Skip to content

Commit dcb677c

Browse files
lzufalconwtarreau
authored andcommitted
tools/nolibc: stackprotector.h: make __stack_chk_init static
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>
1 parent ce1bb82 commit dcb677c

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

tools/include/nolibc/crt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
char **environ __attribute__((weak));
1111
const unsigned long *_auxv __attribute__((weak));
1212

13-
void __stack_chk_init(void);
13+
static void __stack_chk_init(void);
1414
static void exit(int);
1515

1616
void _start_c(long *sp)

tools/include/nolibc/stackprotector.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ void __stack_chk_fail_local(void)
3737
__attribute__((weak,section(".data.nolibc_stack_chk")))
3838
uintptr_t __stack_chk_guard;
3939

40-
__attribute__((weak,section(".text.nolibc_stack_chk"))) __no_stack_protector
41-
void __stack_chk_init(void)
40+
static __no_stack_protector void __stack_chk_init(void)
4241
{
4342
my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0);
4443
/* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */
4544
if (__stack_chk_guard != (uintptr_t) &__stack_chk_guard)
4645
__stack_chk_guard ^= (uintptr_t) &__stack_chk_guard;
4746
}
4847
#else /* !defined(_NOLIBC_STACKPROTECTOR) */
49-
__inline__ void __stack_chk_init(void) {}
48+
static void __stack_chk_init(void) {}
5049
#endif /* defined(_NOLIBC_STACKPROTECTOR) */
5150

5251
#endif /* _NOLIBC_STACKPROTECTOR_H */

0 commit comments

Comments
 (0)