[U-Boot] [PATCH v2 01/80] linker_lists: Add a function to access a linker list entry

Simon Glass sjg at chromium.org
Wed Mar 25 19:21:49 CET 2015


Once declared, you cannot access a linker_list entry since you do not have
a symbol name for it. Add llsym() macro to provide this. This avoids
searching for the symbol at run-time based on name.

An example usage is to declare a driver with U_BOOT_DRIVER(), then obtain
a pointer to that driver later.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

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

diff --git a/include/linker_lists.h b/include/linker_lists.h
index 940c871..b22d169 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -103,6 +103,16 @@
  */
 
 /**
+ * ll_sym() - Access a linker-generated array entry
+ * @_type:	Data type of the entry
+ * @_name:	Name of the entry
+ * @_list:	name of the list. Should contain only characters allowed
+ *		in a C variable name!
+ */
+#define llsym(_type, _name, _list) \
+		((_type *)&_u_boot_list_2_##_list##_2_##_name)
+
+/**
  * ll_entry_declare() - Declare linker-generated array entry
  * @_type:	Data type of the entry
  * @_name:	Name of the entry
-- 
2.2.0.rc0.207.ga3a616c



More information about the U-Boot mailing list