[coreboot] Patch set updated for coreboot: dd90cc6 Makefile: split romstage linking to separate rules

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Mon Mar 26 19:22:59 CEST 2012


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/803

-gerrit

commit dd90cc60f10135aacd7dca36716d32c2226ba459
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sun Mar 25 17:21:21 2012 +0300

    Makefile: split romstage linking to separate rules
    
    After change it is more clear how romstage is linked twice and with
    what scripts. Also with the change, it is easier to add some
    object of static size that need to be re-compiled for the 2nd link.
    One such object could be md5sum of executable.
    
    Change-Id: Ib34d1876071a51345c5c7319a0ed937868817fd1
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/Makefile.inc |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index fc3cd14..a437d18 100755
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -272,8 +272,7 @@ $(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
 	rm -f $@
 	cp $(obj)/coreboot.pre1 $@
 	$(CBFSTOOL) $@ add-stage $(obj)/romstage.elf \
-            $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
-#FIXME: location.txt might require an offset of header size
+		$(CONFIG_CBFS_PREFIX)/romstage x $(shell cat $(obj)/location.txt)
 
 #######################################################################
 # Build the bootblock
@@ -340,26 +339,42 @@ $(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootbl
 
 #######################################################################
 # Build the romstage
-$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $$(romstage-objs) $(obj)/romstage/ldscript.ld
+
+$(obj)/romstage.bin: $$(romstage-objs) $(obj)/romstage/link1st.ld
+	@printf "    LINK       $(subst $(obj)/,,$(@))\n"
+	$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/link1st.ld $(romstage-objs)
+	$(OBJCOPY) -O binary $(obj)/romstage.elf $@
+
+$(obj)/coreboot.romstage: $$(romstage-objs) $(obj)/romstage/link2nd.ld
 	@printf "    LINK       $(subst $(obj)/,,$(@))\n"
-	printf "ROMSTAGE_BASE = 0x0;\n" > $(obj)/location.ld
-	$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(romstage-objs)
-	$(OBJCOPY) -O binary $(obj)/romstage.elf $(obj)/romstage.bin
-	printf "ROMSTAGE_BASE = 0x" > $(obj)/location.ld
-	$(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $(obj)/location.txt || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
-	cat $(obj)/location.txt >> $(obj)/location.ld
-	printf ';\n' >> $(obj)/location.ld
-	$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(romstage-objs)
+	$(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/link2nd.ld $(romstage-objs)
 	$(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map
 	$(OBJCOPY) --only-keep-debug $(obj)/romstage.elf $(obj)/romstage.debug
 	$(OBJCOPY) --strip-debug $(obj)/romstage.elf
 	$(OBJCOPY) --add-gnu-debuglink=$(obj)/romstage.debug $(obj)/romstage.elf
 	$(OBJCOPY) -O binary $(obj)/romstage.elf $@
 
-$(obj)/romstage/ldscript.ld: $$(ldscripts) $(obj)/ldoptions
+$(obj)/romstage/link1st.ld: $$(ldscripts) $(obj)/ldoptions
 	@printf "    GEN        $(subst $(obj)/,,$(@))\n"
 	mkdir -p $(obj)/romstage
-	printf '$(foreach ldscript,ldoptions location.ld $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' > $@
+	rm -f $@
+	printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp
+	printf '$(foreach ldscript,ldoptions $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp
+	mv $@.tmp $@
+
+$(obj)/romstage/link2nd.ld: $(obj)/romstage/link1st.ld $(obj)/location.txt
+	@printf "    GEN        $(subst $(obj)/,,$(@))\n"
+	rm -f $@
+	sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(obj)/location.txt > $@.tmp
+	sed -e '/ROMSTAGE_BASE/d' $(obj)/romstage/link1st.ld >> $@.tmp
+	mv $@.tmp $@
+
+$(obj)/location.txt: $(obj)/coreboot.pre1 $(obj)/romstage.bin
+	rm -f $@
+	$(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $@.tmp \
+	 || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
+	sed -i -e 's/^/0x/g' $@.tmp
+	mv $@.tmp $@
 
 $(obj)/romstage/crt0.S: $$(crt0s)
 	@printf "    GEN        $(subst $(obj)/,,$(@))\n"




More information about the coreboot mailing list