[lld] r286824 - Factor out placeOrphanSections. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 06:13:32 PST 2016
Author: rafael
Date: Mon Nov 14 08:13:32 2016
New Revision: 286824
URL: http://llvm.org/viewvc/llvm-project?rev=286824&view=rev
Log:
Factor out placeOrphanSections. NFC.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=286824&r1=286823&r2=286824&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Nov 14 08:13:32 2016
@@ -583,14 +583,11 @@ static bool shouldSkip(const BaseCommand
return Assign->Name != ".";
}
+// Orphan sections are sections present in the input files which are not
+// explicitly placed into the output file by the linker script. This just
+// places them in the order already decided in OutputSections.
template <class ELFT>
-void LinkerScript<ELFT>::assignAddresses(std::vector<PhdrEntry<ELFT>> &Phdrs) {
- // Orphan sections are sections present in the input files which
- // are not explicitly placed into the output file by the linker script.
- // We place orphan sections at end of file.
- // Other linkers places them using some heuristics as described in
- // https://sourceware.org/binutils/docs/ld/Orphan-Sections.html#Orphan-Sections.
-
+void LinkerScript<ELFT>::placeOrphanSections() {
// The OutputSections are already in the correct order.
// This loops creates or moves commands as needed so that they are in the
// correct order.
@@ -622,6 +619,11 @@ void LinkerScript<ELFT>::assignAddresses
// Continue from where we found it.
CmdIndex = (Pos - Opt.Commands.begin()) + 1;
}
+}
+
+template <class ELFT>
+void LinkerScript<ELFT>::assignAddresses(std::vector<PhdrEntry<ELFT>> &Phdrs) {
+ placeOrphanSections();
// Assign addresses as instructed by linker script SECTIONS sub-commands.
Dot = 0;
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=286824&r1=286823&r2=286824&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Mon Nov 14 08:13:32 2016
@@ -229,6 +229,7 @@ public:
bool hasLMA(StringRef Name);
bool shouldKeep(InputSectionBase<ELFT> *S);
void assignOffsets(OutputSectionCommand *Cmd);
+ void placeOrphanSections();
void assignAddresses(std::vector<PhdrEntry<ELFT>> &Phdrs);
bool hasPhdrsCommands();
uint64_t getOutputSectionAddress(StringRef Name) override;
More information about the llvm-commits
mailing list