aboutsummaryrefslogtreecommitdiff
path: root/tools/include/nolibc/compiler.h
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2023-05-21 11:36:34 +0200
committerPaul E. McKenney <paulmck@kernel.org>2023-06-09 11:46:08 -0700
commit818924d1295ea16db267ea6defe08b21243583b6 (patch)
tree96c0095bd3e7dfd8210835f1db2d1149ad36a0d7 /tools/include/nolibc/compiler.h
parente21a2eef74305b9ec2b8dcecf364aeb5e2e10e2e (diff)
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/compiler.h')
-rw-r--r--tools/include/nolibc/compiler.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
new file mode 100644
index 000000000000..57da75cea799
--- /dev/null
+++ b/tools/include/nolibc/compiler.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * NOLIBC compiler support header
+ * Copyright (C) 2023 Thomas Weißschuh <linux@weissschuh.net>
+ */
+#ifndef _NOLIBC_COMPILER_H
+#define _NOLIBC_COMPILER_H
+
+#if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__)
+
+#define _NOLIBC_STACKPROTECTOR
+
+#endif /* defined(__SSP__) ... */
+
+#endif /* _NOLIBC_COMPILER_H */