From: Simon Glass <simon.glass@canonical.com> The 64-bit PIE linker cannot handle 16-bit relocations, so start16.o and resetvec.o cannot be linked into the 64-bit u-boot binary. Override the assembler flags to build these objects as 32-bit (elf_i386) when targeting x86_64, and exclude them from head-y since they are handled separately by binman. Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- arch/x86/Makefile | 2 ++ arch/x86/cpu/Makefile | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 07e8df15afb..8abedd6e5e9 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -20,8 +20,10 @@ endif endif endif # EFI +ifndef CONFIG_$(PHASE_)X86_64 head-$(CONFIG_$(PHASE_)X86_16BIT_INIT) += arch/x86/cpu/start16.o head-$(CONFIG_$(PHASE_)X86_16BIT_INIT) += arch/x86/cpu/resetvec.o +endif libs-y += arch/x86/cpu/ libs-y += arch/x86/lib/ diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile index 82ae65f141a..71feca3bf29 100644 --- a/arch/x86/cpu/Makefile +++ b/arch/x86/cpu/Makefile @@ -26,6 +26,17 @@ endif extra-$(CONFIG_$(PHASE_)X86_16BIT_INIT) += resetvec.o start16.o +ifdef CONFIG_$(PHASE_)X86_64 +# The 16-bit startup code must be assembled as 32-bit since the 64-bit +# linker cannot handle 16-bit relocations in a PIE binary. These +# objects are not linked into the 64-bit u-boot; instead their sections +# are extracted to binary files for binman to place. +AFLAGS_REMOVE_start16.o := -march=core2 -m64 +AFLAGS_start16.o := -march=i386 -m32 +AFLAGS_REMOVE_resetvec.o := -march=core2 -m64 +AFLAGS_resetvec.o := -march=i386 -m32 +endif + obj-y += cpu.o ifndef CONFIG_TPL_BUILD obj-y += cpu_x86.o -- 2.43.0