summaryrefslogtreecommitdiff
path: root/tools/include/nolibc/arch-riscv.h
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2023-05-21 12:36:34 +0300
committerPaul E. McKenney <paulmck@kernel.org>2023-06-09 21:46:08 +0300
commit818924d1295ea16db267ea6defe08b21243583b6 (patch)
tree96c0095bd3e7dfd8210835f1db2d1149ad36a0d7 /tools/include/nolibc/arch-riscv.h
parente21a2eef74305b9ec2b8dcecf364aeb5e2e10e2e (diff)
downloadlinux-818924d1295ea16db267ea6defe08b21243583b6.tar.xz
tools/nolibc: add autodetection for stackprotector support
The stackprotector support in nolibc should be enabled iff it is also enabled in the compiler. Use the preprocessor defines added by gcc and clang if stackprotector support is enable to automatically do so in nolibc. This completely removes the need for any user-visible API. To avoid inlining the lengthy preprocessor check into every user introduce a new header compiler.h that abstracts the logic away. As the define NOLIBC_STACKPROTECTOR is now not user-relevant anymore prefix it with an underscore. Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/lkml/20230520133237.GA27501@1wt.eu/ 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>
Diffstat (limited to 'tools/include/nolibc/arch-riscv.h')
-rw-r--r--tools/include/nolibc/arch-riscv.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h
index d0439249c9c9..86616aeb77a0 100644
--- a/tools/include/nolibc/arch-riscv.h
+++ b/tools/include/nolibc/arch-riscv.h
@@ -7,6 +7,8 @@
#ifndef _NOLIBC_ARCH_RISCV_H
#define _NOLIBC_ARCH_RISCV_H
+#include "compiler.h"
+
struct sys_stat_struct {
unsigned long st_dev; /* Device. */
unsigned long st_ino; /* File serial number. */
@@ -177,8 +179,6 @@ struct sys_stat_struct {
char **environ __attribute__((weak));
const unsigned long *_auxv __attribute__((weak));
-#define __ARCH_SUPPORTS_STACK_PROTECTOR
-
/* startup code */
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void)
{
@@ -187,7 +187,7 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protec
".option norelax\n"
"lla gp, __global_pointer$\n"
".option pop\n"
-#ifdef NOLIBC_STACKPROTECTOR
+#ifdef _NOLIBC_STACKPROTECTOR
"call __stack_chk_init\n" /* initialize stack protector */
#endif
REG_L" a0, 0(sp)\n" /* argc (a0) was in the stack */