diff mbox series

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

Message ID CAA4tuqeuayUdsg47N-xatT9DtXOBztqQn02-VODvDGmDH_ZabQ@mail.gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series linker_lists.h: Adding comments to clarify attribute(used) | expand

Commit Message

appujee March 23, 2023, 10:33 p.m. UTC
From 807a20a152cbebcc70ab81de825a28da94a07ab6 Mon Sep 17 00:00:00 2001
From: AdityaK <appujee@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@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 mbox series

Patch

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)                                   \
 ({                                                                     \