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
Reviewed-on: http://review.coreboot.org/9303
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Patrick Georgi 2015-04-04 15:50:20 +02:00 committed by Stefan Reinauer
parent d126a749b8
commit 828e0e86f3
24 changed files with 72 additions and 78 deletions

View File

@ -79,6 +79,8 @@ HOSTCXX = g++
HOSTCFLAGS := -g HOSTCFLAGS := -g
HOSTCXXFLAGS := -g HOSTCXXFLAGS := -g
PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .
DOXYGEN := doxygen DOXYGEN := doxygen
DOXYGEN_OUTPUT_DIR := doxygen DOXYGEN_OUTPUT_DIR := doxygen

View File

@ -112,9 +112,9 @@ 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 $(filter-out %.ld,$(1)))), \
$(eval $(d)ramstage.o: $(call files-in-dir,$(d),$(filter-out %.ld,$(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)),$(filter-out %.ld,$(ramstage-objs))))) $(eval ramstage-objs:=$(d)ramstage.o $(filter-out $(filter-out %.ld, $(call files-in-dir,$(d),$(1))),$(ramstage-objs))))
romstage-generic-ccopts += -D__PRE_RAM__ romstage-generic-ccopts += -D__PRE_RAM__
ifeq ($(CONFIG_TRACE),y) ifeq ($(CONFIG_TRACE),y)
@ -142,9 +142,10 @@ bootblock-c-deps:=$$(OPTION_TABLE_H)
# Add handler to copy linker scripts # Add handler to copy linker scripts
define generic-objs_ld_template_gen define generic-objs_ld_template_gen
de$(EMPTY)fine $(1)-objs_ld_template 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" @printf " CP $$$$(subst $$$$(obj)/,,$$$$(@))\n"
cp $$$$< $$$$@ $$(CC_$(1)) $$(CPPFLAGS_$(1)) $($(1)-ld-ccopts) $(PREPROCESS_ONLY) -include $(obj)/config.h $$$$< > $$$$@.tmp
mv $$$$@.tmp $$$$@
en$(EMPTY)def en$(EMPTY)def
endef endef
@ -259,9 +260,6 @@ $(obj)/build.h: .xcompile
util/genbuild_h/genbuild_h.sh > $(obj)/build.ht util/genbuild_h/genbuild_h.sh > $(obj)/build.ht
mv $(obj)/build.ht $(obj)/build.h mv $(obj)/build.ht $(obj)/build.h
$(obj)/ldoptions: $(obj)/config.h
awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print "PROVIDE_HIDDEN(" $$2 " = " $$3 ");";}' $< > $@
build-dirs: build-dirs:
mkdir -p $(objcbfs) $(objgenerated) mkdir -p $(objcbfs) $(objgenerated)

View File

@ -63,9 +63,11 @@ bootblock-y += memmove.S
bootblock-y += div0.c bootblock-y += div0.c
bootblock-y += clock.c bootblock-y += clock.c
$(objcbfs)/bootblock.debug: $(src)/arch/arm/bootblock.ld $(obj)/ldoptions $$(bootblock-objs) $$(VERSTAGE_LIB) bootblock-y += bootblock.ld
$(objcbfs)/bootblock.debug: $(obj)/arch/arm/bootblock.bootblock.ld $$(bootblock-objs) $$(VERSTAGE_LIB)
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_bootblock) --gc-sections -static -o $@ -L$(obj) --start-group $(bootblock-objs) --end-group -T $(src)/arch/arm/bootblock.ld $(LD_bootblock) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/arm/bootblock.bootblock.ld --start-group $(bootblock-objs) --end-group
endif # CONFIG_ARCH_BOOTBLOCK_ARM endif # CONFIG_ARCH_BOOTBLOCK_ARM
@ -73,9 +75,9 @@ endif # CONFIG_ARCH_BOOTBLOCK_ARM
# verification stage # verification stage
############################################################################### ###############################################################################
$(objcbfs)/verstage.debug: $$(verstage-objs) $(src)/arch/arm/verstage.ld $(obj)/ldoptions $$(VB2_LIB) $(objcbfs)/verstage.debug: $$(verstage-objs) $(obj)/arch/arm/verstage.verstage.ld $$(VB2_LIB)
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_verstage) --gc-sections -static -o $@ -L$(obj) --start-group $(verstage-objs) --end-group -T $(src)/arch/arm/verstage.ld $(LD_verstage) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/arm/verstage.verstage.ld --start-group $(verstage-objs) --end-group
verstage-y += div0.c verstage-y += div0.c
verstage-y += eabi_compat.c verstage-y += eabi_compat.c
@ -84,6 +86,8 @@ verstage-y += memcpy.S
verstage-y += memmove.S verstage-y += memmove.S
verstage-y += stages.c verstage-y += stages.c
verstage-y += verstage.ld
############################################################################### ###############################################################################
# romstage # romstage
############################################################################### ###############################################################################
@ -103,11 +107,13 @@ rmodules_arm-y += memcpy.S
rmodules_arm-y += memmove.S rmodules_arm-y += memmove.S
rmodules_arm-y += eabi_compat.c rmodules_arm-y += eabi_compat.c
romstage-y += romstage.ld
VBOOT_STUB_DEPS += $(obj)/arch/arm/eabi_compat.rmodules_arm.o VBOOT_STUB_DEPS += $(obj)/arch/arm/eabi_compat.rmodules_arm.o
$(objcbfs)/romstage.debug: $$(romstage-objs) $(src)/arch/arm/romstage.ld $(obj)/ldoptions $(objcbfs)/romstage.debug: $$(romstage-objs) $(obj)/arch/arm/romstage.romstage.ld
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_romstage) -nostdlib --gc-sections -static -o $@ -L$(obj) --start-group $(romstage-objs) --end-group -T $(src)/arch/arm/romstage.ld $(LD_romstage) -nostdlib --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/arm/romstage.romstage.ld --start-group $(romstage-objs) --end-group
endif # CONFIG_ARCH_ROMSTAGE_ARM endif # CONFIG_ARCH_ROMSTAGE_ARM
@ -133,9 +139,11 @@ rmodules_arm-y += memmove.S
rmodules_arm-y += eabi_compat.c rmodules_arm-y += eabi_compat.c
ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(src)/arch/arm/ramstage.ld $(obj)/ldoptions ramstage-y += ramstage.ld
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(obj)/arch/arm/ramstage.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(LD_ramstage) -nostdlib --gc-sections -o $@ -L$(obj) --start-group $(ramstage-objs) --end-group -T $(src)/arch/arm/ramstage.ld $(LD_ramstage) -nostdlib --gc-sections -o $@ -L$(obj) -T $(obj)/arch/arm/ramstage.ramstage.ld --start-group $(ramstage-objs) --end-group
$(objgenerated)/ramstage.o: $(stages_o) $$(ramstage-objs) $(objgenerated)/ramstage.o: $(stages_o) $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"

View File

@ -21,7 +21,6 @@
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
INCLUDE ldoptions
PHDRS PHDRS
{ {
@ -29,7 +28,6 @@ PHDRS
} }
ENTRY(_start) ENTRY(_start)
TARGET(binary)
SECTIONS SECTIONS
{ {
. = CONFIG_BOOTBLOCK_BASE; . = CONFIG_BOOTBLOCK_BASE;

View File

@ -19,9 +19,6 @@
* 2005.12 yhlu add ramstage cross the vga font buffer handling * 2005.12 yhlu add ramstage cross the vga font buffer handling
*/ */
/* We use ELF as output format. So that we can debug the code in some form. */
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)
PHDRS PHDRS

View File

@ -22,7 +22,6 @@
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)

View File

@ -10,7 +10,6 @@
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
INCLUDE ldoptions
PHDRS PHDRS
{ {

View File

@ -68,11 +68,13 @@ bootblock-y += ../../lib/memset.c
bootblock-y += ../../lib/memcpy.c bootblock-y += ../../lib/memcpy.c
bootblock-y += ../../lib/memmove.c bootblock-y += ../../lib/memmove.c
bootblock-y += bootblock.ld
# Build the bootblock # Build the bootblock
$(objcbfs)/bootblock.debug: $(src)/arch/arm64/bootblock.ld $(obj)/ldoptions $$(bootblock-objs) $(obj)/config.h $(objcbfs)/bootblock.debug: $(obj)/arch/arm64/bootblock.bootblock.ld $$(bootblock-objs) $(obj)/config.h
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_bootblock) --gc-sections -static -o $@ -L$(obj) --start-group $(bootblock-objs) --end-group -T $(src)/arch/arm64/bootblock.ld $(LD_bootblock) --gc-sections -static -o $@ -L$(obj) --start-group $(bootblock-objs) --end-group -T $(obj)/arch/arm64/bootblock.bootblock.ld
endif # CONFIG_ARCH_BOOTBLOCK_ARM64 endif # CONFIG_ARCH_BOOTBLOCK_ARM64
@ -94,6 +96,8 @@ romstage-y += ../../lib/memmove.c
romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
romstage-y += transition.c transition_asm.S romstage-y += transition.c transition_asm.S
romstage-y += romstage.ld
rmodules_arm64-y += ../../lib/memset.c rmodules_arm64-y += ../../lib/memset.c
rmodules_arm64-y += ../../lib/memcpy.c rmodules_arm64-y += ../../lib/memcpy.c
rmodules_arm64-y += ../../lib/memmove.c rmodules_arm64-y += ../../lib/memmove.c
@ -102,9 +106,9 @@ rmodules_arm64-y += eabi_compat.c
# Build the romstage # Build the romstage
VBOOT_STUB_DEPS += $(obj)/arch/arm/eabi_compat.rmodules_arm64.o VBOOT_STUB_DEPS += $(obj)/arch/arm/eabi_compat.rmodules_arm64.o
$(objcbfs)/romstage.debug: $$(romstage-objs) $(src)/arch/arm64/romstage.ld $(obj)/ldoptions $(objcbfs)/romstage.debug: $$(romstage-objs) $(obj)/arch/arm64/romstage.romstage.ld
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_romstage) -nostdlib --gc-sections -static -o $@ -L$(obj) --start-group $(romstage-objs) --end-group -T $(src)/arch/arm64/romstage.ld $(LD_romstage) -nostdlib --gc-sections -static -o $@ -L$(obj) --start-group $(romstage-objs) --end-group -T $(obj)/arch/arm64/romstage.romstage.ld
endif # CONFIG_ARCH_ROMSTAGE_ARM64 endif # CONFIG_ARCH_ROMSTAGE_ARM64
@ -140,14 +144,15 @@ secmon-$(CONFIG_ARCH_USE_SECURE_MONITOR) += ../../lib/memcmp.c
secmon-$(CONFIG_ARCH_USE_SECURE_MONITOR) += ../../lib/memcpy.c secmon-$(CONFIG_ARCH_USE_SECURE_MONITOR) += ../../lib/memcpy.c
ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
ramstage-y += ramstage.ld
ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
# Build the ramstage # Build the ramstage
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(src)/arch/arm64/ramstage.ld $(obj)/ldoptions $(objcbfs)/ramstage.debug: $$(ramstage-objs) $(obj)/arch/arm64/ramstage.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(LD_ramstage) -nostdlib --gc-sections -o $@ -L$(obj) --start-group $(ramstage-objs) --end-group -T $(src)/arch/arm64/ramstage.ld $(LD_ramstage) -nostdlib --gc-sections -o $@ -L$(obj) --start-group $(ramstage-objs) --end-group -T $(obj)/arch/arm64/ramstage.ramstage.ld
$(objgenerated)/ramstage.o: $(stages_o) $$(ramstage-objs) $(objgenerated)/ramstage.o: $(stages_o) $$(ramstage-objs)
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"

View File

@ -21,7 +21,6 @@
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64") OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
OUTPUT_ARCH(aarch64) OUTPUT_ARCH(aarch64)
INCLUDE ldoptions
PHDRS PHDRS
{ {

View File

@ -20,9 +20,6 @@
* 2005.12 yhlu add ramstage cross the vga font buffer handling * 2005.12 yhlu add ramstage cross the vga font buffer handling
*/ */
/* We use ELF as output format. So that we can debug the code in some form. */
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)
PHDRS PHDRS

View File

@ -22,7 +22,6 @@
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64") OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
OUTPUT_ARCH(aarch64) OUTPUT_ARCH(aarch64)
INCLUDE ldoptions
PHDRS PHDRS
{ {

View File

@ -51,9 +51,9 @@ bootblock-y += bootblock.ld
# prevent that. # prevent that.
bootblock-S-ccopts += -undef bootblock-S-ccopts += -undef
$(objcbfs)/bootblock.debug: $(src)/arch/mips/bootblock.ld $$(bootblock-objs) $(obj)/config.h $(obj)/ldoptions $(objcbfs)/bootblock.debug: $(obj)/arch/mips/bootblock.bootblock.ld $$(bootblock-objs) $(obj)/config.h
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_bootblock) --gc-sections -static -o $@ -L$(obj) -T $(src)/arch/mips/bootblock.ld --start-group $(bootblock-objs) --end-group $(LD_bootblock) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/mips/bootblock.bootblock.ld --start-group $(bootblock-objs) --end-group
endif # CONFIG_ARCH_BOOTBLOCK_MIPS endif # CONFIG_ARCH_BOOTBLOCK_MIPS
@ -71,9 +71,11 @@ romstage-y += ../../lib/memcpy.c
romstage-y += ../../lib/memmove.c romstage-y += ../../lib/memmove.c
romstage-y += ../../lib/memset.c romstage-y += ../../lib/memset.c
$(objcbfs)/romstage.debug: $$(romstage-objs) $(src)/arch/mips/romstage.ld $(obj)/ldoptions romstage-y += romstage.ld
$(objcbfs)/romstage.debug: $$(romstage-objs) $(obj)/arch/mips/romstage.romstage.ld
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(LD_romstage) --gc-sections -static -o $@ -L$(obj) -T $(src)/arch/mips/romstage.ld --start-group $(romstage-objs) --end-group $(LD_romstage) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/mips/romstage.romstage.ld --start-group $(romstage-objs) --end-group
endif # CONFIG_ARCH_ROMSTAGE_MIPS endif # CONFIG_ARCH_ROMSTAGE_MIPS
@ -93,8 +95,10 @@ ramstage-y += ../../lib/memmove.c
ramstage-y += ../../lib/memset.c ramstage-y += ../../lib/memset.c
ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c) ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(src)/arch/mips/ramstage.ld $(obj)/ldoptions ramstage-y += ramstage.ld
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(obj)/arch/mips/ramstage.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(LD_ramstage) --gc-sections -static -o $@ -L$(obj) -T $(src)/arch/mips/ramstage.ld --start-group $(ramstage-objs) --end-group $(LD_ramstage) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/mips/ramstage.ramstage.ld --start-group $(ramstage-objs) --end-group
endif # CONFIG_ARCH_RAMSTAGE_MIPS endif # CONFIG_ARCH_RAMSTAGE_MIPS

View File

@ -20,7 +20,6 @@
*/ */
OUTPUT_ARCH(mips) OUTPUT_ARCH(mips)
INCLUDE ldoptions
ENTRY(_start) ENTRY(_start)

View File

@ -24,7 +24,6 @@
*/ */
OUTPUT_ARCH(mips) OUTPUT_ARCH(mips)
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)

View File

@ -20,7 +20,6 @@
*/ */
OUTPUT_ARCH(mips) OUTPUT_ARCH(mips)
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)

View File

@ -28,8 +28,6 @@ riscv_asm_flags =
################################################################################ ################################################################################
ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y) ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y)
bootblock-y += bootblock.ld
bootblock-y = bootblock.S stages.c bootblock-y = bootblock.S stages.c
bootblock-y += boot.c bootblock-y += boot.c
bootblock-y += rom_media.c bootblock-y += rom_media.c
@ -40,11 +38,13 @@ bootblock-y += \
$(top)/src/lib/memmove.c \ $(top)/src/lib/memmove.c \
$(top)/src/lib/memset.c $(top)/src/lib/memset.c
$(objcbfs)/bootblock.debug: $(src)/arch/riscv/bootblock.ld $(obj)/ldoptions $$(bootblock-objs) bootblock-y += bootblock.ld
$(objcbfs)/bootblock.debug: $(obj)/arch/riscv/bootblock.bootblock.ld $$(bootblock-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(CC_bootblock) $(CFLAGS_bootblock) -nostartfiles -Wl,--gc-sections -static -o $@ -L$(obj) \ $(LD_bootblock) --gc-sections -static -o $@ -L$(obj) \
-T $(src)/arch/riscv/bootblock.ld -Wl,--start-group $(bootblock-objs) \ -T $(obj)/arch/riscv/bootblock.bootblock.ld --start-group $(bootblock-objs) \
$(LIBGCC_FILE_NAME_bootblock) -Wl,--end-group $(LIBGCC_FILE_NAME_bootblock) --end-group
endif endif
@ -65,11 +65,13 @@ romstage-y += \
romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
romstage-y += romstage.ld
# Build the romstage # Build the romstage
$(objcbfs)/romstage.debug: $$(romstage-objs) $(src)/arch/riscv/romstage.ld $(obj)/ldoptions $(objcbfs)/romstage.debug: $$(romstage-objs) $(obj)/arch/riscv/romstage.romstage.ld
@printf " LINK $(subst $(obj)/,,$(@))\n" @printf " LINK $(subst $(obj)/,,$(@))\n"
$(CC_romstage) $(CFLAGS_romstage) -nostdlib -Wl,--gc-sections -static -o $@ -L$(obj) -T $(src)/arch/riscv/romstage.ld -Wl,--start-group $(romstage-objs) -Wl,--end-group $(LD_romstage) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/riscv/romstage.romstage.ld --start-group $(romstage-objs) --end-group
romstage-c-ccopts += $(riscv_flags) romstage-c-ccopts += $(riscv_flags)
romstage-S-ccopts += $(riscv_asm_flags) romstage-S-ccopts += $(riscv_asm_flags)
@ -101,13 +103,15 @@ $(eval $(call create_class_compiler,rmodules,riscv))
ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
ramstage-y += ramstage.ld
ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c
# Build the ramstage # Build the ramstage
$(objcbfs)/ramstage.debug: $$(ramstage-objs) $(src)/arch/riscv/ramstage.ld $(obj)/ldoptions $(objcbfs)/ramstage.debug: $$(ramstage-objs) $(obj)/arch/riscv/ramstage.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(CC_ramstage) $(CFLAGS_ramstage) -nostdlib -Wl,--gc-sections -static -o $@ -L$(obj) -Wl,--start-group $(ramstage-objs) -Wl,--end-group -T $(src)/arch/riscv/ramstage.ld $(LD_ramstage) --gc-sections -static -o $@ -L$(obj) -T $(obj)/arch/riscv/ramstage.ramstage.ld --start-group $(ramstage-objs) --end-group
ramstage-c-ccopts += $(riscv_flags) ramstage-c-ccopts += $(riscv_flags)
ramstage-S-ccopts += $(riscv_asm_flags) ramstage-S-ccopts += $(riscv_asm_flags)

View File

@ -21,7 +21,6 @@
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
OUTPUT_ARCH(riscv) OUTPUT_ARCH(riscv)
INCLUDE ldoptions
PHDRS PHDRS
{ {
@ -29,7 +28,6 @@ PHDRS
} }
ENTRY(_start) ENTRY(_start)
TARGET(binary)
SECTIONS SECTIONS
{ {
. = CONFIG_BOOTBLOCK_BASE; . = CONFIG_BOOTBLOCK_BASE;

View File

@ -20,9 +20,6 @@
* 2005.12 yhlu add ramstage cross the vga font buffer handling * 2005.12 yhlu add ramstage cross the vga font buffer handling
*/ */
/* We use ELF as output format. So that we can debug the code in some form. */
INCLUDE ldoptions
ENTRY(stage_entry) ENTRY(stage_entry)
PHDRS PHDRS

View File

@ -19,15 +19,9 @@
* 2005.12 yhlu add ramstage cross the vga font buffer handling * 2005.12 yhlu add ramstage cross the vga font buffer handling
*/ */
/* We use ELF as output format. So that we can debug the code in some form. */
/*
INCLUDE ldoptions
*/
/* We use ELF as output format. So that we can debug the code in some form. */ /* We use ELF as output format. So that we can debug the code in some form. */
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
OUTPUT_ARCH(riscv) OUTPUT_ARCH(riscv)
INCLUDE ldoptions
PHDRS PHDRS
{ {

View File

@ -103,9 +103,9 @@ ifeq ($(CONFIG_SSE),y)
bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__ bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
endif endif
$(objgenerated)/bootblock.ld: $(obj)/ldoptions $$(filter %.ld,$$(bootblock-srcs)) $(objgenerated)/bootblock.ld: $(obj)/config.h $$(filter %.ld,$$(bootblock-srcs))
@printf " GEN $(subst $(obj)/,,$(@))\n" @printf " GEN $(subst $(obj)/,,$(@))\n"
printf '$(foreach ldscript,$(^),INCLUDE "$(ldscript)"\n)' > $@ printf '$(foreach ldscript,$(^),#include "$(ldscript)"\n)' | $(CC_bootblock) $(PREPROCESS_ONLY) - > $@
$(objgenerated)/bootblock_inc.S: $$(bootblock_inc) $(objgenerated)/bootblock_inc.S: $$(bootblock_inc)
@printf " GEN $(subst $(obj)/,,$(@))\n" @printf " GEN $(subst $(obj)/,,$(@))\n"
@ -212,18 +212,18 @@ $(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(roms
@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 $(filter-out %.ld,$(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: $(obj)/ldoptions $$(filter %.ld,$$(romstage-srcs)) $(objgenerated)/romstage_null.ld: $(obj)/config.h $$(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,$(^),INCLUDE "$(ldscript)"\n)' >> $@.tmp printf '$(foreach ldscript,$(^),#include "$(ldscript)"\n)' >> $@.tmp
mv $@.tmp $@ $(CC_romstage) $(PREPROCESS_ONLY) $@.tmp > $@
$(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt $(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt
@printf " GEN $(subst $(obj)/,,$(@))\n" @printf " GEN $(subst $(obj)/,,$(@))\n"
rm -f $@ rm -f $@
sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(objcbfs)/base_xip.txt > $@.tmp 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 $@ mv $@.tmp $@
$(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin $(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin
@ -299,9 +299,11 @@ $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
else else
$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(src)/arch/x86/ramstage.ld ramstage-srcs += $(src)/arch/x86/ramstage.ld
$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/ramstage.ramstage.ld
@printf " CC $(subst $(obj)/,,$(@))\n" @printf " CC $(subst $(obj)/,,$(@))\n"
$(LD_ramstage) --gc-sections -o $@ -L$(obj) $< -T $(src)/arch/x86/ramstage.ld $(LD_ramstage) --gc-sections -o $@ -L$(obj) $< -T $(obj)/arch/x86/ramstage.ramstage.ld
endif endif

View File

@ -75,8 +75,8 @@ SECTIONS
. = 0xffffff00; . = 0xffffff00;
.illegal_globals . : { .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)
*(.bss.*) *(.bss.*)
*(.sbss) *(.sbss)

View File

@ -19,9 +19,6 @@
* 2005.12 yhlu add ramstage cross the vga font buffer handling * 2005.12 yhlu add ramstage cross the vga font buffer handling
*/ */
/* We use ELF as output format. So that we can debug the code in some form. */
INCLUDE ldoptions
ENTRY(_start) ENTRY(_start)
SECTIONS SECTIONS

View File

@ -34,7 +34,7 @@ smm-c-deps:=$$(OPTION_TABLE_H)
$(obj)/cpu/x86/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm) $(obj)/cpu/x86/smm/smm.o: $$(smm-objs) $(COMPILER_RT_smm)
$(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) --start-group $(smm-objs) $(COMPILER_RT_smm) --end-group $(LD_smm) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smm) --start-group $(smm-objs) $(COMPILER_RT_smm) --end-group
$(obj)/cpu/x86/smm/smm_wrap: $(obj)/cpu/x86/smm/smm.o $(src)/cpu/x86/smm/$(SMM_LDSCRIPT) $(obj)/ldoptions $(obj)/cpu/x86/smm/smm_wrap: $(obj)/cpu/x86/smm/smm.o $(src)/cpu/x86/smm/$(SMM_LDSCRIPT)
$(LD_smm) $(SMM_LDFLAGS) -nostdlib -nostartfiles -static -o $(obj)/cpu/x86/smm/smm.elf -T $(src)/cpu/x86/smm/$(SMM_LDSCRIPT) $(obj)/cpu/x86/smm/smm.o $(LD_smm) $(SMM_LDFLAGS) -nostdlib -nostartfiles -static -o $(obj)/cpu/x86/smm/smm.elf -T $(src)/cpu/x86/smm/$(SMM_LDSCRIPT) $(obj)/cpu/x86/smm/smm.o
$(NM_smm) -n $(obj)/cpu/x86/smm/smm.elf | sort > $(obj)/cpu/x86/smm/smm.map $(NM_smm) -n $(obj)/cpu/x86/smm/smm.elf | sort > $(obj)/cpu/x86/smm/smm.map
$(OBJCOPY_smm) -O binary $(obj)/cpu/x86/smm/smm.elf $(obj)/cpu/x86/smm/smm $(OBJCOPY_smm) -O binary $(obj)/cpu/x86/smm/smm.elf $(obj)/cpu/x86/smm/smm

View File

@ -137,7 +137,7 @@ RMODULE_LDFLAGS := -nostartfiles --gc-sections --emit-relocs -z defs -Bsymbolic
# It will create the necessary Make rules to create a rmodule. The resulting # It will create the necessary Make rules to create a rmodule. The resulting
# rmdoule is named $(1).rmod # rmdoule is named $(1).rmod
define rmodule_link define rmodule_link
$(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions $$(RMODTOOL) $(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(RMODTOOL)
$$(LD_rmodules_$(4)) $$(RMODULE_LDFLAGS) --defsym=__heap_size=$(strip $(3)) -o $$@ --start-group $(strip $(2)) $$(COMPILER_RT_rmodules_$(4)) --end-group $$(LD_rmodules_$(4)) $$(RMODULE_LDFLAGS) --defsym=__heap_size=$(strip $(3)) -o $$@ --start-group $(strip $(2)) $$(COMPILER_RT_rmodules_$(4)) --end-group
$$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map $$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map