Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/nolibc: stackprotector: mark implicitly used symbols as used

During LTO the references from the compiler-generated prologue and
epilogues to the stack protector symbols are not visible and the symbols
are removed.
This will then lead to errors during linking.
As those symbols are already #ifdeffed-out if unused mark them as "used"
to prevent their removal.

Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240812-nolibc-lto-v2-2-736af7bbefa8@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

+2 -2
+2 -2
tools/include/nolibc/stackprotector.h
··· 18 18 * triggering stack protector errors themselves 19 19 */ 20 20 21 - __attribute__((weak,noreturn,section(".text.nolibc_stack_chk"))) 21 + __attribute__((weak,used,noreturn,section(".text.nolibc_stack_chk"))) 22 22 void __stack_chk_fail(void) 23 23 { 24 24 pid_t pid; ··· 34 34 __stack_chk_fail(); 35 35 } 36 36 37 - __attribute__((weak,section(".data.nolibc_stack_chk"))) 37 + __attribute__((weak,used,section(".data.nolibc_stack_chk"))) 38 38 uintptr_t __stack_chk_guard; 39 39 40 40 static __no_stack_protector void __stack_chk_init(void)