Skip to contentSkip to conversation

windows: Add _stack_chk_guard/_stack_chk_fail symbols for Windows 64-bit target

PATCH In review Daniel Kiper via Grub-devel 2 participants 2 messages Apr 9, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 windows: Add _stack_chk_guard/_stack_chk_fail symbols for Windows 64-bit target

Otherwise the GRUB cannot start when stack protector is enabled on EFI platforms.

---
 include/grub/stack_protector.h | 4 ++++
 1 file changed, 4 insertions(+)
include/grub/stack_protector.h +4 -0
index c88dc00b5..13d2657d9 100644
@@ -25,6 +25,10 @@
 #ifdef GRUB_STACK_PROTECTOR
 extern grub_addr_t EXPORT_VAR (__stack_chk_guard);
 extern void __attribute__ ((noreturn)) EXPORT_FUNC (__stack_chk_fail) (void);
+#if defined(_WIN64) && !defined(__CYGWIN__) /* MinGW, Windows 64-bit target. */
+static grub_addr_t __attribute__ ((weakref("__stack_chk_guard"))) EXPORT_VAR (_stack_chk_guard);
+static void __attribute__ ((noreturn, weakref("__stack_chk_fail"))) EXPORT_FUNC (_stack_chk_fail) (void);
+#endif
 #endif
 
 #endif /* GRUB_STACK_PROTECTOR_H */
Signature · 7 lines
2.11.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

LGTM. Reviewed-by: Vladimir Serbinenko

Quoted 27 lines · Daniel Kiper

Otherwise the GRUB cannot start when stack protector is enabled on EFI platforms.

---
 include/grub/stack_protector.h | 4 ++++
 1 file changed, 4 insertions(+)
include/grub/stack_protector.h +1 -0
index c88dc00b5..13d2657d9 100644
@@ -25,6 +25,10 @@
 #ifdef GRUB_STACK_PROTECTOR
 extern grub_addr_t EXPORT_VAR (__stack_chk_guard);
 extern void __attribute__ ((noreturn)) EXPORT_FUNC (__stack_chk_fail)
 (void);
+#if defined(_WIN64) && !defined(__CYGWIN__) /* MinGW, Windows 64-bit

target. */
+static grub_addr_t __attribute__ ((weakref("__stack_chk_guard"))) EXPORT_VAR (_stack_chk_guard);
+static void __attribute__ ((noreturn, weakref("__stack_chk_fail"))) EXPORT_FUNC (_stack_chk_fail) (void);
+#endif
#endif

Quoted 5 lines

#endif /* GRUB_STACK_PROTECTOR_H */
--
2.11.0

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel