[PATCH] linker_lists.h: Adding comments to clarify attribute(used)

appujee appujee at google.com
Thu Mar 23 23:33:31 CET 2023


>From 807a20a152cbebcc70ab81de825a28da94a07ab6 Mon Sep 17 00:00:00 2001
From: AdityaK <appujee at google.com>
Date: Thu, 23 Mar 2023 15:30:15 -0700
Subject: [PATCH] [PATCH] linker_lists.h: Adding comments to clarify
 attribute(used)

Change-Id: I2878f458b8955cac23acd54f4cfaafe7f132935b

Signed-off-by: AdityaK <appujee at google.com>

Tom Rini suggested we add comments because it may be confusing to have
both attribute(used) and attribute(unused) in the same declaration.

---
 include/linker_lists.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linker_lists.h b/include/linker_lists.h
index 5e95e30b5d..4e41f86eab 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -121,6 +121,14 @@
  * ::
  *
  *   struct my_sub_cmd *msc = ll_entry_start(struct my_sub_cmd, cmd_sub);
+ *
+ * The static variable `start` gets dropped by clang compiler in optimized
+ * build as zero sized arrays aren't C-standards compliant.
+ * https://github.com/llvm/llvm-project/issues/60967
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108915
+ * Adding attribute((used)) allows the symbol to be preserved. Note that
+ * attribute((used)) and attribute((unused)) do not cancel each other as
+ * they had different semantics.
  */
 #define ll_entry_start(_type, _list)                                   \
 ({                                                                     \
--


More information about the U-Boot mailing list