In https://gcc.gnu.org/PR121911 `gcc` started enforcing the type of
`__stack_chk_guard` to `uintptr_t` and broke `mingw-w64` build as:
```
ssp/stack_chk_guard.c:11:7: error: conflicting types for '__stack_chk_guard';
have 'void *'
11 | void *__stack_chk_guard;
| ^~~~~~~~~~~~~~~~~
cc1: note: previous declaration of '__stack_chk_guard' with type 'long long
unsigned int'
ssp/stack_chk_guard.c:11:7: warning: declaration of '__stack_chk_guard' shadows
a global declaration [-Wshadow]
11 | void *__stack_chk_guard;
| ^~~~~~~~~~~~~~~~~
```
Let's match the declaration to unsigned type as suggested by upstream in
https://gcc.gnu.org/PR121911#c6.
---
mingw-w64-crt/ssp/stack_chk_guard.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mingw-w64-crt/ssp/stack_chk_guard.c
b/mingw-w64-crt/ssp/stack_chk_guard.c
index 6a4d862cc..9d961e333 100644
--- a/mingw-w64-crt/ssp/stack_chk_guard.c
+++ b/mingw-w64-crt/ssp/stack_chk_guard.c
@@ -8,7 +8,7 @@
#include <stdlib.h>
#include <stdint.h>
-void *__stack_chk_guard;
+uintptr_t __stack_chk_guard;
#if defined __SSP__ || defined __SSP_STRONG__ || defined __SSP_ALL__
// This function requires `no_stack_protector` because it changes the
@@ -35,18 +35,18 @@ static void __cdecl init(void)
// which tries to load the function dynamically, and falls back on
// using RtlGenRandom if not available.
if (rand_s(&ui) == 0) {
- __stack_chk_guard = (void*)(intptr_t)ui;
+ __stack_chk_guard = ui;
#if __SIZEOF_POINTER__ > 4
rand_s(&ui);
- __stack_chk_guard = (void*)(((intptr_t)__stack_chk_guard) << 32 | ui);
+ __stack_chk_guard = __stack_chk_guard << 32 | ui;
#endif
return;
}
// If rand_s failed (it shouldn't), hardcode a nonzero default stack guard.
#if __SIZEOF_POINTER__ > 4
- __stack_chk_guard = (void*)0xdeadbeefdeadbeefULL;
+ __stack_chk_guard = 0xdeadbeefdeadbeefULL;
#else
- __stack_chk_guard = (void*)0xdeadbeef;
+ __stack_chk_guard = 0xdeadbeef;
#endif
}
--
2.53.0
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public