From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] compiler: define __ll_elem for linker list elements
Date: Wed, 3 Jan 2024 11:17:47 +0100 [thread overview]
Message-ID: <20240103101748.2629927-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240103101748.2629927-1-a.fatoum@pengutronix.de>
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@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
next prev parent reply other threads:[~2024-01-03 10:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 10:17 [PATCH 0/2] compiler: fix clang and address sanitizer coexistance Ahmad Fatoum
2024-01-03 10:17 ` Ahmad Fatoum [this message]
2024-01-03 10:17 ` [PATCH 2/2] treewide: mark linker list elements with __ll_elem Ahmad Fatoum
2024-01-04 9:10 ` [PATCH 0/2] compiler: fix clang and address sanitizer coexistance Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240103101748.2629927-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox