Commit 0d8c461a authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Paul E. McKenney

tools/nolibc: x86_64: add stackprotector support

Enable the new stackprotector support for x86_64.
Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent ff221a6d
...@@ -181,6 +181,8 @@ struct sys_stat_struct { ...@@ -181,6 +181,8 @@ struct sys_stat_struct {
char **environ __attribute__((weak)); char **environ __attribute__((weak));
const unsigned long *_auxv __attribute__((weak)); const unsigned long *_auxv __attribute__((weak));
#define __ARCH_SUPPORTS_STACK_PROTECTOR
/* startup code */ /* startup code */
/* /*
* x86-64 System V ABI mandates: * x86-64 System V ABI mandates:
...@@ -191,6 +193,9 @@ const unsigned long *_auxv __attribute__((weak)); ...@@ -191,6 +193,9 @@ const unsigned long *_auxv __attribute__((weak));
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
{ {
__asm__ volatile ( __asm__ volatile (
#ifdef NOLIBC_STACKPROTECTOR
"call __stack_chk_init\n" // initialize stack protector
#endif
"pop %rdi\n" // argc (first arg, %rdi) "pop %rdi\n" // argc (first arg, %rdi)
"mov %rsp, %rsi\n" // argv[] (second arg, %rsi) "mov %rsp, %rsi\n" // argv[] (second arg, %rsi)
"lea 8(%rsi,%rdi,8),%rdx\n" // then a NULL then envp (third arg, %rdx) "lea 8(%rsi,%rdi,8),%rdx\n" // then a NULL then envp (third arg, %rdx)
......
...@@ -80,6 +80,8 @@ CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ ...@@ -80,6 +80,8 @@ CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \
$(call cc-option,-mstack-protector-guard=global) \ $(call cc-option,-mstack-protector-guard=global) \
$(call cc-option,-fstack-protector-all) $(call cc-option,-fstack-protector-all)
CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR)
CFLAGS_s390 = -m64 CFLAGS_s390 = -m64
CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \ CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \
$(call cc-option,-fno-stack-protector) \ $(call cc-option,-fno-stack-protector) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment