diff options
| author | Denis Protivensky <dprotivensky@accesssoftek.com> | 2015-05-21 10:11:27 +0000 |
|---|---|---|
| committer | Denis Protivensky <dprotivensky@accesssoftek.com> | 2015-05-21 10:11:27 +0000 |
| commit | 30e40be080d34053409dae2ba5f85d1670ee8416 (patch) | |
| tree | 6b9d5591a316e815c16af4ffc4e9e485c3df1a79 | |
| parent | e0541993545643aad2a74cc4bdbe73197fe9f9f4 (diff) | |
| download | bcm5719-llvm-30e40be080d34053409dae2ba5f85d1670ee8416.tar.gz bcm5719-llvm-30e40be080d34053409dae2ba5f85d1670ee8416.zip | |
[ELF] Move start/end atom method assignment to OutputELFWriter. NFC
llvm-svn: 237886
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/ExecutableWriter.h | 30 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/OutputELFWriter.cpp | 20 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/OutputELFWriter.h | 3 |
3 files changed, 28 insertions, 25 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ExecutableWriter.h b/lld/lib/ReaderWriter/ELF/ExecutableWriter.h index 3bb2d7a5210..9d9f4d9ce0a 100644 --- a/lld/lib/ReaderWriter/ELF/ExecutableWriter.h +++ b/lld/lib/ReaderWriter/ELF/ExecutableWriter.h @@ -26,7 +26,6 @@ public: : OutputELFWriter<ELFT>(ctx, layout) {} protected: - void updateScopeAtomValues(StringRef sym, StringRef sec); void buildDynamicSymbolTable(const File &file) override; void createImplicitFiles(std::vector<std::unique_ptr<File>> &) override; void finalizeDefaultAtomValues() override; @@ -45,25 +44,6 @@ private: //===----------------------------------------------------------------------===// // ExecutableWriter //===----------------------------------------------------------------------===// -template <class ELFT> -void ExecutableWriter<ELFT>::updateScopeAtomValues(StringRef sym, - StringRef sec) { - std::string start = ("__" + sym + "_start").str(); - std::string end = ("__" + sym + "_end").str(); - AtomLayout *s = this->_layout.findAbsoluteAtom(start); - AtomLayout *e = this->_layout.findAbsoluteAtom(end); - OutputSection<ELFT> *section = this->_layout.findOutputSection(sec); - if (!s || !e) - return; - if (section) { - s->_virtualAddr = section->virtualAddr(); - e->_virtualAddr = section->virtualAddr() + section->memSize(); - } else { - s->_virtualAddr = 0; - e->_virtualAddr = 0; - } -} - template<class ELFT> void ExecutableWriter<ELFT>::buildDynamicSymbolTable(const File &file) { for (auto sec : this->_layout.sections()) @@ -147,13 +127,13 @@ template <class ELFT> void ExecutableWriter<ELFT>::finalizeDefaultAtomValues() { assert((bssStartAtom || bssEndAtom || underScoreEndAtom || endAtom) && "Unable to find the absolute atoms that have been added by lld"); - updateScopeAtomValues("preinit_array", ".preinit_array"); - updateScopeAtomValues("init_array", ".init_array"); + this->updateScopeAtomValues("preinit_array", ".preinit_array"); + this->updateScopeAtomValues("init_array", ".init_array"); if (this->_ctx.isRelaOutputFormat()) - updateScopeAtomValues("rela_iplt", ".rela.plt"); + this->updateScopeAtomValues("rela_iplt", ".rela.plt"); else - updateScopeAtomValues("rel_iplt", ".rel.plt"); - updateScopeAtomValues("fini_array", ".fini_array"); + this->updateScopeAtomValues("rel_iplt", ".rel.plt"); + this->updateScopeAtomValues("fini_array", ".fini_array"); auto bssSection = this->_layout.findOutputSection(".bss"); diff --git a/lld/lib/ReaderWriter/ELF/OutputELFWriter.cpp b/lld/lib/ReaderWriter/ELF/OutputELFWriter.cpp index a8487406911..6441790ac57 100644 --- a/lld/lib/ReaderWriter/ELF/OutputELFWriter.cpp +++ b/lld/lib/ReaderWriter/ELF/OutputELFWriter.cpp @@ -447,6 +447,26 @@ std::error_code OutputELFWriter<ELFT>::writeFile(const File &file, return writeOutput(file, path); } +template <class ELFT> +void OutputELFWriter<ELFT>::updateScopeAtomValues(StringRef sym, + StringRef sec) { + std::string start = ("__" + sym + "_start").str(); + std::string end = ("__" + sym + "_end").str(); + AtomLayout *s = _layout.findAbsoluteAtom(start); + AtomLayout *e = _layout.findAbsoluteAtom(end); + OutputSection<ELFT> *section = _layout.findOutputSection(sec); + if (!s || !e) + return; + + if (section) { + s->_virtualAddr = section->virtualAddr(); + e->_virtualAddr = section->virtualAddr() + section->memSize(); + } else { + s->_virtualAddr = 0; + e->_virtualAddr = 0; + } +} + template class OutputELFWriter<ELF32LE>; template class OutputELFWriter<ELF32BE>; template class OutputELFWriter<ELF64LE>; diff --git a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h index d48223aba8d..c7909f5f75d 100644 --- a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h +++ b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h @@ -115,6 +115,9 @@ protected: virtual void processUndefinedSymbol(StringRef symName, RuntimeFile<ELFT> &file) const {} + /// \brief Assign addresses to atoms marking section's start and end. + void updateScopeAtomValues(StringRef sym, StringRef sec); + llvm::BumpPtrAllocator _alloc; ELFLinkingContext &_ctx; |

