lld requires output section descriptions to be sorted by address. Just sort the addresses beforehand.
-- Changes v2 -> v3 * Sort sections by finalloc unconditionally
Signed-off-by: Fangrui Song maskray@google.com --- scripts/layoutrom.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index abebf02..fa270ef 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -321,6 +321,7 @@ def outXRefs(sections, useseg=0, exportsyms=[], forcedelta=0):
# Write LD script includes for the given sections def outSections(sections, useseg=0): + sections = sorted(sections, key=lambda x: x.finalloc) out = "" for section in sections: loc = section.finalloc