Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9303
-gerrit
commit 01140647081035ff6748b39e01cf0d7ee4f71cb2 Author: Patrick Georgi pgeorgi@chromium.org Date: Sat Apr 4 15:50:20 2015 +0200
build system: run linker scripts through the preprocessor
This allows combining and simplifying linker scripts.
This is inspired by the commit listed below, but rewritten to match upstream, and split in smaller pieces to keep intent clear.
Change-Id: Ie5c11bd8495a399561cefde2f3e8dd300f4feb98 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 --- Makefile | 2 ++ Makefile.inc | 7 ++++--- src/arch/x86/Makefile.inc | 12 ++++++------ src/arch/x86/init/romstage.ld | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile index 97a14a8..395910f 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,8 @@ HOSTCXX = g++ HOSTCFLAGS := -g HOSTCXXFLAGS := -g
+PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I . + DOXYGEN := doxygen DOXYGEN_OUTPUT_DIR := doxygen
diff --git a/Makefile.inc b/Makefile.inc index 92f2013..ce943a6 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -112,7 +112,7 @@ files-in-dir=$(filter-out $(call dir-wildcards,$(call filter-out-dirs,$(1),$(sor ####################################################################### # reduce command line length by linking the objects of each # directory into an intermediate file -ramstage-postprocess=$(foreach d,$(sort $(dir $(1))), \ +ramstage-postprocess=$(foreach d,$(sort $(dir $(filter-out %.ld,$(1)))), \ $(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)),$(filter-out %.ld,$(ramstage-objs)))))
@@ -142,9 +142,10 @@ 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 +$$(call src-to-obj,$1,$$(1).ld): $$(1).ld $(obj)/config.h @printf " CP $$$$(subst $$$$(obj)/,,$$$$(@))\n" - cp $$$$< $$$$@ + $$(CC_$(1)) $(PREPROCESS_ONLY) -CC -include $(obj)/config.h $$$$< > $$$$@.tmp + mv $$$$@.tmp $$$$@ en$(EMPTY)def endef
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index e4af06d..8ab19d7 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -103,9 +103,9 @@ ifeq ($(CONFIG_SSE),y) bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ endif
-$(objgenerated)/bootblock.ld: $(obj)/ldoptions $$(filter %.ld,$$(bootblock-srcs)) +$(objgenerated)/bootblock.ld: $(obj)/ldoptions $(obj)/config.h $$(filter %.ld,$$(bootblock-srcs)) @printf " GEN $(subst $(obj)/,,$(@))\n" - printf '$(foreach ldscript,$(^),INCLUDE "$(ldscript)"\n)' > $@ + printf '$(foreach ldscript,$(^),#include "$(ldscript)"\n)' | $(CC_bootblock) $(PREPROCESS_ONLY) -CC - > $@
$(objgenerated)/bootblock_inc.S: $$(bootblock_inc) @printf " GEN $(subst $(obj)/,,$(@))\n" @@ -212,18 +212,18 @@ $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(roms @printf " LINK $(subst $(obj)/,,$(@))\n" $(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: $(obj)/ldoptions $$(filter %.ld,$$(romstage-srcs)) +$(objgenerated)/romstage_null.ld: $(obj)/ldoptions $(obj)/config.h $$(filter %.ld,$$(romstage-srcs)) @printf " GEN $(subst $(obj)/,,$(@))\n" rm -f $@ printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp - printf '$(foreach ldscript,$(^),INCLUDE "$(ldscript)"\n)' >> $@.tmp - mv $@.tmp $@ + printf '$(foreach ldscript,$(^),#include "$(ldscript)"\n)' >> $@.tmp + $(CC_romstage) $(PREPROCESS_ONLY) -CC $@.tmp > $@
$(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt @printf " GEN $(subst $(obj)/,,$(@))\n" rm -f $@ sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(objcbfs)/base_xip.txt > $@.tmp - sed -e '/ROMSTAGE_BASE/d' $(objgenerated)/romstage_null.ld >> $@.tmp + sed -e '/^ROMSTAGE_BASE/d' $(objgenerated)/romstage_null.ld >> $@.tmp mv $@.tmp $@
$(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld index 95b9571..40ed354 100644 --- a/src/arch/x86/init/romstage.ld +++ b/src/arch/x86/init/romstage.ld @@ -75,8 +75,8 @@ SECTIONS
. = 0xffffff00; .illegal_globals . : { - *(EXCLUDE_FILE (*/libagesa.*.a: */buildOpts.romstage.o */agesawrapper.romstage.o */vendorcode/amd/agesa/* */vendorcode/amd/cimx/*) .data) - *(EXCLUDE_FILE (*/libagesa.*.a: */buildOpts.romstage.o */agesawrapper.romstage.o */vendorcode/amd/agesa/* */vendorcode/amd/cimx/*) .data.*) + *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data) + *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/buildOpts.romstage.o" "*/agesawrapper.romstage.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*) *(.bss) *(.bss.*) *(.sbss)