(
For posterity, read https://reviews.llvm.org/D71035 to get some
understanding how objcopy -O binary works.
Program headers don't occupy space after objcopy -O binary, so there is
no need deleting PT_GNU_STACK via a PHDRS command.

)

This deletes a strip rule and avoids an immediate target rom.o

Signed-off-by: Fangrui Song <mask...@google.com>
---
 Makefile             | 10 +++-------
 scripts/layoutrom.py |  7 ++-----
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 7a16195..e52b395 100644
--- a/Makefile
+++ b/Makefile
@@ -182,13 +182,13 @@ $(OUT)rom32seg.o: $(OUT)code32seg.o 
$(OUT)romlayout32seg.lds
        @echo "  Linking $@"
        $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@
 
-$(OUT)rom.o: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o 
$(OUT)romlayout32flat.lds
+$(OUT)bios.bin.elf: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o 
$(OUT)code32flat.o $(OUT)romlayout32flat.lds
        @echo "  Linking $@"
        $(Q)$(LD) -N -T $(OUT)romlayout32flat.lds $(OUT)rom16.strip.o 
$(OUT)rom32seg.strip.o $(OUT)code32flat.o -o $@
 
-$(OUT)bios.bin.prep: $(OUT)rom.o scripts/checkrom.py
+$(OUT)bios.bin.prep: $(OUT)bios.bin.elf scripts/checkrom.py
        @echo "  Prepping $@"
-       $(Q)rm -f $(OUT)bios.bin $(OUT)Csm16.bin $(OUT)bios.bin.elf
+       $(Q)rm -f $(OUT)bios.bin $(OUT)Csm16.bin
        $(Q)$(READELF) -WSrs $< > $<.readelf
        $(Q)$(OBJCOPY) -O binary $< $(OUT)bios.bin.raw
        $(Q)$(PYTHON) ./scripts/checkrom.py $<.readelf $(CONFIG_ROM_SIZE) 
$(OUT)bios.bin.raw $(OUT)bios.bin.prep
@@ -201,10 +201,6 @@ $(OUT)Csm16.bin: $(OUT)bios.bin.prep
        @echo "  Creating $@"
        $(Q)cp $< $@
 
-$(OUT)bios.bin.elf: $(OUT)rom.o $(OUT)bios.bin.prep
-       @echo "  Creating $@"
-       $(Q)$(STRIP) -R .comment $< -o $(OUT)bios.bin.elf
-
 
 ################ VGA build rules
 
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py
index 3595371..c14966d 100755
--- a/scripts/layoutrom.py
+++ b/scripts/layoutrom.py
@@ -25,6 +25,7 @@ COMMONTRAILER = """
         /DISCARD/ : {
                 *(.text*) *(.data*) *(.bss*) *(.rodata*)
                 *(COMMON) *(.discard*) *(.eh_frame) *(.note*)
+                *(.comment)
                 }
 }
 """
@@ -438,7 +439,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
 %s
 %s
         code32flat_end = ABSOLUTE(.) ;
-    } :text
+    }
 """ % (li.sec32init_align,
        li.zonefseg_start,
        li.zonefseg_end,
@@ -455,10 +456,6 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
        outRelSections(li.sections, 'code32flat_start'))
     out = COMMONHEADER + out + COMMONTRAILER + """
 ENTRY(%s)
-PHDRS
-{
-        text PT_LOAD AT ( code32flat_start ) ;
-}
 """ % (li.entrysym.name,)
     outfile = open(out32flat, 'w')
     outfile.write(out)
-- 
2.25.1
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to