linking: link bootblock.elf with .data and .bss sections again

Currently coreboot expects the loader to clear the bss section
for all stages. i.e. stages don't clear their own bss. On ARM
SoCs the BootROM would be responsible for this. To do that
one needs to include the bss section data (all zeros) in the
bootblock.bin file. This was previously being attempted by
keeping the .bss info in the .data section because objcopy
happened zero out non-file allocated data section data.

Instead go back to linking bootblock with the bss section
but mark the bss section as loadable allocatable data. That
way it will be included in the binary properly when objcopy
-O binary is emplyed. Also do the same for the data section
in the case of no non-zero object values are in the data
section.

Without this change the trick of including .bss in .data
was not working when there wasn't a non-zero value object
in the data section.

BUG=None
BRANCH=None
TEST=Built emulation/qemu-armv7 and noted bootblock.bin contains
     the cleared bss.

Change-Id: I94bd404c2c4a8b9332393e6224e98940a9cad4a2
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/11680
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Aaron Durbin 2015-09-17 17:02:53 -05:00
parent f66a026d70
commit d972f78e75
11 changed files with 16 additions and 48 deletions

View File

@ -531,10 +531,19 @@ find-substr = $(word 1,$(subst _, ,$(1)))
# and remove .x the next time and finally return romstage # and remove .x the next time and finally return romstage
find-class = $(if $(filter $(1),$(basename $(1))),$(if $(CC_$(1)), $(1), $(call find-substr,$(1))),$(call find-class,$(basename $(1)))) find-class = $(if $(filter $(1),$(basename $(1))),$(if $(CC_$(1)), $(1), $(call find-substr,$(1))),$(call find-class,$(basename $(1))))
$(objcbfs)/%.bin: $(objcbfs)/%.elf # Bootblocks are not CBFS stages. coreboot is currently expecting the bss to
$(eval class := $(call find-class,$(@F))) # be cleared by the loader of the stage. For ARM SoCs that means one needs to
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n" # include the bss section in the binary so the BootROM clears the bss on
$(OBJCOPY_$(class)) -O binary $< $@ # loading of the bootblock stage. Achieve this by marking the bss section
# loadable,allocatable, and data. Do the same for the .data section in case
# it's marked as NOBITS.
$(objcbfs)/bootblock.raw.bin: $(objcbfs)/bootblock.elf
@printf " OBJCOPY $(notdir $(@))\n"
$(OBJCOPY_bootblock) --set-section-flags .bss=load,alloc,data --set-section-flags .data=load,alloc,data $< $<.tmp
$(OBJCOPY_bootblock) -O binary $<.tmp $@
$(objcbfs)/%.bin: $(objcbfs)/%.raw.bin
cp $< $@
$(objcbfs)/%.elf: $(objcbfs)/%.debug $(objcbfs)/%.elf: $(objcbfs)/%.debug
$(eval class := $(call find-class,$(@F))) $(eval class := $(call find-class,$(@F)))

View File

@ -111,14 +111,7 @@
#endif #endif
#if ARCH_STAGE_HAS_BSS_SECTION #if ARCH_STAGE_HAS_BSS_SECTION
#if ENV_BOOTBLOCK
/* Bootblocks are not CBFS stages, so they cannot communicate the amount of
* (memsz - filesz) bytes the loader needs to clear for them. Therefore we merge
* the BSS into the .data section so those zeroes get loaded explicitly. */
.data . : {
#else
.bss . : { .bss . : {
#endif
. = ALIGN(ARCH_POINTER_ALIGN_SIZE); . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_bss = .; _bss = .;
*(.bss) *(.bss)

View File

@ -62,10 +62,6 @@ ramstage-y += usb.c
CPPFLAGS_common += -Isrc/soc/broadcom/cygnus/include/ CPPFLAGS_common += -Isrc/soc/broadcom/cygnus/include/
$(objcbfs)/bootblock.tmp: $(objcbfs)/bootblock.elf
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
$(OBJCOPY_bootblock) -O binary $< $@
ifneq ($(V),1) ifneq ($(V),1)
redirect := > /dev/null redirect := > /dev/null
endif endif
@ -96,7 +92,7 @@ endif
# SLEEP 1 # SLEEP 1
# DEEP_SLEEP 2 # DEEP_SLEEP 2
# EXCEPTION 4 # EXCEPTION 4
$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.tmp \ $(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin \
$(objutil)/broadcom/secimage/secimage \ $(objutil)/broadcom/secimage/secimage \
util/broadcom/unauth.cfg \ util/broadcom/unauth.cfg \
util/broadcom/khmacsha256 util/broadcom/khmacsha256

View File

@ -46,14 +46,8 @@ romstage-y += monotonic_timer.c
CPPFLAGS_common += -Isrc/soc/imgtec/pistachio/include/ CPPFLAGS_common += -Isrc/soc/imgtec/pistachio/include/
# Generate the actual coreboot bootblock code
$(objcbfs)/bootblock.raw: $(objcbfs)/bootblock.elf
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
$(OBJCOPY_bootblock) -O binary $< $@.tmp
@mv $@.tmp $@
# Create a complete bootblock which will start up the system # Create a complete bootblock which will start up the system
$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw $(BIMGTOOL) $(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin $(BIMGTOOL)
@printf " BIMGTOOL $(subst $(obj)/,,$(@))\n" @printf " BIMGTOOL $(subst $(obj)/,,$(@))\n"
$(BIMGTOOL) $< $@ $(call loadaddr,bootblock) $(BIMGTOOL) $< $@ $(call loadaddr,bootblock)

View File

@ -45,9 +45,6 @@ ramstage-$(CONFIG_SPI_FLASH) += spi.c
CPPFLAGS_common += -Isrc/soc/marvell/bg4cd/include/ CPPFLAGS_common += -Isrc/soc/marvell/bg4cd/include/
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
cp $< $@
$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin $(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin
@printf "Generating: $(subst $(obj)/,,$(@))\n" @printf "Generating: $(subst $(obj)/,,$(@))\n"
@mkdir -p $(dir $@) @mkdir -p $(dir $@)

View File

@ -84,9 +84,6 @@ CPPFLAGS_common += -Isrc/soc/nvidia/tegra124/include/
# package up the image pull in bootblock.bin, it will be this wrapped version # package up the image pull in bootblock.bin, it will be this wrapped version
# instead of the raw bootblock. # instead of the raw bootblock.
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
cp $< $@
$(obj)/generated/bct.bin: $(obj)/generated/bct.cfg $(CBOOTIMAGE) $(obj)/generated/bct.bin: $(obj)/generated/bct.cfg $(CBOOTIMAGE)
@printf " CBOOTIMAGE $(subst $(obj)/,,$(@))\n" @printf " CBOOTIMAGE $(subst $(obj)/,,$(@))\n"
$(CBOOTIMAGE) -gbct --soc tegra124 $< $@ $(CBOOTIMAGE) -gbct --soc tegra124 $< $@

View File

@ -121,9 +121,6 @@ CBOOTIMAGE_OPTS = --soc tegra132
# package up the image pull in bootblock.bin, it will be this wrapped version # package up the image pull in bootblock.bin, it will be this wrapped version
# instead of the raw bootblock. # instead of the raw bootblock.
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
cp $< $@
$(obj)/generated/bct.bin: $(obj)/generated/bct.cfg $(CBOOTIMAGE) $(obj)/generated/bct.bin: $(obj)/generated/bct.cfg $(CBOOTIMAGE)
@printf " CBOOTIMAGE $(subst $(obj)/,,$(@))\n" @printf " CBOOTIMAGE $(subst $(obj)/,,$(@))\n"
$(CBOOTIMAGE) -gbct $(CBOOTIMAGE_OPTS) $< $@ $(CBOOTIMAGE) -gbct $(CBOOTIMAGE_OPTS) $< $@

View File

@ -56,14 +56,8 @@ ramstage-y += tz_wrapper.S
ifeq ($(CONFIG_USE_BLOBS),y) ifeq ($(CONFIG_USE_BLOBS),y)
# Generate the actual coreboot bootblock code
$(objcbfs)/bootblock.raw: $(objcbfs)/bootblock.elf
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
$(OBJCOPY_bootblock) -O binary $< $@.tmp
@mv $@.tmp $@
# Add MBN header to allow SBL3 to start coreboot bootblock # Add MBN header to allow SBL3 to start coreboot bootblock
$(objcbfs)/bootblock.mbn: $(objcbfs)/bootblock.raw $(objcbfs)/bootblock.mbn: $(objcbfs)/bootblock.raw.bin
@printf " ADD MBN $(subst $(obj)/,,$(@))\n" @printf " ADD MBN $(subst $(obj)/,,$(@))\n"
./util/ipqheader/ipqheader.py $(call loadaddr,bootblock) $< $@.tmp ./util/ipqheader/ipqheader.py $(call loadaddr,bootblock) $< $@.tmp
@mv $@.tmp $@ @mv $@.tmp $@

View File

@ -75,9 +75,6 @@ ramstage-$(CONFIG_DRIVERS_UART) += uart.c
CPPFLAGS_common += -Isrc/soc/rockchip/rk3288/include/ CPPFLAGS_common += -Isrc/soc/rockchip/rk3288/include/
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
cp $< $@
$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin $(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin
@printf "Generating: $(subst $(obj)/,,$(@))\n" @printf "Generating: $(subst $(obj)/,,$(@))\n"
@mkdir -p $(dir $@) @mkdir -p $(dir $@)

View File

@ -46,9 +46,6 @@ ramstage-y += cbmem.c
CPPFLAGS_common += -Isrc/soc/samsung/exynos5250/include/ CPPFLAGS_common += -Isrc/soc/samsung/exynos5250/include/
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
cp $< $@
$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin $(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin
@printf " BL1, CKSUM $(subst $(obj)/,,$(@))\n" @printf " BL1, CKSUM $(subst $(obj)/,,$(@))\n"
util/exynos/fixed_cksum.py $< $<.cksum 32768 util/exynos/fixed_cksum.py $< $<.cksum 32768

View File

@ -48,9 +48,6 @@ rmodules_$(ARCH-ROMSTAGE-y)-y += timer.c
CPPFLAGS_common += -Isrc/soc/samsung/exynos5420/include/ CPPFLAGS_common += -Isrc/soc/samsung/exynos5420/include/
$(objcbfs)/bootblock.raw.elf: $(objcbfs)/bootblock.elf
cp $< $@
$(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin $(objcbfs)/bootblock.bin: $(objcbfs)/bootblock.raw.bin
@printf " BL1, CKSUM $(subst $(obj)/,,$(@))\n" @printf " BL1, CKSUM $(subst $(obj)/,,$(@))\n"
util/exynos/variable_cksum.py $< $<.cksum util/exynos/variable_cksum.py $< $<.cksum