MIPS: boot: compressed: fix the vmlinuz link with ld.lld
PATCH 1/1 MIPS: boot: compressed: fix the vmlinuz link with ld.lld
ld.lld cannot link a 32-bit executable at a sign-extended address. With a sign-extended ZBOOT_LOAD_ADDRESS, such as the BCM47XX default of 0xffffffff80400000, the vmlinuz link fails:
ld.lld: error: section .text at 0xffffffff80400000 of size 0x35a4 exceeds available address space
arch/mips/Makefile already avoids this for vmlinux by linking at LINKER_LOAD_ADDRESS, which drops the upper 32 bits on 32-bit kernels. Do the same for vmlinuz. The address computed by calc_vmlinuz_load_addr is already derived from LINKER_LOAD_ADDRESS, which is why only an explicit ZBOOT_LOAD_ADDRESS is affected.
--- arch/mips/boot/compressed/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/mips/boot/compressed/Makefile +9 -1
@@ -96,12 +96,20 @@ VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ endif UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) +# Like LINKER_LOAD_ADDRESS in arch/mips/Makefile: ld.lld cannot link a +# 32-bit executable at a sign-extended address, so drop the upper 32 bits. +ifdef CONFIG_64BIT +VMLINUZ_LINK_ADDRESS = $(VMLINUZ_LOAD_ADDRESS) +else +VMLINUZ_LINK_ADDRESS = $(subst 0xffffffff,0x,$(VMLINUZ_LOAD_ADDRESS)) +endif + vmlinuzobjs-y += $(obj)/piggy.o targets += ../../../../vmlinuz quiet_cmd_zld = LD $@ - cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ + cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LINK_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ quiet_cmd_strip = STRIP $@ cmd_strip = $(STRIP) -s $@
Signature · 1 line
2.56.0
Quoted 47 lines · Rosen Penev
ld.lld cannot link a 32-bit executable at a sign-extended address. With a sign-extended
ZBOOT_LOAD_ADDRESS, such as the BCM47XX default of0xffffffff80400000, the vmlinuz link fails:ld.lld: error: section .text at
0xffffffff80400000of size0x35a4exceeds available address space
arch/mips/Makefilealready avoids this for vmlinux by linking atLINKER_LOAD_ADDRESS, which drops the upper 32 bits on 32-bit kernels. Do the same for vmlinuz. The address computed bycalc_vmlinuz_load_addris already derived fromLINKER_LOAD_ADDRESS, which is why only an explicitZBOOT_LOAD_ADDRESSis affected.Assisted-by LLMSigned-off-by Rosen Penev <[email protected]>--- arch/mips/boot/compressed/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)arch/mips/boot/compressed/Makefile +9
-1@@ -96,12 +96,20 @@ VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ endif UIMAGE_LOADADDR = $(VMLINUZ_LOAD_ADDRESS) +# Like LINKER_LOAD_ADDRESS in arch/mips/Makefile: ld.lld cannot link a +# 32-bit executable at a sign-extended address, so drop the upper 32 bits. +ifdef CONFIG_64BIT +VMLINUZ_LINK_ADDRESS = $(VMLINUZ_LOAD_ADDRESS) +else +VMLINUZ_LINK_ADDRESS = $(subst 0xffffffff,0x,$(VMLINUZ_LOAD_ADDRESS)) +endif + vmlinuzobjs-y += $(obj)/piggy.o targets += ../../../../vmlinuz quiet_cmd_zld = LD $@ - cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ + cmd_zld = $(LD) $(KBUILD_LDFLAGS) -Ttext $(VMLINUZ_LINK_ADDRESS) -T $< $(vmlinuzobjs-y) -o $@ quiet_cmd_strip = STRIP $@ cmd_strip = $(STRIP) -s $@Signature · 1 line
2.56.0
applied to mips-fixes
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]