aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-03-28 11:44:55 -0400
committerTom Rini <trini@konsulko.com>2023-03-28 12:08:50 -0400
commita5eaf38e727280a0db81c21ebc62eeff9d9056b2 (patch)
tree76071e6871ed4ced7da36aab9ba20485fb7cc8e2
parent953a96d23036132be37a5d2071e580ad4fe3d4c9 (diff)
downloadu-boot-CHECK/rework-linkerlists.zip
u-boot-CHECK/rework-linkerlists.tar.gz
u-boot-CHECK/rework-linkerlists.tar.bz2
linker_lists: Rework start/end macros to not rely on undefined behaviorCHECK/rework-linkerlists
Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems. Reported-by: AdityaK <appujee@google.com> Suggested-by: Andrew Pinski <pinskia@gcc.gnu.org> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108915 Signed-off-by: Tom Rini <trini@konsulko.com>
-rw-r--r--include/linker_lists.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/linker_lists.h b/include/linker_lists.h
index d3da9d4..f9a2ee0 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -127,7 +127,9 @@
static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \
__attribute__((unused)) \
__section("__u_boot_list_2_"#_list"_1"); \
- (_type *)&start; \
+ _type * tmp = (_type *)&start; \
+ asm("":"+r"(tmp)); \
+ tmp; \
})
/**
@@ -153,7 +155,9 @@
({ \
static char end[0] __aligned(4) __attribute__((unused)) \
__section("__u_boot_list_2_"#_list"_3"); \
- (_type *)&end; \
+ _type * tmp = (_type *)&end; \
+ asm("":"+r"(tmp)); \
+ tmp; \
})
/**
* ll_entry_count() - Return the number of elements in linker-generated array
@@ -247,7 +251,9 @@
({ \
static char start[0] __aligned(4) __attribute__((unused)) \
__section("__u_boot_list_1"); \
- (_type *)&start; \
+ _type * tmp = (_type *)&start; \
+ asm("":"+r"(tmp)); \
+ tmp; \
})
/**
@@ -270,7 +276,9 @@
({ \
static char end[0] __aligned(4) __attribute__((unused)) \
__section("__u_boot_list_3"); \
- (_type *)&end; \
+ _type * tmp = (_type *)&end; \
+ asm("":"+r"(tmp)); \
+ tmp; \
})
#endif /* __ASSEMBLY__ */