arch/x86: Build all stages using the same function

There is no difference in how early and later stages are linked so
rename the same function.

Change-Id: I458c7c6822b310847e7ab32519fd8d66a90f88f7
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83562
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
This commit is contained in:
Arthur Heymans 2024-07-18 21:53:23 +02:00 committed by Felix Held
parent 47254261ba
commit 9b99eb5cf8

View File

@ -54,7 +54,7 @@ endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA
# common support for early assembly includes
###############################################################################
define early_x86_stage
define x86_stage
# $1 stage name
# $2 oformat
@ -95,9 +95,9 @@ bootblock-y += car.ld
$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
$(eval $(call early_x86_stage,bootblock,elf32-i386))
$(eval $(call x86_stage,bootblock,elf32-i386))
else
$(eval $(call early_x86_stage,bootblock,elf64-x86-64))
$(eval $(call x86_stage,bootblock,elf64-x86-64))
endif
ifeq ($(CONFIG_BOOTBLOCK_IN_CBFS),y)
@ -148,9 +148,9 @@ verstage-y += car.ld
verstage-libs ?=
ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
$(eval $(call early_x86_stage,verstage,elf32-i386))
$(eval $(call x86_stage,verstage,elf32-i386))
else
$(eval $(call early_x86_stage,verstage,elf64-x86-64))
$(eval $(call x86_stage,verstage,elf64-x86-64))
endif
endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
@ -187,9 +187,9 @@ romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c)
romstage-libs ?=
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
$(eval $(call early_x86_stage,romstage,elf32-i386))
$(eval $(call x86_stage,romstage,elf32-i386))
else
$(eval $(call early_x86_stage,romstage,elf64-x86-64))
$(eval $(call x86_stage,romstage,elf64-x86-64))
endif
# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
@ -228,9 +228,11 @@ postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
$(objcbfs)/postcar.debug: $$(postcar-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,$(CONFIG_MEMLAYOUT_LD_FILE))
ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y)
$(eval $(call x86_stage,postcar,elf32-i386))
else
$(eval $(call x86_stage,postcar,elf64-x86-64))
endif
$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
cp $< $@
@ -309,14 +311,15 @@ endif
ramstage-libs ?=
# The rmodule_link definition creates an elf file with .rmod extension.
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
$(eval $(call x86_stage,ramstage,elf32-i386))
else
$(eval $(call x86_stage,ramstage,elf64-x86-64))
endif
$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
cp $< $@
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(COMPILER_RT_ramstage) $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE)) $$(ramstage-libs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_ramstage) --end-group -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
smm-$(CONFIG_DEBUG_HW_BREAKPOINTS_IN_ALL_STAGES) += breakpoint.c