[lld] r304420 - Convert a few more uses of OutputSections. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 09:26:28 PDT 2017
Author: rafael
Date: Thu Jun 1 11:26:28 2017
New Revision: 304420
URL: http://llvm.org/viewvc/llvm-project?rev=304420&view=rev
Log:
Convert a few more uses of OutputSections. NFC.
Also needed to move clearOutputSections earlier.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=304420&r1=304419&r2=304420&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Jun 1 11:26:28 2017
@@ -919,9 +919,10 @@ void LinkerScript::synchronize() {
}
}
-static bool allocateHeaders(std::vector<PhdrEntry> &Phdrs,
- ArrayRef<OutputSection *> OutputSections,
- uint64_t Min) {
+static bool
+allocateHeaders(std::vector<PhdrEntry> &Phdrs,
+ ArrayRef<OutputSectionCommand *> OutputSectionCommands,
+ uint64_t Min) {
auto FirstPTLoad =
std::find_if(Phdrs.begin(), Phdrs.end(),
[](const PhdrEntry &E) { return E.p_type == PT_LOAD; });
@@ -938,16 +939,19 @@ static bool allocateHeaders(std::vector<
assert(FirstPTLoad->First == Out::ElfHeader);
OutputSection *ActualFirst = nullptr;
- for (OutputSection *Sec : OutputSections) {
+ for (OutputSectionCommand *Cmd : OutputSectionCommands) {
+ OutputSection *Sec = Cmd->Sec;
if (Sec->FirstInPtLoad == Out::ElfHeader) {
ActualFirst = Sec;
break;
}
}
if (ActualFirst) {
- for (OutputSection *Sec : OutputSections)
+ for (OutputSectionCommand *Cmd : OutputSectionCommands) {
+ OutputSection *Sec = Cmd->Sec;
if (Sec->FirstInPtLoad == Out::ElfHeader)
Sec->FirstInPtLoad = ActualFirst;
+ }
FirstPTLoad->First = ActualFirst;
} else {
Phdrs.erase(FirstPTLoad);
@@ -961,7 +965,9 @@ static bool allocateHeaders(std::vector<
return false;
}
-void LinkerScript::assignAddresses(std::vector<PhdrEntry> &Phdrs) {
+void LinkerScript::assignAddresses(
+ std::vector<PhdrEntry> &Phdrs,
+ ArrayRef<OutputSectionCommand *> OutputSectionCommands) {
// Assign addresses as instructed by linker script SECTIONS sub-commands.
Dot = 0;
ErrorOnMissingSection = true;
@@ -983,14 +989,15 @@ void LinkerScript::assignAddresses(std::
}
uint64_t MinVA = std::numeric_limits<uint64_t>::max();
- for (OutputSection *Sec : *OutputSections) {
+ for (OutputSectionCommand *Cmd : OutputSectionCommands) {
+ OutputSection *Sec = Cmd->Sec;
if (Sec->Flags & SHF_ALLOC)
MinVA = std::min<uint64_t>(MinVA, Sec->Addr);
else
Sec->Addr = 0;
}
- allocateHeaders(Phdrs, *OutputSections, MinVA);
+ allocateHeaders(Phdrs, OutputSectionCommands, MinVA);
}
// Creates program headers as instructed by PHDRS linker script command.
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=304420&r1=304419&r2=304420&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Thu Jun 1 11:26:28 2017
@@ -281,7 +281,8 @@ public:
void placeOrphanSections();
void processNonSectionCommands();
void synchronize();
- void assignAddresses(std::vector<PhdrEntry> &Phdrs);
+ void assignAddresses(std::vector<PhdrEntry> &Phdrs,
+ ArrayRef<OutputSectionCommand *> OutputSectionCommands);
void addSymbol(SymbolAssignment *Cmd);
void processCommands(OutputSectionFactory &Factory);
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=304420&r1=304419&r2=304420&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Jun 1 11:26:28 2017
@@ -277,7 +277,7 @@ template <class ELFT> void Writer<ELFT>:
assignFileOffsets();
} else {
Script->synchronize();
- Script->assignAddresses(Phdrs);
+ Script->assignAddresses(Phdrs, OutputSectionCommands);
// Remove empty PT_LOAD to avoid causing the dynamic linker to try to mmap a
// 0 sized region. This has to be done late since only after assignAddresses
More information about the llvm-commits
mailing list