(1) In romlayout.S, .fixedaddr.\addr sections do have not the SHF_ALLOC flag. It does not make sense to reference a SHF_ALLOC section from a non-SHF_ALLOC section via R_386_PC16. GNU ld allows it but lld will warn. Add the SHF_ALLOC flag.
(2) lld requires output section descriptions to be sorted by address.
Signed-off-by: Fangrui Song maskray@google.com
(Note: with https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/CJR7WU6... and this patch, qemu-system-x86_64 -boot menu=on,splash-time=15000 -bios out/bios.bin -nographic seems to work for me with a small change to lld (allow ET_EXEC to used as if a relocatable object)
More precisely, during: ld.lld -N -T out/romlayout32flat.lds out/rom16.strip.o out/rom32seg.strip.o out/code32flat.o -o out/rom.o
out/rom16.strip.o and out/rom32seg.strip.o are ET_EXEC, instead of ET_REL. lld<11 will reject such input. )
--- scripts/layoutrom.py | 4 ++++ src/romlayout.S | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index bbf07aa..14e6ada 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -321,6 +321,10 @@ def outXRefs(sections, useseg=0, exportsyms=[], forcedelta=0):
# Write LD script includes for the given sections def outSections(sections, useseg=0): + if useseg: + sections.sort(key=lambda x: x.finalsegloc) + else: + sections.sort(key=lambda x: x.finalloc) out = "" for section in sections: loc = section.finalloc diff --git a/src/romlayout.S b/src/romlayout.S index c4a4635..a854783 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -587,7 +587,7 @@ entry_18:
// Specify a location in the fixed part of bios area. .macro ORG addr - .section .fixedaddr.\addr + .section .fixedaddr.\addr,"a" .endm
ORG 0xe05b