build system x86: deprecate bootblock_lds and ldscripts variables

Instead of keeping this separate variable around, add linker scripts
to the $(class)-y source lists and let the build system sort things out.

This is inspired by the commit listed below, but rewritten to match
upstream, and split in smaller pieces to keep intent clear.

Change-Id: I4af687becf2971e009cb077debc902d2f0722cfb
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Based-On-Change-Id: I50af7dacf616e0f8ff4c43f4acc679089ad7022b
Based-On-Signed-off-by: Julius Werner <jwerner@chromium.org>
Based-On-Reviewed-on: https://chromium-review.googlesource.com/219170
Reviewed-on: http://review.coreboot.org/9289
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
This commit is contained in:
Patrick Georgi 2015-04-03 10:47:15 +02:00 committed by Patrick Georgi
parent d69839bdfd
commit 990e7c90f0
12 changed files with 38 additions and 30 deletions

View File

@ -225,7 +225,7 @@ alldirs:=$(sort $(abspath $(dir $(allobjs))))
# macro to define template macros that are used by use_template macro # macro to define template macros that are used by use_template macro
define create_cc_template define create_cc_template
# $1 obj class # $1 obj class
# $2 source suffix (c, S) # $2 source suffix (c, S, ld, ...)
# $3 additional compiler flags # $3 additional compiler flags
# $4 additional dependencies # $4 additional dependencies
ifn$(EMPTY)def $(1)-objs_$(2)_template ifn$(EMPTY)def $(1)-objs_$(2)_template

View File

@ -113,8 +113,8 @@ files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(sor
# reduce command line length by linking the objects of each # reduce command line length by linking the objects of each
# directory into an intermediate file # directory into an intermediate file
ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \ ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \
$(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(1)); $$(LD_ramstage) -o $$@ -r $$^ ) \ $(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(filter-out %.ld,$(1))); $$(LD_ramstage) -o $$@ -r $$^ ) \
$(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(call files-in-dir,$(d),$(1)),$(ramstage-objs)))) $(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(call files-in-dir,$(d),$(1)),$(filter-out %.ld,$(ramstage-objs)))))
romstage-generic-ccopts += -D__PRE_RAM__ romstage-generic-ccopts += -D__PRE_RAM__
ifeq ($(CONFIG_TRACE),y) ifeq ($(CONFIG_TRACE),y)
@ -139,6 +139,15 @@ romstage-c-deps:=$$(OPTION_TABLE_H)
verstage-c-deps:=$$(OPTION_TABLE_H) verstage-c-deps:=$$(OPTION_TABLE_H)
bootblock-c-deps:=$$(OPTION_TABLE_H) bootblock-c-deps:=$$(OPTION_TABLE_H)
# Add handler to copy linker scripts
define generic-objs_ld_template_gen
de$(EMPTY)fine $(1)-objs_ld_template
$$(call src-to-obj,$1,$$(1).ld): $$(1).ld
@printf " CP $$$$(subst $$$$(obj)/,,$$$$(@))\n"
cp $$$$< $$$$@
en$(EMPTY)def
endef
# Add handler to add no rules for manual files # Add handler to add no rules for manual files
define generic-objs_manual_template_gen define generic-objs_manual_template_gen
# do nothing # do nothing

View File

@ -43,7 +43,7 @@ bootblock-y += ../../lib/memcpy.c
bootblock-y += ../../lib/memmove.c bootblock-y += ../../lib/memmove.c
bootblock-y += ../../lib/memset.c bootblock-y += ../../lib/memset.c
bootblock_lds = $(src)/arch/mips/bootblock.ld bootblock-y += bootblock.ld
# Much of the assembly code is generated by the compiler, and may contain # Much of the assembly code is generated by the compiler, and may contain
# terms which the preprocessor will happily go on to replace. For example # terms which the preprocessor will happily go on to replace. For example

View File

@ -28,7 +28,7 @@ riscv_asm_flags =
################################################################################ ################################################################################
ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y) ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y)
bootblock_lds = $(src)/arch/riscv/bootblock.ld bootblock-y += bootblock.ld
bootblock-y = bootblock.S stages.c bootblock-y = bootblock.S stages.c
bootblock-y += boot.c bootblock-y += boot.c

View File

@ -73,15 +73,15 @@ endif
ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y) ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
bootblock_lds = $(src)/arch/x86/init/failover.ld bootblock-srcs += $(src)/arch/x86/init/failover.ld
bootblock_lds += $(src)/cpu/x86/16bit/entry16.ld bootblock-srcs += $(src)/cpu/x86/16bit/entry16.ld
bootblock_lds += $(src)/cpu/x86/16bit/reset16.ld bootblock-srcs += $(src)/cpu/x86/16bit/reset16.ld
bootblock_lds += $(src)/arch/x86/lib/id.ld bootblock-srcs += $(src)/arch/x86/lib/id.ld
bootblock_lds += $(chipset_bootblock_lds)
ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y)
bootblock_lds += $(src)/cpu/intel/fit/fit.ld bootblock-srcs += $(src)/cpu/intel/fit/fit.ld
endif endif
# TODO: Why can't this use the real bootblock-y += xxx.S mechanism instead?
bootblock_inc = $(src)/arch/x86/init/prologue.inc bootblock_inc = $(src)/arch/x86/init/prologue.inc
bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc
bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc
@ -103,9 +103,9 @@ ifeq ($(CONFIG_SSE),y)
bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOT_BLOCK__ bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOT_BLOCK__
endif endif
$(objgenerated)/bootblock.ld: $$(bootblock_lds) $(obj)/ldoptions $(objgenerated)/bootblock.ld: $(obj)/ldoptions $$(filter %.ld,$$(bootblock-srcs))
@printf " GEN $(subst $(obj)/,,$(@))\n" @printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@ printf '$(foreach ldscript,$(^),INCLUDE "$(ldscript)"\n)' > $@
$(objgenerated)/bootblock_inc.S: $$(bootblock_inc) $(objgenerated)/bootblock_inc.S: $$(bootblock_inc)
@printf " GEN $(subst $(obj)/,,$(@))\n" @printf " GEN $(subst $(obj)/,,$(@))\n"
@ -139,10 +139,9 @@ endif # CONFIG_ARCH_BOOTBLOCK_X86_32
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y) ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
crt0s = $(src)/arch/x86/init/prologue.inc crt0s = $(src)/arch/x86/init/prologue.inc
ldscripts = romstage-srcs += $(src)/arch/x86/init/romstage.ld
ldscripts += $(src)/arch/x86/init/romstage.ld
crt0s += $(src)/cpu/x86/32bit/entry32.inc crt0s += $(src)/cpu/x86/32bit/entry32.inc
ldscripts += $(src)/cpu/x86/32bit/entry32.ld romstage-srcs += $(src)/cpu/x86/32bit/entry32.ld
crt0s += $(src)/cpu/x86/fpu_enable.inc crt0s += $(src)/cpu/x86/fpu_enable.inc
ifeq ($(CONFIG_SSE),y) ifeq ($(CONFIG_SSE),y)
@ -202,7 +201,7 @@ romstage-libs ?=
$(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs) $(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs)
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --start-group $(romstage-objs) $(romstage-libs) $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage_null.ld $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage_null.ld
$(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders && \ $(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders && \
$(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \ $(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \
echo "Forbidden global variables in romstage:"; \ echo "Forbidden global variables in romstage:"; \
@ -211,13 +210,13 @@ $(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.
$(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(romstage-libs) $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(romstage-libs)
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --start-group $(romstage-objs) $(romstage-libs) $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage.ld $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage.ld
$(objgenerated)/romstage_null.ld: $$(ldscripts) $(obj)/ldoptions $(objgenerated)/romstage_null.ld: $(obj)/ldoptions $$(filter %.ld,$$(romstage-srcs))
@printf " GEN $(subst $(obj)/,,$(@))\n" @printf " GEN $(subst $(obj)/,,$(@))\n"
rm -f $@ rm -f $@
printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp
printf '$(foreach ldscript,ldoptions $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp printf '$(foreach ldscript,$(^),INCLUDE "$(ldscript)"\n)' >> $@.tmp
mv $@.tmp $@ mv $@.tmp $@
$(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt $(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt
@ -278,7 +277,7 @@ endif
ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),) ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),)
ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c
endif endif
endif endif # CONFIG_GENERATE_ACPI_TABLES
ifeq ($(CONFIG_HAVE_SMI_HANDLER),y) ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),) ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),)
smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c
@ -308,7 +307,7 @@ endif
$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs) $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(LD_ramstage) -m elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --start-group $(ramstage-objs) $(ramstage-libs) $(COMPILER_RT_ramstage) --end-group $(LD_ramstage) -m elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) $(COMPILER_RT_ramstage) --end-group
endif # CONFIG_ARCH_RAMSTAGE_X86_32 endif # CONFIG_ARCH_RAMSTAGE_X86_32

View File

@ -25,7 +25,7 @@ subdirs-y += ../../x86/smm
chipset_bootblock_inc += $(src)/cpu/dmp/vortex86ex/biosdata.inc chipset_bootblock_inc += $(src)/cpu/dmp/vortex86ex/biosdata.inc
chipset_bootblock_inc += $(src)/cpu/dmp/vortex86ex/biosdata_ex.inc chipset_bootblock_inc += $(src)/cpu/dmp/vortex86ex/biosdata_ex.inc
chipset_bootblock_lds += $(src)/cpu/dmp/vortex86ex/biosdata.ld bootblock-y += biosdata.ld
chipset_bootblock_lds += $(src)/cpu/dmp/vortex86ex/biosdata_ex.ld bootblock-y += biosdata_ex.ld
ROMCCFLAGS := -mcpu=i386 -O2 ROMCCFLAGS := -mcpu=i386 -O2

View File

@ -24,4 +24,4 @@ ramstage-y += lpc.c
ramstage-y += ide.c ramstage-y += ide.c
chipset_bootblock_inc += $(src)/northbridge/via/vx800/romstrap.inc chipset_bootblock_inc += $(src)/northbridge/via/vx800/romstrap.inc
chipset_bootblock_lds += $(src)/northbridge/via/vx800/romstrap.ld bootblock-y += romstrap.ld

View File

@ -45,4 +45,4 @@ ramstage-y += ./../../../drivers/pc80/vga/vga_io.c
chipset_bootblock_inc += $(src)/northbridge/via/vx900/romstrap.inc chipset_bootblock_inc += $(src)/northbridge/via/vx900/romstrap.inc
chipset_bootblock_lds += $(src)/northbridge/via/vx900/romstrap.ld bootblock-y += romstrap.ld

View File

@ -20,4 +20,4 @@ ramstage-$(CONFIG_USBDEBUG) += enable_usbdebug.c
romstage-y += early_smbus.c romstage-y += early_smbus.c
chipset_bootblock_inc += $(src)/southbridge/nvidia/ck804/romstrap.inc chipset_bootblock_inc += $(src)/southbridge/nvidia/ck804/romstrap.inc
chipset_bootblock_lds += $(src)/southbridge/nvidia/ck804/romstrap.ld bootblock-y += romstrap.ld

View File

@ -19,4 +19,4 @@ romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += enable_usbdebug.c
ramstage-$(CONFIG_USBDEBUG) += enable_usbdebug.c ramstage-$(CONFIG_USBDEBUG) += enable_usbdebug.c
chipset_bootblock_inc += $(src)/southbridge/nvidia/mcp55/romstrap.inc chipset_bootblock_inc += $(src)/southbridge/nvidia/mcp55/romstrap.inc
chipset_bootblock_lds += $(src)/southbridge/nvidia/mcp55/romstrap.ld bootblock-y += romstrap.ld

View File

@ -14,4 +14,4 @@ romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += enable_usbdebug.c
ramstage-$(CONFIG_USBDEBUG) += enable_usbdebug.c ramstage-$(CONFIG_USBDEBUG) += enable_usbdebug.c
chipset_bootblock_inc += $(src)/southbridge/sis/sis966/romstrap.inc chipset_bootblock_inc += $(src)/southbridge/sis/sis966/romstrap.inc
chipset_bootblock_lds += $(src)/southbridge/sis/sis966/romstrap.ld bootblock-y += romstrap.ld

View File

@ -9,4 +9,4 @@ ramstage-y += error.c
ramstage-y += chrome.c ramstage-y += chrome.c
chipset_bootblock_inc += $(src)/southbridge/via/k8t890/romstrap.inc chipset_bootblock_inc += $(src)/southbridge/via/k8t890/romstrap.inc
chipset_bootblock_lds += $(src)/southbridge/via/k8t890/romstrap.ld bootblock-y += romstrap.ld