Sent my previous patch too quickly. This patch supersedes
Re: [SeaBIOS] [PATCH] Discard .comment via linker script and delete unneeded PHDRS
I just realized that we don't need /DISCARD/ : { ... *(.comment) } because .command is non-SHF_ALLOC.
`objcopy -O binary` does not write program headers or non-SHF_ALLOC sections, so the PHDRS command and strip -R .comment are redundant.
Signed-off-by: Fangrui Song maskray@google.com --- Makefile | 10 +++------- scripts/layoutrom.py | 6 +----- 2 files changed, 4 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..b38a47e 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -438,7 +438,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat): %s %s code32flat_end = ABSOLUTE(.) ; - } :text + } """ % (li.sec32init_align, li.zonefseg_start, li.zonefseg_end, @@ -455,10 +455,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)