Accepting ET_EXEC as an input file is an extremely rare GNU ld feature
that lld does not intend to support, because this is error-prone.

See Linux kernel commit 90ceddcb495008ac8ba7a3dce297841efcd7d584 for
another use of the dd trick.

--
Changes v1 -> v2
* Add status=none to the dd command line. This suppresses dd's stderr output.
* Move dd command to a separate command

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

diff --git a/Makefile b/Makefile
index 5f7d537..118dec0 100644
--- a/Makefile
+++ b/Makefile
@@ -177,10 +177,14 @@ $(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 $@
+       # Change e_type to ET_REL so that it can be used to link rom.o.
+       # Unlike GNU ld, lld does not allow an ET_EXEC input.
+       printf '\1' | dd of=$@ conv=notrunc bs=1 seek=16 status=none
 
 $(OUT)rom32seg.o: $(OUT)code32seg.o $(OUT)romlayout32seg.lds
        @echo "  Linking $@"
        $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@
+       printf '\1' | dd of=$@ conv=notrunc bs=1 seek=16 status=none
 
 $(OUT)rom.o: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o 
$(OUT)romlayout32flat.lds
        @echo "  Linking $@"
-- 
2.26.0.292.g33ef6b2f38-goog
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to