diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-01 16:26:28 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-06-01 16:26:28 +0000 |
| commit | faf25a7216d971f72e7878a7e661538da4c4c9ce (patch) | |
| tree | 5cfa3766ddf6f6d972084831c0db461f9652adbe /lld | |
| parent | 8a0966ea03e5f9ff1183c013c7927b3b65646df3 (diff) | |
| download | bcm5719-llvm-faf25a7216d971f72e7878a7e661538da4c4c9ce.tar.gz bcm5719-llvm-faf25a7216d971f72e7878a7e661538da4c4c9ce.zip | |
Convert a few more uses of OutputSections. NFC.
Also needed to move clearOutputSections earlier.
llvm-svn: 304420
Diffstat (limited to 'lld')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 23 | ||||
| -rw-r--r-- | lld/ELF/LinkerScript.h | 3 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 2 |
3 files changed, 18 insertions, 10 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index ec3f282e565..b68c8821a27 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -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<PhdrEntry> &Phdrs, 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<PhdrEntry> &Phdrs, 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::vector<PhdrEntry> &Phdrs) { } 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. diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 819d7c5e1d9..070d49937ce 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -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); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index b71ba5daaf9..9bc28a64cda 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -277,7 +277,7 @@ template <class ELFT> void Writer<ELFT>::run() { 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 |

