diff options
author | Rui Ueyama <ruiu@google.com> | 2016-08-09 01:35:37 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-08-09 01:35:37 +0000 |
commit | 75118259bac43e6d3a28fdcc86c15c296c75806a (patch) | |
tree | f10466c8fe03180e44afc9cb49e234bf045158ca | |
parent | 53b9af02c8437c03508f5fb34d5902352300bf9a (diff) | |
download | bcm5719-llvm-75118259bac43e6d3a28fdcc86c15c296c75806a.tar.gz bcm5719-llvm-75118259bac43e6d3a28fdcc86c15c296c75806a.zip |
Do not initialize Out<ELFT>::Opd until needed.
This change makes it clear that we need the variable only within
writeSections.
llvm-svn: 278083
-rw-r--r-- | lld/ELF/Writer.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7392480a2b8..9f0304aea98 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -664,11 +664,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() { // Create output sections for input object file sections. std::vector<OutputSectionBase<ELFT> *> RegularSections = OutputSections; - // If we have a .opd section (used under PPC64 for function descriptors), - // store a pointer to it here so that we can use it later when processing - // relocations. - Out<ELFT>::Opd = Factory.lookup(".opd", SHT_PROGBITS, SHF_WRITE | SHF_ALLOC); - Out<ELFT>::Dynamic->PreInitArraySec = Factory.lookup( ".preinit_array", SHT_PREINIT_ARRAY, SHF_WRITE | SHF_ALLOC); Out<ELFT>::Dynamic->InitArraySec = @@ -1248,11 +1243,12 @@ template <class ELFT> void Writer<ELFT>::openFile() { template <class ELFT> void Writer<ELFT>::writeSections() { uint8_t *Buf = Buffer->getBufferStart(); - // PPC64 needs to process relocations in the .opd section before processing - // relocations in code-containing sections. - if (OutputSectionBase<ELFT> *Sec = Out<ELFT>::Opd) { - Out<ELFT>::OpdBuf = Buf + Sec->getFileOff(); - Sec->writeTo(Buf + Sec->getFileOff()); + // PPC64 needs to process relocations in the .opd section + // before processing relocations in code-containing sections. + Out<ELFT>::Opd = Factory.lookup(".opd", SHT_PROGBITS, SHF_WRITE | SHF_ALLOC); + if (Out<ELFT>::Opd) { + Out<ELFT>::OpdBuf = Buf + Out<ELFT>::Opd->getFileOff(); + Out<ELFT>::Opd->writeTo(Buf + Out<ELFT>::Opd->getFileOff()); } for (OutputSectionBase<ELFT> *Sec : OutputSections) |