Kyösti Mälkki ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/803

-gerrit

commit bf34b57ec47f525055157f4e5ec0f77c151ea2e4
Author: Kyösti Mälkki <[email protected]>
Date:   Sat Mar 31 10:21:29 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 <[email protected]>
---
 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 5917ce5..f131af9 100755
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -274,9 +274,8 @@ $(obj)/coreboot.pre: $(obj)/coreboot.romstage 
$(obj)/coreboot.pre1 $(CBFSTOOL)
        @printf "    CBFS       $(subst $(obj)/,,$(@))\n"
        cp $(obj)/coreboot.pre1 [email protected]
        $(CBFSTOOL) [email protected] add-stage $(obj)/romstage.elf \
-           $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
+               $(CONFIG_CBFS_PREFIX)/romstage x $(shell cat 
$(obj)/location.txt)
        mv [email protected] $@
-#FIXME: location.txt might require an offset of header size
 
 #######################################################################
 # Build the bootblock
@@ -344,26 +343,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"
-       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/link1st.ld $(romstage-objs)
+       $(OBJCOPY) -O binary $(obj)/romstage.elf $@
+
+$(obj)/coreboot.romstage: $$(romstage-objs) $(obj)/romstage/link2nd.ld
+       @printf "    LINK       $(subst $(obj)/,,$(@))\n"
+       $(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" > [email protected]
+       printf '$(foreach ldscript,ldoptions $(ldscripts),INCLUDE 
"$(ldscript:$(obj)/%=%)"\n)' >> [email protected]
+       mv [email protected] $@
+
+$(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 > 
[email protected]
+       sed -e '/ROMSTAGE_BASE/d' $(obj)/romstage/link1st.ld >> [email protected]
+       mv [email protected] $@
+
+$(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) > [email protected] \
+        || { echo "The romstage is larger than XIP size. Please expand the 
CONFIG_XIP_ROM_SIZE" ; exit 1; }
+       sed -i -e 's/^/0x/g' [email protected]
+       mv [email protected] $@
 
 $(obj)/romstage/crt0.S: $$(crt0s)
        @printf "    GEN        $(subst $(obj)/,,$(@))\n"

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to