aboutsummaryrefslogtreecommitdiffstats
path: root/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-07-19 07:02:58 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-07-19 07:02:58 +0000
commitda06c7cfa0388de29a4024d8d386e48f2fb13ed6 (patch)
treedc28e84fc2bb9a4a4d9873fe4d04946fe3f7f4c0 /ELF/LinkerScript.cpp
parent267829774358b5aebd3e726ae318813bd48129bb (diff)
downloadsrc-da06c7cfa0388de29a4024d8d386e48f2fb13ed6.tar.gz
src-da06c7cfa0388de29a4024d8d386e48f2fb13ed6.zip
Vendor import of lld trunk r308421:vendor/lld/lld-trunk-r308421
Notes
Notes: svn path=/vendor/lld/dist/; revision=321192 svn path=/vendor/lld/lld-trunk-r308421/; revision=321193; tag=vendor/lld/lld-trunk-r308421
Diffstat (limited to 'ELF/LinkerScript.cpp')
-rw-r--r--ELF/LinkerScript.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/ELF/LinkerScript.cpp b/ELF/LinkerScript.cpp
index a182d5a3a096..8bdbd8db20ad 100644
--- a/ELF/LinkerScript.cpp
+++ b/ELF/LinkerScript.cpp
@@ -229,6 +229,19 @@ bool LinkerScript::shouldKeep(InputSectionBase *S) {
return false;
}
+// If an input string is in the form of "foo.N" where N is a number,
+// return N. Otherwise, returns 65536, which is one greater than the
+// lowest priority.
+static int getPriority(StringRef S) {
+ size_t Pos = S.rfind('.');
+ if (Pos == StringRef::npos)
+ return 65536;
+ int V;
+ if (!to_integer(S.substr(Pos + 1), V, 10))
+ return 65536;
+ return V;
+}
+
// A helper function for the SORT() command.
static std::function<bool(InputSectionBase *, InputSectionBase *)>
getComparator(SortSectionPolicy K) {
@@ -449,7 +462,7 @@ void LinkerScript::fabricateDefaultCommands() {
// The Sections with -T<section> have been sorted in order of ascending
// address. We must lower StartAddr if the lowest -T<section address> as
// calls to setDot() must be monotonically increasing.
- for (auto& KV : Config->SectionStartMap)
+ for (auto &KV : Config->SectionStartMap)
StartAddr = std::min(StartAddr, KV.second);
Commands.push_back(make<SymbolAssignment>(
@@ -739,7 +752,7 @@ void LinkerScript::adjustSectionsAfterSorting() {
Cmd->MemRegion = findMemoryRegion(Cmd);
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
if (Cmd->AlignExpr)
- Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
+ Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
}
}
@@ -1071,7 +1084,7 @@ template <class ELFT> void OutputSectionCommand::finalize() {
}
if ((Sec->Flags & SHF_LINK_ORDER)) {
- std::sort(Sections.begin(), Sections.end(), compareByFilePosition);
+ std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);
for (int I = 0, N = Sections.size(); I < N; ++I)
*ScriptSections[I] = Sections[I];