[lld] r307102 - Move clearOutputSections earlier. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 4 12:08:40 PDT 2017
Author: rafael
Date: Tue Jul 4 12:08:40 2017
New Revision: 307102
URL: http://llvm.org/viewvc/llvm-project?rev=307102&view=rev
Log:
Move clearOutputSections earlier. NFC.
Now addSectionSymbols operates on the linker script.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=307102&r1=307101&r2=307102&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jul 4 12:08:40 2017
@@ -197,11 +197,11 @@ template <class ELFT> void Writer<ELFT>:
if (Config->Discard != DiscardPolicy::All)
copyLocalSymbols();
+ clearOutputSections();
+
if (Config->CopyRelocs)
addSectionSymbols();
- clearOutputSections();
-
// Now that we have a complete set of output sections. This function
// completes section contents. For example, we need to add strings
// to the string table, and add entries to .got and .plt.
@@ -501,11 +501,18 @@ template <class ELFT> void Writer<ELFT>:
template <class ELFT> void Writer<ELFT>::addSectionSymbols() {
// Create one STT_SECTION symbol for each output section we might
// have a relocation with.
- for (OutputSection *Sec : OutputSections) {
- if (Sec->Sections.empty())
+ for (BaseCommand *Base : Script->Opt.Commands) {
+ auto *Cmd = dyn_cast<OutputSectionCommand>(Base);
+ if (!Cmd)
continue;
-
- InputSection *IS = Sec->Sections[0];
+ auto I = llvm::find_if(Cmd->Commands, [](BaseCommand *Base) {
+ if (auto *ISD = dyn_cast<InputSectionDescription>(Base))
+ return !ISD->Sections.empty();
+ return false;
+ });
+ if (I == Cmd->Commands.end())
+ continue;
+ InputSection *IS = cast<InputSectionDescription>(*I)->Sections[0];
if (isa<SyntheticSection>(IS) || IS->Type == SHT_REL ||
IS->Type == SHT_RELA)
continue;
More information about the llvm-commits
mailing list