From 06a4039572b6c0e2d1dec87a50fb2b8a42432967 Mon Sep 17 00:00:00 2001 From: Shankar Easwaran Date: Wed, 20 Mar 2013 05:06:40 +0000 Subject: [PATCH] [ELF] Interp section is only needed in dynamic executables llvm-svn: 177483 --- lld/lib/ReaderWriter/ELF/ExecutableWriter.h | 18 ++++++++++++++---- lld/lib/ReaderWriter/ELF/OutputELFWriter.h | 5 ----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/ExecutableWriter.h b/lld/lib/ReaderWriter/ELF/ExecutableWriter.h index 60dbcb27..fc0bde0 100644 --- a/lld/lib/ReaderWriter/ELF/ExecutableWriter.h +++ b/lld/lib/ReaderWriter/ELF/ExecutableWriter.h @@ -31,9 +31,10 @@ public: private: virtual void addDefaultAtoms(); - virtual void addFiles(InputFiles&); + virtual void addFiles(InputFiles &); virtual void finalizeDefaultAtomValues(); - + virtual void createDefaultSections(); + LLD_UNIQUE_BUMP_PTR(InterpSection) _interpSection; CRuntimeFile _runtimeFile; }; @@ -69,10 +70,19 @@ void ExecutableWriter::addFiles(InputFiles &inputFiles) { this->_targetHandler.addFiles(inputFiles); } +template void ExecutableWriter::createDefaultSections() { + OutputELFWriter::createDefaultSections(); + if (this->_targetInfo.isDynamic()) { + _interpSection.reset(new (this->_alloc) InterpSection( + this->_targetInfo, ".interp", DefaultLayout::ORDER_INTERP, + this->_targetInfo.getInterpreter())); + this->_layout->addSection(_interpSection.get()); + } +} + /// Finalize the value of all the absolute symbols that we /// created -template -void ExecutableWriter::finalizeDefaultAtomValues() { +template void ExecutableWriter::finalizeDefaultAtomValues() { auto bssStartAtomIter = this->_layout->findAbsoluteAtom("__bss_start"); auto bssEndAtomIter = this->_layout->findAbsoluteAtom("__bss_end"); auto underScoreEndAtomIter = this->_layout->findAbsoluteAtom("_end"); diff --git a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h index 5f8e52b..d2850ad 100644 --- a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h +++ b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h @@ -109,7 +109,6 @@ protected: LLD_UNIQUE_BUMP_PTR(DynamicTable) _dynamicTable; LLD_UNIQUE_BUMP_PTR(DynamicSymbolTable) _dynamicSymbolTable; LLD_UNIQUE_BUMP_PTR(StringTable) _dynamicStringTable; - LLD_UNIQUE_BUMP_PTR(InterpSection) _interpSection; LLD_UNIQUE_BUMP_PTR(HashSection) _hashTable; llvm::StringSet<> _soNeeded; /// @} @@ -226,15 +225,11 @@ void OutputELFWriter::createDefaultSections() { true)); _dynamicSymbolTable.reset(new (_alloc) DynamicSymbolTable( _targetInfo, ".dynsym", DefaultLayout::ORDER_DYNAMIC_SYMBOLS)); - _interpSection.reset(new (_alloc) InterpSection( - _targetInfo, ".interp", DefaultLayout::ORDER_INTERP, - _targetInfo.getInterpreter())); _hashTable.reset(new (_alloc) HashSection( _targetInfo, ".hash", DefaultLayout::ORDER_HASH)); _layout->addSection(_dynamicTable.get()); _layout->addSection(_dynamicStringTable.get()); _layout->addSection(_dynamicSymbolTable.get()); - _layout->addSection(_interpSection.get()); _layout->addSection(_hashTable.get()); _dynamicSymbolTable->setStringSection(_dynamicStringTable.get()); if (_layout->hasDynamicRelocationTable()) -- 2.7.4