Makefile: Preprocess linker scripts and other general improvements
This patch started out as an attempt to run linker scripts through the preprocessor. However, since that required some more infrastructure changes, the build system is so intertwined, and there are so many other small issues that turned up and are easier to fix (and get running, and test thoroughly) in a single go, it turned out a little bigger. In order of appearance, it: - wraps direct linker invocations in a macro to avoid the widespread ifeq($(CONFIG_COMPILER_LLVM_CLANG),y) duplication. - introduces an $(generic-deps) (equivalent to $(<class>-deps)) variable for targets that all files depend on - makes the $(src-to-obj) function usable in multiple places as the authoritative way to get an output file name (even if the respective source file is also under build/), and makes it preserve extensions on everything except %.c and %.S (e.g. %.ld and %.asl) - replaces the old $(<class>-postprocess) with a single $(postprocessors) variable. The old ramstage-postprocess was weird because it contained unescaped $(eval ...)s, meaning it gets executed as soon as the variable is first substituted (and the other $(eval ...) in the toplevel Makefile does essentially nothing). The new mechanism is just $(eval ...)ed directly after the recursive parse with no further magic. Files can freely append their own (escaped) content to it and access variables valid in the calling context (like $(<class>-objs)) directly. - enhances the existing $(<class>-<type>-ccopts) mechanism with $(<class>-generic-ccopts) and $(generic-<type>-ccopts) to reduce duplication. - makes .ld a type that can be added like a normal class file, causing it to be preprocessed with the correct #defines for the current class (needed for a follow-up feature). Migrates all linker scripts to this mechanism, which allows us to get rid of the weird $(ldoptions) mechanism (Kconfigs are replaced by preprocessor and no longer need to be defined as symbols). - removes duplicate $(INCLUDES) from $(CFLAGS) - repairs the crazy state of MIPS Makefiles, which seem to have been copied together from X86 despite having absolutely nothing in common with that architecture. They were using the same code to paste assembly pieces and linker scripts together without really needing it for anything, and even accidentally relied on a Kconfig default set in the arch/x86 subdirectory (I wish I was kidding). Changed them to work equivalent to the arm/arm64 Makefiles which are far closer related (also being SRAM-based platforms). - moves the x86-specifc $(OPTION_TABLES_H) into the x86 Makefile.inc and fixes an rule that would've had an empty target if it wasn't defined - removes the custom ldscript-gathering variables for x86 bootblock and romstage. The Makefile simply combines all .ld files that have been added to the respective class now. - uses the normal class build system to replace some of the custom rules for autogenerated bootblock/crt0 files on x86, and removes some hardcoded flags by using the normal $(...-ccopts) variables. - moves the handling of .asl files from the global Makefile.inc to x86. Changed to reuse the generic template for the preprocessing and C compilation steps. - removed the extra <name>.o linking step before linking an rmodule for modules that don't require special linker flags (most of them). - removes the incorrect assumption that there was a global $(LDFLAGS) from the SMM Makefile.inc (it was named $(LDFLAGFS in one place so it couldn't have been all that important ;) ). - allow -j flag for parallel builds to be properly passed through to vboot child invocation by using special $(MAKE) variable. BUG=None TEST=Built for Falco, Nyan_Blaze, Stout, Rush_Ryu and Urara. Binary diffed old and new coreboot.rom (and some manually uncompressed stages), confirmed that images/stages are byte-for-byte identical except for some embedded timestamps and commit hashes. (Addresses in Falco/Stout ramstages shifting slightly due to different link order for ASL object files within their directory. Some addresses in Urara ramstage .rodata and some relocation entries in rmodules moved around due to linking them in fewer steps.) Change-Id: I50af7dacf616e0f8ff4c43f4acc679089ad7022b Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219170 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
b81ef37c03
commit
af6852b98f
42 changed files with 248 additions and 400 deletions
|
|
@ -66,7 +66,6 @@ INCLUDES += $(VB_INCLUDES)
|
|||
|
||||
VBOOT_STUB_ELF = $(obj)/vendorcode/google/chromeos/vbootstub.elf
|
||||
VBOOT_STUB = $(VBOOT_STUB_ELF).rmod
|
||||
VBOOT_STUB_DOTO = $(VBOOT_STUB_ELF:.elf=.o)
|
||||
|
||||
# Dependency for the vboot rmodules. Ordering matters.
|
||||
VBOOT_STUB_DEPS += $(obj)/vendorcode/google/chromeos/vboot_wrapper.rmodules_$(ARCH-ROMSTAGE-y).o
|
||||
|
|
@ -90,19 +89,16 @@ VBOOT_CFLAGS += $(patsubst -I%,-I$(top)/%,$(filter-out -include $(src)/include/k
|
|||
VBOOT_CFLAGS += -DVBOOT_DEBUG
|
||||
VBOOT_CFLAGS += $(rmodules_$(ARCH-ROMSTAGE-y)-c-ccopts)
|
||||
|
||||
$(VBOOT_STUB_DOTO): $(VBOOT_STUB_DEPS)
|
||||
$(CC_rmodules_$(ARCH-ROMSTAGE-y)) $(CFLAGS_rmodules_$(ARCH-ROMSTAGE-y)) $(LDFLAGS) -nostdlib -r -o $@ $^
|
||||
|
||||
# Link the vbootstub module with a 64KiB-byte heap.
|
||||
$(eval $(call rmodule_link,$(VBOOT_STUB_ELF), $(VBOOT_STUB_DOTO), 0x10000,$(ARCH-ROMSTAGE-y)))
|
||||
$(eval $(call rmodule_link,$(VBOOT_STUB_ELF), $(VBOOT_STUB_DEPS), 0x10000,$(ARCH-ROMSTAGE-y)))
|
||||
|
||||
# Build vboot library without the default includes from coreboot proper.
|
||||
$(VB_LIB):
|
||||
@printf " MAKE $(subst $(obj)/,,$(@))\n"
|
||||
$(Q)FIRMWARE_ARCH=$(VB_FIRMWARE_ARCH) \
|
||||
CC="$(CC_romstage)" \
|
||||
CFLAGS="$(VBOOT_CFLAGS)" \
|
||||
make -C $(VB_SOURCE) \
|
||||
CFLAGS="$(VBOOT_CFLAGS)" \
|
||||
$(MAKE) -C $(VB_SOURCE) \
|
||||
$(VBOOT_MAKEFLAGS) \
|
||||
BUILD=$(top)/$(dir $(VB_LIB)) \
|
||||
V=$(V) \
|
||||
|
|
@ -115,8 +111,7 @@ VB_SOURCE := vboot_reference
|
|||
INCLUDES += -I$(VB_SOURCE)/firmware/2lib/include
|
||||
INCLUDES += -I$(VB_SOURCE)/firmware/include
|
||||
|
||||
verstage-c-ccopts += -D__PRE_RAM__ -D__VER_STAGE__
|
||||
verstage-S-ccopts += -D__PRE_RAM__ -D__VER_STAGE__
|
||||
verstage-generic-ccopts += -D__PRE_RAM__ -D__VER_STAGE__
|
||||
|
||||
ifeq ($(CONFIG_RETURN_FROM_VERSTAGE),y)
|
||||
bootblock-y += verstub.c chromeos.c
|
||||
|
|
@ -134,12 +129,12 @@ VBOOT_CFLAGS += $(verstage-c-ccopts)
|
|||
VBOOT_CFLAGS += -include $(top)/src/include/kconfig.h -Wno-missing-prototypes
|
||||
VBOOT_CFLAGS += -DVBOOT_DEBUG
|
||||
|
||||
$(VB2_LIB): $(obj)/config.h
|
||||
$(VB2_LIB): $$(generic-deps)
|
||||
@printf " MAKE $(subst $(obj)/,,$(@))\n"
|
||||
$(Q)FIRMWARE_ARCH=$(VB_FIRMWARE_ARCH) \
|
||||
CC="$(CC_verstage)" \
|
||||
CFLAGS="$(VBOOT_CFLAGS)" VBOOT2="y" \
|
||||
make -C $(VB_SOURCE) \
|
||||
CFLAGS="$(VBOOT_CFLAGS)" VBOOT2="y" \
|
||||
$(MAKE) -C $(VB_SOURCE) \
|
||||
BUILD=$(top)/$(dir $(VB2_LIB)) \
|
||||
V=$(V) \
|
||||
fwlib2
|
||||
|
|
@ -149,4 +144,4 @@ cbfs-files-y += $(call strip_quotes,$(CONFIG_CBFS_PREFIX))/verstage
|
|||
fallback/verstage-file = $(VERSTAGE_ELF)
|
||||
fallback/verstage-type = stage
|
||||
fallback/verstage-compression = none
|
||||
endif # CONFIG_VBOOT2_VERIFY_FIRMWARE
|
||||
endif # CONFIG_VBOOT2_VERIFY_FIRMWARE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue