Re: [Mingw-w64-public] [PATCH 2/3] crt: Provide the stack protector functions/variables in libmingwex too

2022-09-14 Thread LIU Hao
在 2022/9/15 03:29, Martin Storsjö 写道: As we're free to use any Windows specific APIs here, I considered using TerminateProcess() - but I preferred to avoid that as it's not available for older Windows Store apps (targeting Windows 8.x iirc). (We do have a fallback implementation of it for such

Re: [Mingw-w64-public] [PATCH 2/3] crt: Provide the stack protector functions/variables in libmingwex too

2022-09-14 Thread Martin Storsjö
On Thu, 15 Sep 2022, Alvin Wong wrote: Hi, On 14/9/2022 15:33, Martin Storsjö wrote: +void __cdecl __attribute__((__noreturn__)) __stack_chk_fail(void) { + char msg[] = "*** stack smashing detected ***: terminated\n"; + write(STDERR_FILENO, msg, strlen(msg)); + abort(); +} I have a feelin

Re: [Mingw-w64-public] [PATCH 2/3] crt: Provide the stack protector functions/variables in libmingwex too

2022-09-14 Thread Alvin Wong via Mingw-w64-public
Hi, On 14/9/2022 15:33, Martin Storsjö wrote: > +void __cdecl __attribute__((__noreturn__)) __stack_chk_fail(void) { > + char msg[] = "*** stack smashing detected ***: terminated\n"; > + write(STDERR_FILENO, msg, strlen(msg)); > + abort(); > +} I have a feeling that calling `abort()` may not b

Re: [Mingw-w64-public] [PATCH] headers: Remove _GNU_SOURCE ifdefs around mempcpy fortification

2022-09-14 Thread Martin Storsjö
On Wed, 14 Sep 2022, LIU Hao wrote: 在 2022-09-14 15:20, Martin Storsjö 写道: The regular mempcpy declaration is visible even without _GNU_SOURCE, so this one should match. Signed-off-by: Martin Storsjö --- mingw-w64-headers/crt/string.h | 2 -- 1 file changed, 2 deletions(-) Well, `mempc

Re: [Mingw-w64-public] [PATCH 1/3] crt: Implement a subset of libssp functions to libmingwex

2022-09-14 Thread Martin Storsjö
On Wed, 14 Sep 2022, LIU Hao wrote: 在 2022-09-14 15:33, Martin Storsjö 写道: + +void __cdecl __attribute__((__noreturn__)) __chk_fail(void) { + char msg[] = "*** buffer overflow detected ***: terminated\n"; + write(STDERR_FILENO, msg, strlen(msg)); + abort(); +} Are there any reasons why `ms

Re: [Mingw-w64-public] Linking error with _set_se_translator

2022-09-14 Thread Martin Storsjö
On Wed, 14 Sep 2022, Biswapriyo Nath wrote: Thanks for the patch. It worked in ucrt and msvcrt x86_64 environments. But if we consider all four CPU architectures there is some missing symbols in msvcrt.def.in. It seems that many symbols are specified for x86_64 only including _set_se_translator

Re: [Mingw-w64-public] Linking error with _set_se_translator

2022-09-14 Thread Biswapriyo Nath
Thanks for the patch. It worked in ucrt and msvcrt x86_64 environments. But if we consider all four CPU architectures there is some missing symbols in msvcrt.def.in. It seems that many symbols are specified for x86_64 only including _set_se_translator. For example, "?what@exception@@UEBAPEBDXZ" is

Re: [Mingw-w64-public] [PATCH 1/3] crt: Implement a subset of libssp functions to libmingwex

2022-09-14 Thread LIU Hao
在 2022-09-14 15:33, Martin Storsjö 写道: + +void __cdecl __attribute__((__noreturn__)) __chk_fail(void) { + char msg[] = "*** buffer overflow detected ***: terminated\n"; + write(STDERR_FILENO, msg, strlen(msg)); + abort(); +} Are there any reasons why `msg` is not `static const`? I just had a

Re: [Mingw-w64-public] [PATCH] headers: Remove _GNU_SOURCE ifdefs around mempcpy fortification

2022-09-14 Thread LIU Hao
在 2022-09-14 15:20, Martin Storsjö 写道: The regular mempcpy declaration is visible even without _GNU_SOURCE, so this one should match. Signed-off-by: Martin Storsjö --- mingw-w64-headers/crt/string.h | 2 -- 1 file changed, 2 deletions(-) Well, `mempcpy()` is indeed a GNU extension, so `_

Re: [Mingw-w64-public] invalid O_WRONLY read sets errno=EACCES instead of EBADF

2022-09-14 Thread Michel Zou
oh I can reproduce now on the native windows, seems like a wine bug after all https://bugs.winehq.org/show_bug.cgi?id=53677 sorry for the noise, and thanks for the help From: LIU Hao Sent: Tuesday, September 13, 2022 7:34 AM To: mingw-w64-public@lists.sourcefor

Re: [Mingw-w64-public] Linking error with _set_se_translator

2022-09-14 Thread Martin Storsjö
On Wed, 14 Sep 2022, Biswapriyo Nath wrote: Thanks for the explanation. I have tried to add the following line in ucrtbase.def.in ``` _Z18_set_se_translatorPFvjP19_EXCEPTION_POINTERSE == _set_se_translator ``` But the given sample program does not link with `g++ test.cpp` command. I have to add

Re: [Mingw-w64-public] Linking error with _set_se_translator

2022-09-14 Thread Biswapriyo Nath
Thanks for the explanation. I have tried to add the following line in ucrtbase.def.in ``` _Z18_set_se_translatorPFvjP19_EXCEPTION_POINTERSE == _set_se_translator ``` But the given sample program does not link with `g++ test.cpp` command. I have to add `-lucrtbase` option explicitly. Did you mean s

[Mingw-w64-public] [PATCH 1/3] crt: Implement a subset of libssp functions to libmingwex

2022-09-14 Thread Martin Storsjö
This is the subset of functions that ends up called when our headers are used with _FORTIFY_SOURCE defined. This avoids needing to manually pass -lssp in such build configurations. Signed-off-by: Martin Storsjö --- mingw-w64-crt/Makefile.am | 4 mingw-w64-crt/ssp/chk_fail.c| 17 +

[Mingw-w64-public] [PATCH 3/3] RFC: crt: Implement the rest of the libssp functions

2022-09-14 Thread Martin Storsjö
Our fortification macros don't wrap these stdio functions (since there's already lots of variability, whether calling directly to the CRT's stdio functions, or if calling the __USE_MINGW_ANSI_STDIO replacements), but this at least provides token implementations if someone implements fortification o

[Mingw-w64-public] [PATCH 2/3] crt: Provide the stack protector functions/variables in libmingwex too

2022-09-14 Thread Martin Storsjö
While the compiler drivers do add -lssp automatically when linking with -fstack-protector-strong, this also allows relying entirely on libmingwex. This implementation should be functionally equivalent to GCC's libssp for a mingw build configuration. This allows toolchains that don't otherwise use

[Mingw-w64-public] [PATCH] headers: Remove _GNU_SOURCE ifdefs around mempcpy fortification

2022-09-14 Thread Martin Storsjö
The regular mempcpy declaration is visible even without _GNU_SOURCE, so this one should match. Signed-off-by: Martin Storsjö --- mingw-w64-headers/crt/string.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/mingw-w64-headers/crt/string.h b/mingw-w64-headers/crt/string.h index 49027c18d..90

Re: [Mingw-w64-public] Linking error with _set_se_translator

2022-09-14 Thread Martin Storsjö
On Wed, 14 Sep 2022, Biswapriyo Nath wrote: * Sample code (test.cpp): #include #include #include int main() { _set_se_translator(NULL); } * gcc output: undefined reference to `__imp__Z18_set_se_translatorPFvjP19_EXCEPTION_POINTERSE' * clang output: undefined symbol: __declspec(dllimport