(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. Just sort the addresses beforehand.
Signed-off-by: Fangrui Song maskray@google.com --- 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 6616721..4c55390 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