summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2024-08-20 23:29:20 +0200
committerFelix Held <felix-coreboot@felixheld.de>2024-08-22 13:56:52 +0000
commitcb26ed489c67b58bc981a57d032969355850cbd6 (patch)
treeb707e6adf8c2e85b4ab2b3008ba5746b9ecb0496 /src
parent89869144bfe75efb3d224fb6e5a5e95700f7b0f9 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/Makefile.mk33
-rw-r--r--src/arch/x86/include/arch/header.ld8
2 files changed, 14 insertions, 27 deletions
diff --git a/src/arch/x86/Makefile.mk b/src/arch/x86/Makefile.mk
index 2832ac36f5..0a0d9c320b 100644
--- a/src/arch/x86/Makefile.mk
+++ b/src/arch/x86/Makefile.mk
@@ -56,11 +56,10 @@ endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA
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 @@ bootblock-y += car.ld
$(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-y += car.ld
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-y += car.ld
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 @@ postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
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 @@ endif
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 2ee021226c..d12c8039f9 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;