Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/83999?usp=email )
Change subject: arch/x86: Move oformat definition into the linker file ......................................................................
arch/x86: Move oformat definition into the linker file
This removes the boilerplate --oformat out of the makefile.mk
Change-Id: Ib78934fff4a31c4375da2038efca5027b813b07b Signed-off-by: Arthur Heymans arthur@aheymans.xyz Reviewed-on: https://review.coreboot.org/c/coreboot/+/83999 Reviewed-by: Elyes Haouas ehaouas@noos.fr Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Nico Huber nico.h@gmx.de --- M src/arch/x86/Makefile.mk M src/arch/x86/include/arch/header.ld 2 files changed, 14 insertions(+), 27 deletions(-)
Approvals: Nico Huber: Looks good to me, approved Elyes Haouas: Looks good to me, but someone else must approve build bot (Jenkins): Verified
diff --git a/src/arch/x86/Makefile.mk b/src/arch/x86/Makefile.mk index 2832ac3..0a0d9c3 100644 --- a/src/arch/x86/Makefile.mk +++ b/src/arch/x86/Makefile.mk @@ -56,11 +56,10 @@
define x86_stage # $1 stage name -# $2 oformat
$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs) @printf " LINK $$(subst $$(obj)/,,$$(@))\n" - $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(CONFIG_MEMLAYOUT_LD_FILE)) --oformat $(2) + $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(CONFIG_MEMLAYOUT_LD_FILE)) endef
############################################################################### @@ -91,11 +90,7 @@
$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
-ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) -$(eval $(call x86_stage,bootblock,elf32-i386)) -else -$(eval $(call x86_stage,bootblock,elf64-x86-64)) -endif +$(eval $(call x86_stage,bootblock))
ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS),y) add_bootblock = \ @@ -144,11 +139,7 @@
verstage-libs ?=
-ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y) -$(eval $(call x86_stage,verstage,elf32-i386)) -else -$(eval $(call x86_stage,verstage,elf64-x86-64)) -endif +$(eval $(call x86_stage,verstage))
endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
@@ -183,11 +174,7 @@ romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c) romstage-libs ?=
-ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) -$(eval $(call x86_stage,romstage,elf32-i386)) -else -$(eval $(call x86_stage,romstage,elf64-x86-64)) -endif +$(eval $(call x86_stage,romstage))
# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428 romstage-S-ccopts += -g0 @@ -225,11 +212,7 @@
LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
-ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y) -$(eval $(call x86_stage,postcar,elf32-i386)) -else -$(eval $(call x86_stage,postcar,elf64-x86-64)) -endif +$(eval $(call x86_stage,postcar))
$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod cp $< $@ @@ -308,11 +291,7 @@
ramstage-libs ?=
-ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) -$(eval $(call x86_stage,ramstage,elf32-i386)) -else -$(eval $(call x86_stage,ramstage,elf64-x86-64)) -endif +$(eval $(call x86_stage,ramstage))
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod cp $< $@ diff --git a/src/arch/x86/include/arch/header.ld b/src/arch/x86/include/arch/header.ld index 2ee0212..d12c803 100644 --- a/src/arch/x86/include/arch/header.ld +++ b/src/arch/x86/include/arch/header.ld @@ -1,5 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#if ENV_X86_64 +OUTPUT_FORMAT(elf64-x86-64) +OUTPUT_ARCH(i386:x86-64) +#else +OUTPUT_FORMAT(elf32-i386) +OUTPUT_ARCH(i386) +#endif + PHDRS { to_load PT_LOAD;