diff options
author | Zhangjin Wu <falcon@tinylab.org> | 2023-08-05 14:12:06 +0800 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2023-08-06 18:44:47 +0200 |
commit | d98c1e27e46e47a3ae67e1d048f153598ba82611 (patch) | |
tree | 055357feafc4a2c17a8f4a7f37f4e58143e10826 | |
parent | 8eff9a6b71a28d95cbff96e7353c28859e92a404 (diff) | |
download | linux-nolibc-20230806-for-6.6-1.tar.gz |
tools/nolibc: stackprotector.h: make __stack_chk_init static20230806-for-6.6-1
This allows to generate smaller text/data/dec size.
As the _start_c() function added by crt.h, __stack_chk_init() is called
from _start_c() instead of the assembly _start. So, it is able to mark
it with static now.
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r-- | tools/include/nolibc/crt.h | 2 | ||||
-rw-r--r-- | tools/include/nolibc/stackprotector.h | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h index 32e128b0fb621..a5f33fef16720 100644 --- a/tools/include/nolibc/crt.h +++ b/tools/include/nolibc/crt.h @@ -10,7 +10,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -void __stack_chk_init(void); +static void __stack_chk_init(void); static void exit(int); void _start_c(long *sp) diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index b620f2b9578d6..13f1d0e603875 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -37,8 +37,7 @@ void __stack_chk_fail_local(void) __attribute__((weak,section(".data.nolibc_stack_chk"))) uintptr_t __stack_chk_guard; -__attribute__((weak,section(".text.nolibc_stack_chk"))) __no_stack_protector -void __stack_chk_init(void) +static __no_stack_protector void __stack_chk_init(void) { my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); /* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */ @@ -46,7 +45,7 @@ void __stack_chk_init(void) __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; } #else /* !defined(_NOLIBC_STACKPROTECTOR) */ -__inline__ void __stack_chk_init(void) {} +static void __stack_chk_init(void) {} #endif /* defined(_NOLIBC_STACKPROTECTOR) */ #endif /* _NOLIBC_STACKPROTECTOR_H */ |