This improves the portability of the linker script and allows lld to link rom.o
Dot assignment inside an output section has an inconsistent behavior which makes lld difficult to implement. See https://bugs.llvm.org/show_bug.cgi?id=43083 Dropping `. =` turns out to be beneficial to older GNU ld as well because we can delete an ld check detecting "cannot move location counter backwards". Signed-off-by: Fangrui Song <mask...@google.com> --- scripts/layoutrom.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index 4c55390..94d4412 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -339,14 +339,19 @@ def outRelSections(sections, startsym, useseg=0): if section.finalloc is not None] sections.sort(key=operator.itemgetter(0)) out = "" + location = "_reloc_init_end" for addr, section in sections: loc = section.finalloc if useseg: loc = section.finalsegloc - out += ". = ( 0x%x - %s ) ;\n" % (loc, startsym) + if location == "_reloc_init_end": + out += ". += 0x%x - %s ;\n" % (loc, location) + elif location < loc: + out += ". += 0x%x ;\n" % (loc-location,) if section.name in ('.rodata.str1.1', '.rodata'): out += "_rodata%s = . ;\n" % (section.fileid,) out += "*%s.*(%s)\n" % (section.fileid, section.name) + location = loc + section.size return out # Build linker script output for a list of relocations. -- 2.26.0.rc2.310.g2932bb562d-goog _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-le...@seabios.org