[RFC PATCH 4/9] linker_lists.h: add ll_*_name() helper macros

Rasmus Villemoes ravi at prevas.dk
Fri May 22 23:27:51 CEST 2026


Instead of open-coding the same section and symbol naming scheme over
and over, add helper macros that take the list name (and, for entries,
the name of the entry/entries) and construct a suitable string
literal.

This will be particularly important when the followup patches add even
more uses of those names.

No functional change.

Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
---
 include/linker_lists.h | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/include/linker_lists.h b/include/linker_lists.h
index a8b7e2c9f2b..b6437ad6462 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -19,6 +19,12 @@
 
 #if !defined(__ASSEMBLY__)
 
+#define ll_start_section_name(_list)        "__u_boot_list_2_"#_list"_1"
+#define ll_entry_section_name(_list, _name) "__u_boot_list_2_"#_list"_2_"#_name
+#define ll_end_section_name(_list)          "__u_boot_list_2_"#_list"_3"
+
+#define ll_entry_symbol_name(_list, _name) _u_boot_list_2_##_list##_2_##_name
+
 /**
  * llsym() - Access a linker-generated array entry
  * @_type:	Data type of the entry
@@ -27,7 +33,7 @@
  *		in a C variable name!
  */
 #define llsym(_type, _name, _list) \
-		((_type *)&_u_boot_list_2_##_list##_2_##_name)
+		((_type *)&ll_entry_symbol_name(_list, _name))
 
 /**
  * ll_entry_declare() - Declare linker-generated array entry
@@ -68,8 +74,8 @@
  *   };
  */
 #define ll_entry_declare(_type, _name, _list)				\
-	_type _u_boot_list_2_##_list##_2_##_name __aligned(4)		\
-			__section("__u_boot_list_2_"#_list"_2_"#_name)
+	_type ll_entry_symbol_name(_list, _name) __aligned(4)		\
+			__section(ll_entry_section_name(_list, _name))
 
 /**
  * ll_entry_declare_list() - Declare a list of link-generated array entries
@@ -90,8 +96,8 @@
  *   };
  */
 #define ll_entry_declare_list(_type, _name, _list)			\
-	_type _u_boot_list_2_##_list##_2_##_name[] __aligned(4)		\
-			__section("__u_boot_list_2_"#_list"_2_"#_name)
+	_type ll_entry_symbol_name(_list, _name)[] __aligned(4)		\
+			__section(ll_entry_section_name(_list, _name))
 
 /*
  * We need a 0-byte-size type for iterator symbols, and the compiler
@@ -123,7 +129,7 @@
 #define ll_entry_start(_type, _list)					\
 ({									\
 	static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN)	\
-		__section("__u_boot_list_2_"#_list"_1");			\
+		__section(ll_start_section_name(_list));		\
 	_type * tmp = (_type *)&start;					\
 	asm("":"+r"(tmp));						\
 	tmp;								\
@@ -165,7 +171,7 @@
 #define ll_entry_end(_type, _list)					\
 ({									\
 	static char end[0] __aligned(1)					\
-		__section("__u_boot_list_2_"#_list"_3");			\
+		__section(ll_end_section_name(_list));			\
 	_type * tmp = (_type *)&end;					\
 	asm("":"+r"(tmp));						\
 	tmp;								\
@@ -248,7 +254,7 @@
  */
 #define ll_start_decl(_sym, _type, _list)					\
 	static _type _sym[0] __aligned(CONFIG_LINKER_LIST_ALIGN)	\
-		__section("__u_boot_list_2_" #_list "_1")
+		__section(ll_start_section_name(_list))
 
 /*
  * ll_end_decl uses __aligned(1) to avoid padding before the end marker.
@@ -256,7 +262,7 @@
  */
 #define ll_end_decl(_sym, _type, _list)					\
 	static _type _sym[0] __aligned(1)				\
-		__section("__u_boot_list_2_" #_list "_3")
+		__section(ll_end_section_name(_list))
 
 /**
  * ll_entry_get() - Retrieve entry from linker-generated array by name
@@ -281,10 +287,10 @@
  */
 #define ll_entry_get(_type, _name, _list)				\
 	({								\
-		extern _type _u_boot_list_2_##_list##_2_##_name		\
+		extern _type ll_entry_symbol_name(_list, _name)		\
 			__aligned(4);					\
 		_type *_ll_result =					\
-			&_u_boot_list_2_##_list##_2_##_name;		\
+			&ll_entry_symbol_name(_list, _name);		\
 		_ll_result;						\
 	})
 
@@ -302,7 +308,7 @@
  * @_list: name of the list
  */
 #define ll_entry_ref(_type, _name, _list)				\
-	((_type *)&_u_boot_list_2_##_list##_2_##_name)
+	((_type *)&ll_entry_symbol_name(_list, _name))
 
 #endif /* __ASSEMBLY__ */
 
-- 
2.54.0



More information about the U-Boot mailing list