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/ELF/LinkerScript.cpp | |
| 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/ELF/LinkerScript.cpp')
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 23 |
1 files changed, 15 insertions, 8 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. |

