(
With
https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/CJR7WU6TTHVQEG5XHCRI75EA6SBV72SW/
https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/GUYWC4VOYH76JOYGBNT7J4FSHLKG53EO/
and this patch, I am able to link bios.bin.elf with lld 7 (a somewhat
old version of lld. FreeBSD 12 uses lld 8

I considered an lld patch (https://reviews.llvm.org/D76174) but I now think it 
is probably not a good idea.
In almost all circumstances this is an error. See Peter Smith's comment.
It is just that seabios has a very particular use case which makes it
work.)


bios.bin.elf uses an extremely rare feature of GNU ld: an ET_EXEC can be
linked as if it were an ET_REL. lld is rigid and will reject this use case.
With this patch, I can link bios.bin.elf with lld 7.

Signed-off-by: Fangrui Song <mask...@google.com>
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 66b3eab..8d087af 100644
--- a/Makefile
+++ b/Makefile
@@ -181,11 +181,11 @@ $(OUT)romlayout32seg.lds $(OUT)romlayout32flat.lds 
$(OUT)code32flat.o $(OUT)code
 
 $(OUT)rom16.o: $(OUT)code16.o $(OUT)romlayout16.lds
        @echo "  Linking $@"
-       $(Q)$(LD) -T $(OUT)romlayout16.lds $< -o $@
+       $(Q)$(LD) -T $(OUT)romlayout16.lds $< -o $@ && printf '\1' | dd of=$@ 
conv=notrunc bs=1 seek=16  # Change ET_EXEC to ET_REL
 
 $(OUT)rom32seg.o: $(OUT)code32seg.o $(OUT)romlayout32seg.lds
        @echo "  Linking $@"
-       $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@
+       $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@ && printf '\1' | dd 
of=$@ conv=notrunc bs=1 seek=16  # Change ET_EXEC to ET_REL
 
 $(OUT)bios.bin.elf: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o 
$(OUT)code32flat.o $(OUT)romlayout32flat.lds
        @echo "  Linking $@"
-- 
2.25.1
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to