diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-07-04 19:08:40 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-07-04 19:08:40 +0000 |
commit | d48b208833a7c26f3b005849fc4fc0d6ef41ccad (patch) | |
tree | d753b8a4473940c94a39097dda095f2667002a3f | |
parent | b6915457210adb33e90a4475ba80ae21c861227a (diff) | |
download | bcm5719-llvm-d48b208833a7c26f3b005849fc4fc0d6ef41ccad.tar.gz bcm5719-llvm-d48b208833a7c26f3b005849fc4fc0d6ef41ccad.zip |
Move clearOutputSections earlier. NFC.
Now addSectionSymbols operates on the linker script.
llvm-svn: 307102
-rw-r--r-- | lld/ELF/Writer.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 8dbfabd0964..f790ccfca56 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -197,11 +197,11 @@ template <class ELFT> void Writer<ELFT>::run() { 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>::copyLocalSymbols() { 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; |