summaryrefslogtreecommitdiff
path: root/tools/include/nolibc/compiler.h
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2024-10-14 10:45:28 -0700
committerNamhyung Kim <namhyung@kernel.org>2024-10-14 10:45:28 -0700
commit77b679453d3364688ff3e5153c0be5b2b52672b7 (patch)
tree2279ec3271529a6a4dcec324930a1f46238ffd66 /tools/include/nolibc/compiler.h
parent1a3d6a9723d4dbdad41dad67b66a64d4a84c5f5c (diff)
parent8e929cb546ee42c9a61d24fae60605e9e3192354 (diff)
Merge tag 'v6.12-rc3' into perf-tools-next
To get the fixes in the current perf-tools tree. Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/include/nolibc/compiler.h')
-rw-r--r--tools/include/nolibc/compiler.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index beddc3665d69..9bc6a706a332 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -6,20 +6,30 @@
#ifndef _NOLIBC_COMPILER_H
#define _NOLIBC_COMPILER_H
+#if defined(__has_attribute)
+# define __nolibc_has_attribute(attr) __has_attribute(attr)
+#else
+# define __nolibc_has_attribute(attr) 0
+#endif
+
+#if __nolibc_has_attribute(naked)
+# define __nolibc_entrypoint __attribute__((naked))
+# define __nolibc_entrypoint_epilogue()
+#else
+# define __nolibc_entrypoint __attribute__((optimize("Os", "omit-frame-pointer")))
+# define __nolibc_entrypoint_epilogue() __builtin_unreachable()
+#endif /* __nolibc_has_attribute(naked) */
+
#if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__)
#define _NOLIBC_STACKPROTECTOR
#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
+#if __nolibc_has_attribute(no_stack_protector)
+# define __no_stack_protector __attribute__((no_stack_protector))
#else
# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))
-#endif /* defined(__has_attribute) */
+#endif /* __nolibc_has_attribute(no_stack_protector) */
#endif /* _NOLIBC_COMPILER_H */