With LTO, keep-syms-lto.o puts pointers to linker list entries in .discard.addressable to prevent the entries from being removed. On mpc85xx, -mrelocatable creates .fixup entries for these pointers, and the linker scripts keep all .fixup input sections, leaving .discard.addressable in the image.
Discard .discard* sections and the .fixup entries of keep-syms-lto.o, which point into them. Otherwise, ld leaves zero words in the fixup table, which start.S treats as addresses to relocate. With them, the Turris NOR build with LTO hung after the DRAM message. Signed-off-by: Josef Schlehofer <[email protected]> Cc: Marek BehĂșn <[email protected]> --- Changes in v2: - shorter commit message --- arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 11 ++++++++++- arch/powerpc/cpu/mpc85xx/u-boot.lds | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds index d918b4395bf..dd4d18bc24b 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds @@ -35,7 +35,7 @@ SECTIONS KEEP(*(.got2)) KEEP(*(.got)) _FIXUP_TABLE_ = .; - KEEP(*(.fixup)) + KEEP(*(EXCLUDE_FILE(*keep-syms-lto.o) .fixup)) } __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1; __fixup_entries = (. - _FIXUP_TABLE_) >> 2; @@ -63,6 +63,15 @@ SECTIONS __init_end = .; _end = .; + /* + * .discard.addressable of keep-syms-lto.o only keeps the linker lists + * alive during an LTO link. Drop it, and its fixups with it. + */ + /DISCARD/ : { + *(.discard*) + *keep-syms-lto.o(.fixup) + } + #if CONFIG_IS_ENABLED(SYS_MPC85XX_NO_RESETVEC) #if defined(CONFIG_SDCARD) && !defined(CFG_SYS_MMC_U_BOOT_OFFS) mmc_u_boot_offs = .; diff --git a/arch/powerpc/cpu/mpc85xx/u-boot.lds b/arch/powerpc/cpu/mpc85xx/u-boot.lds index bedd2d47472..4bb9b4ecfb2 100644 --- a/arch/powerpc/cpu/mpc85xx/u-boot.lds +++ b/arch/powerpc/cpu/mpc85xx/u-boot.lds @@ -49,7 +49,7 @@ SECTIONS KEEP(*(.got2)) KEEP(*(.got)) _FIXUP_TABLE_ = .; - KEEP(*(.fixup)) + KEEP(*(EXCLUDE_FILE(*keep-syms-lto.o) .fixup)) } __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1; __fixup_entries = (. - _FIXUP_TABLE_) >> 2; @@ -107,6 +107,15 @@ SECTIONS #endif #endif + /* + * .discard.addressable of keep-syms-lto.o only keeps the linker lists + * alive during an LTO link. Drop it, and its fixups with it. + */ + /DISCARD/ : { + *(.discard*) + *keep-syms-lto.o(.fixup) + } + __bss_start = .; .bss (NOLOAD) : { -- 2.54.0 (Apple Git-157)
