mirror of
https://github.com/torvalds/linux
synced 2024-09-06 09:51:23 +00:00
tools/nolibc: fix segfaults on compilers without attribute no_stack_protector
Not all compilers, notably GCC < 10, have support for __attribute__((no_stack_protector)). Fall back to a mechanism that also works there. Tested with GCC 9.5.0 from kernel.org crosstools. 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>
This commit is contained in:
parent
0093c2dae8
commit
e76b70dec9
|
@ -175,7 +175,7 @@ char **environ __attribute__((weak));
|
|||
const unsigned long *_auxv __attribute__((weak));
|
||||
|
||||
/* startup code */
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
#ifdef _NOLIBC_STACKPROTECTOR
|
||||
|
|
|
@ -202,7 +202,7 @@ char **environ __attribute__((weak));
|
|||
const unsigned long *_auxv __attribute__((weak));
|
||||
|
||||
/* startup code */
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
#ifdef _NOLIBC_STACKPROTECTOR
|
||||
|
|
|
@ -190,7 +190,7 @@ const unsigned long *_auxv __attribute__((weak));
|
|||
* 2) The deepest stack frame should be set to zero
|
||||
*
|
||||
*/
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
#ifdef _NOLIBC_STACKPROTECTOR
|
||||
|
|
|
@ -172,7 +172,7 @@ const unsigned long *_auxv __attribute__((weak));
|
|||
#endif
|
||||
|
||||
/* startup code */
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
#ifdef _NOLIBC_STACKPROTECTOR
|
||||
|
|
|
@ -182,7 +182,7 @@ char **environ __attribute__((weak));
|
|||
const unsigned long *_auxv __attribute__((weak));
|
||||
|
||||
/* startup code, note that it's called __start on MIPS */
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) __start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector __start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
/*".set nomips16\n"*/
|
||||
|
|
|
@ -180,7 +180,7 @@ char **environ __attribute__((weak));
|
|||
const unsigned long *_auxv __attribute__((weak));
|
||||
|
||||
/* startup code */
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
".option push\n"
|
||||
|
|
|
@ -190,7 +190,7 @@ const unsigned long *_auxv __attribute__((weak));
|
|||
* 2) The deepest stack frame should be zero (the %rbp).
|
||||
*
|
||||
*/
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
|
||||
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
|
||||
{
|
||||
__asm__ volatile (
|
||||
#ifdef _NOLIBC_STACKPROTECTOR
|
||||
|
|
|
@ -12,4 +12,14 @@
|
|||
|
||||
#endif /* defined(__SSP__) ... */
|
||||
|
||||
#if defined(__has_attribute)
|
||||
# if __has_attribute(no_stack_protector)
|
||||
# define __no_stack_protector __attribute__((no_stack_protector))
|
||||
# else
|
||||
# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))
|
||||
# endif
|
||||
#else
|
||||
# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))
|
||||
#endif /* defined(__has_attribute) */
|
||||
|
||||
#endif /* _NOLIBC_COMPILER_H */
|
||||
|
|
|
@ -37,7 +37,7 @@ void __stack_chk_fail_local(void)
|
|||
__attribute__((weak,section(".data.nolibc_stack_chk")))
|
||||
uintptr_t __stack_chk_guard;
|
||||
|
||||
__attribute__((weak,no_stack_protector,section(".text.nolibc_stack_chk")))
|
||||
__attribute__((weak,section(".text.nolibc_stack_chk"))) __no_stack_protector
|
||||
void __stack_chk_init(void)
|
||||
{
|
||||
my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0);
|
||||
|
|
Loading…
Reference in a new issue