diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-05-31 20:22:27 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-05-31 20:22:27 +0000 |
| commit | 969c6512c277ffca58d691322db7f61be4006458 (patch) | |
| tree | 88f9e2b50c4370d3c26e140bca750a3f241acf08 | |
| parent | db5e56f7b2c8fd96321bed5b829e77b6e699bfdf (diff) | |
| download | bcm5719-llvm-969c6512c277ffca58d691322db7f61be4006458.tar.gz bcm5719-llvm-969c6512c277ffca58d691322db7f61be4006458.zip | |
Move clearOutputSections earlier.
Another step into merging the linker script and non linker script code
paths.
llvm-svn: 304339
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 7 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index a5ca4a2e6e8..eecbe9cef18 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1085,7 +1085,12 @@ template <class ELFT> void OutputSectionCommand::writeTo(uint8_t *Buf) { return; // Write leading padding. - ArrayRef<InputSection *> Sections = Sec->Sections; + std::vector<InputSection *> Sections; + for (BaseCommand *Cmd : Commands) + if (auto *ISD = dyn_cast<InputSectionDescription>(Cmd)) + for (InputSection *IS : ISD->Sections) + if (IS->Live) + Sections.push_back(IS); uint32_t Filler = getFiller(); if (Filler) fill(Buf, Sections.empty() ? Sec->Size : Sections[0]->OutSecOff, Filler); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 55cb8565076..20f86f0f212 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -300,13 +300,13 @@ template <class ELFT> void Writer<ELFT>::run() { openFile(); if (ErrorCount) return; + clearOutputSections(); if (!Config->OFormatBinary) { writeHeader(); writeSections(); } else { writeSectionsBinary(); } - clearOutputSections(); // Backfill .note.gnu.build-id section content. This is done at last // because the content is usually a hash value of the entire output file. |

