summaryrefslogtreecommitdiff
path: root/tools/include/nolibc
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2023-03-25 18:45:15 +0300
committerPaul E. McKenney <paulmck@kernel.org>2023-03-28 02:26:10 +0300
commitff221a6d9ae8191c97d6578f2e1900db483a289d (patch)
tree0fc26859d0e1bfc9b2b91294279e4a3f4528baa5 /tools/include/nolibc
parent9735716830f2d52fd402b853b56cd94c0cb433c0 (diff)
downloadlinux-ff221a6d9ae8191c97d6578f2e1900db483a289d.tar.xz
tools/nolibc: i386: add stackprotector support
Enable the new stackprotector support for i386. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools/include/nolibc')
-rw-r--r--tools/include/nolibc/arch-i386.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h
index e8d0cf545bf1..2d98d78fd3f3 100644
--- a/tools/include/nolibc/arch-i386.h
+++ b/tools/include/nolibc/arch-i386.h
@@ -181,6 +181,8 @@ struct sys_stat_struct {
char **environ __attribute__((weak));
const unsigned long *_auxv __attribute__((weak));
+#define __ARCH_SUPPORTS_STACK_PROTECTOR
+
/* startup code */
/*
* i386 System V ABI mandates:
@@ -188,9 +190,12 @@ const unsigned long *_auxv __attribute__((weak));
* 2) The deepest stack frame should be set to zero
*
*/
-void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
+void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
{
__asm__ volatile (
+#ifdef NOLIBC_STACKPROTECTOR
+ "call __stack_chk_init\n" // initialize stack protector
+#endif
"pop %eax\n" // argc (first arg, %eax)
"mov %esp, %ebx\n" // argv[] (second arg, %ebx)
"lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)