Fix pr32816.
When using linkerscripts we were trying to sort SHF_LINK_ORDER
sections too early. Instead of always doing two runs of
assignAddresses, record the section order in processCommands.
llvm-svn: 301830
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f7bc237..22a5b63 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -406,8 +406,15 @@
}
// Add input sections to an output section.
- for (InputSectionBase *S : V)
+ unsigned Pos = 0;
+ for (InputSectionBase *S : V) {
+ // The actual offset will be computed during
+ // assignAddresses. For now, use the index as a very crude
+ // approximation so that it is at least easy for other code to
+ // know the section order.
+ cast<InputSection>(S)->OutSecOff = Pos++;
Factory.addInputSec(S, Cmd->Name, Cmd->Sec);
+ }
}
}
CurOutSec = nullptr;