With SKIP_RELOCATE_CODE, relocate.S relocates a literal only when its
value lies between __data_start and __data_end. Without -fdata-sections,
GCC can reach .data objects through a section anchor that lies past the
end of their block. If that block is the last one in .data, the anchor
lies above __data_end, so a literal that holds it keeps its link
address, and stores through it go to the read-only alias of the data.
The .data of r8a78000_ironhide_cm33, the only board with
SKIP_RELOCATE_CODE, does not trigger this today.

Keep -ffunction-sections -fdata-sections with LTO when
SKIP_RELOCATE_CODE is set. This changes no image on main.

Signed-off-by: Josef Schlehofer <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Marek BehĂșn <[email protected]>
Cc: Simon Glass <[email protected]>
---
 arch/arm/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index e9606e7c78a..7e99e61ca82 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -17,7 +17,7 @@ ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
 LDFLAGS_FINAL += --gc-sections
 endif
 
-ifneq ($(LTO_ENABLE).$(CONFIG_ARM64),y.)
+ifneq ($(LTO_ENABLE).$(CONFIG_ARM64)$(CONFIG_SKIP_RELOCATE_CODE),y.)
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 endif
 
-- 
2.54.0 (Apple Git-157)

Reply via email to