[PATCH 1/2] compiler: define __ll_elem for linker list elements
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 3 02:17:47 PST 2024
When built with clang + AddressSanitizer, global variables end up with
a redzone that breaks linker list elements.
The __no_sanitize_address attribute prevents these redzones, but GCC
isn't happy about applying it to anything but functions. Therefore
define a __ll_elem macro for defining linker list elements that takes
care to avoid these redzones when building with clang.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/compiler_types.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 9ef8115a396f..d925b3da296d 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -274,6 +274,12 @@ struct ftrace_likely_data {
#define __cold __attribute__((cold))
#define __section(S) __attribute__((__section__(#S)))
+#ifdef __clang__
+#define __ll_elem(S) __section(S) __used __no_sanitize_address
+#else
+#define __ll_elem(S) __section(S) __used
+#endif
+
#ifdef CONFIG_ENABLE_MUST_CHECK
#define __must_check __attribute__((warn_unused_result))
--
2.39.2
More information about the barebox
mailing list