[PATCH u-boot v3 08/39] linker_lists: declare lists and entries as __ADDRESSABLE for LTO

Marek Behún
2021-03-16T12:25:38Z

Use the __ADDRESSABLE() macro to make entries and lists declared by
ll_entry_declare() and ll_entry_declare_list() addressable so that when
building with LTO the compiler does not optimize this data away.

Signed-off-by: Marek Beh?n <marek.behun@nic.cz>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
include/linker_lists.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linker_lists.h b/include/linker_lists.h
index 815a90691a..c9c3b3c2ad 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -88,7 +88,9 @@
* .y = 4,
* };
*/
-#define ll_entry_declare(_type, _name, _list) \
+#define ll_entry_declare(_type, _name, _list) \
+ __lldecl(_type, _name, _list); \
+ __ADDRESSABLE(__llname(_name, _list)); \
__lldecl(_type, _name, _list)

/**
@@ -109,7 +111,9 @@
* { .x = 1, .y = 7 }
* };
*/
-#define ll_entry_declare_list(_type, _name, _list) \
+#define ll_entry_declare_list(_type, _name, _list) \
+ __lldecl(_type, _name, _list)[]; \
+ __ADDRESSABLE(__llname(_name, _list)); \
__lldecl(_type, _name, _list)[]

/*
--
2.26.2