diff options
6 files changed, 39 insertions, 48 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h index b703ad68afb..b23540a722e 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h @@ -16,13 +16,12 @@ namespace lld { namespace elf { -template <typename ELFT> class HexagonTargetLayout; +class HexagonTargetLayout; -template <class ELFT> class HexagonDynamicLibraryWriter : public DynamicLibraryWriter<ELFT> { public: HexagonDynamicLibraryWriter(HexagonLinkingContext &ctx, - HexagonTargetLayout<ELFT> &layout); + HexagonTargetLayout &layout); protected: // Add any runtime files and their atoms to the output @@ -38,28 +37,25 @@ protected: private: HexagonLinkingContext &_ctx; - HexagonTargetLayout<ELFT> &_targetLayout; + HexagonTargetLayout &_targetLayout; }; -template <class ELFT> -HexagonDynamicLibraryWriter<ELFT>::HexagonDynamicLibraryWriter( - HexagonLinkingContext &ctx, HexagonTargetLayout<ELFT> &layout) +HexagonDynamicLibraryWriter::HexagonDynamicLibraryWriter( + HexagonLinkingContext &ctx, HexagonTargetLayout &layout) : DynamicLibraryWriter<ELFT>(ctx, layout), _ctx(ctx), _targetLayout(layout) {} -template <class ELFT> -void HexagonDynamicLibraryWriter<ELFT>::createImplicitFiles( +void HexagonDynamicLibraryWriter::createImplicitFiles( std::vector<std::unique_ptr<File>> &result) { DynamicLibraryWriter<ELFT>::createImplicitFiles(result); // Add the default atoms as defined for hexagon - auto file = llvm::make_unique<HexagonRuntimeFile<ELFT>>(_ctx); + auto file = llvm::make_unique<HexagonRuntimeFile>(_ctx); file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"); file->addAbsoluteAtom("_DYNAMIC"); result.push_back(std::move(file)); } -template <class ELFT> -void HexagonDynamicLibraryWriter<ELFT>::finalizeDefaultAtomValues() { +void HexagonDynamicLibraryWriter::finalizeDefaultAtomValues() { // Finalize the atom values that are part of the parent. DynamicLibraryWriter<ELFT>::finalizeDefaultAtomValues(); if (_ctx.isDynamic()) diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h index d0280c0147f..42fbdd6936d 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h @@ -13,12 +13,14 @@ #include "ELFFile.h" namespace lld { +class ELFLinkingContext; + namespace elf { -class HexagonLinkingContext; +typedef llvm::object::ELFType<llvm::support::little, 2, false> ELFT; -template <class ELFT> class HexagonRuntimeFile : public RuntimeFile<ELFT> { +class HexagonRuntimeFile : public RuntimeFile<ELFT> { public: - HexagonRuntimeFile(HexagonLinkingContext &ctx) + HexagonRuntimeFile(ELFLinkingContext &ctx) : RuntimeFile<ELFT>(ctx, "Hexagon runtime file") {} }; } // elf diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h index af1dd21f8df..ee6d4c98ec1 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h @@ -12,17 +12,17 @@ #include "ExecutableWriter.h" #include "HexagonExecutableAtoms.h" #include "HexagonLinkingContext.h" +#include "HexagonTargetHandler.h" namespace lld { namespace elf { -template <typename ELFT> class HexagonTargetLayout; +class HexagonTargetLayout; -template <class ELFT> class HexagonExecutableWriter : public ExecutableWriter<ELFT> { public: HexagonExecutableWriter(HexagonLinkingContext &ctx, - HexagonTargetLayout<ELFT> &layout); + HexagonTargetLayout &layout); protected: // Add any runtime files and their atoms to the output @@ -38,20 +38,18 @@ protected: private: HexagonLinkingContext &_ctx; - HexagonTargetLayout<ELFT> &_targetLayout; + HexagonTargetLayout &_targetLayout; }; -template <class ELFT> -HexagonExecutableWriter<ELFT>::HexagonExecutableWriter( - HexagonLinkingContext &ctx, HexagonTargetLayout<ELFT> &layout) +HexagonExecutableWriter::HexagonExecutableWriter(HexagonLinkingContext &ctx, + HexagonTargetLayout &layout) : ExecutableWriter<ELFT>(ctx, layout), _ctx(ctx), _targetLayout(layout) {} -template <class ELFT> -void HexagonExecutableWriter<ELFT>::createImplicitFiles( +void HexagonExecutableWriter::createImplicitFiles( std::vector<std::unique_ptr<File>> &result) { ExecutableWriter<ELFT>::createImplicitFiles(result); // Add the default atoms as defined for hexagon - auto file = llvm::make_unique<HexagonRuntimeFile<ELFT>>(_ctx); + auto file = llvm::make_unique<HexagonRuntimeFile>(_ctx); file->addAbsoluteAtom("_SDA_BASE_"); if (this->_ctx.isDynamic()) { file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"); @@ -60,8 +58,7 @@ void HexagonExecutableWriter<ELFT>::createImplicitFiles( result.push_back(std::move(file)); } -template <class ELFT> -void HexagonExecutableWriter<ELFT>::finalizeDefaultAtomValues() { +void HexagonExecutableWriter::finalizeDefaultAtomValues() { // Finalize the atom values that are part of the parent. ExecutableWriter<ELFT>::finalizeDefaultAtomValues(); AtomLayout *sdabaseAtom = _targetLayout.findAbsoluteAtom("_SDA_BASE_"); diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h index e09a9dbfe25..15c9a6ce8de 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h @@ -14,13 +14,13 @@ namespace lld { namespace elf { class HexagonTargetHandler; -template <class ELFT> class HexagonTargetLayout; +class HexagonTargetLayout; typedef llvm::object::ELFType<llvm::support::little, 2, false> HexagonELFType; class HexagonTargetRelocationHandler final : public TargetRelocationHandler { public: - HexagonTargetRelocationHandler(HexagonTargetLayout<HexagonELFType> &layout) + HexagonTargetRelocationHandler(HexagonTargetLayout &layout) : _targetLayout(layout) {} std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, @@ -28,7 +28,7 @@ public: const Reference &) const override; private: - HexagonTargetLayout<HexagonELFType> &_targetLayout; + HexagonTargetLayout &_targetLayout; }; } // elf } // lld diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp index b69bc946e5f..1fe523a2eb4 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp @@ -19,18 +19,16 @@ using namespace llvm::ELF; using llvm::makeArrayRef; HexagonTargetHandler::HexagonTargetHandler(HexagonLinkingContext &ctx) - : _ctx(ctx), _runtimeFile(new HexagonRuntimeFile<HexagonELFType>(ctx)), - _targetLayout(new HexagonTargetLayout<HexagonELFType>(ctx)), + : _ctx(ctx), _runtimeFile(new HexagonRuntimeFile(ctx)), + _targetLayout(new HexagonTargetLayout(ctx)), _relocationHandler(new HexagonTargetRelocationHandler(*_targetLayout)) {} std::unique_ptr<Writer> HexagonTargetHandler::getWriter() { switch (_ctx.getOutputELFType()) { case llvm::ELF::ET_EXEC: - return llvm::make_unique<HexagonExecutableWriter<HexagonELFType>>( - _ctx, *_targetLayout); + return llvm::make_unique<HexagonExecutableWriter>(_ctx, *_targetLayout); case llvm::ELF::ET_DYN: - return llvm::make_unique<HexagonDynamicLibraryWriter<HexagonELFType>>( - _ctx, *_targetLayout); + return llvm::make_unique<HexagonDynamicLibraryWriter>(_ctx, *_targetLayout); case llvm::ELF::ET_REL: llvm_unreachable("TODO: support -r mode"); default: diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h index a1b7d34c4f7..2e09186fbc7 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h @@ -37,7 +37,6 @@ public: }; /// \brief TargetLayout for Hexagon -template <class ELFT> class HexagonTargetLayout final : public TargetLayout<ELFT> { public: enum HexagonSectionOrder { @@ -50,7 +49,7 @@ public: } /// \brief Return the section order for a input section - typename TargetLayout<ELFT>::SectionOrder + TargetLayout<ELFT>::SectionOrder getSectionOrder(StringRef name, int32_t contentType, int32_t contentPermissions) override { if ((contentType == DefinedAtom::typeDataFast) || @@ -74,10 +73,10 @@ public: } /// \brief Gets or creates a section. - AtomSection<ELFT> *createSection( - StringRef name, int32_t contentType, - DefinedAtom::ContentPermissions contentPermissions, - typename TargetLayout<ELFT>::SectionOrder sectionOrder) override { + AtomSection<ELFT> * + createSection(StringRef name, int32_t contentType, + DefinedAtom::ContentPermissions contentPermissions, + TargetLayout<ELFT>::SectionOrder sectionOrder) override { if ((contentType == DefinedAtom::typeDataFast) || (contentType == DefinedAtom::typeZeroFillFast)) return _sdataSection; @@ -86,7 +85,7 @@ public: } /// \brief get the segment type for the section thats defined by the target - typename TargetLayout<ELFT>::SegmentType + TargetLayout<ELFT>::SegmentType getSegmentType(Section<ELFT> *section) const override { if (section->order() == ORDER_SDATA) return PT_LOAD; @@ -136,8 +135,8 @@ public: private: HexagonLinkingContext &_ctx; - std::unique_ptr<HexagonRuntimeFile<ELFT>> _runtimeFile; - std::unique_ptr<HexagonTargetLayout<ELFT>> _targetLayout; + std::unique_ptr<HexagonRuntimeFile> _runtimeFile; + std::unique_ptr<HexagonTargetLayout> _targetLayout; std::unique_ptr<HexagonTargetRelocationHandler> _relocationHandler; }; @@ -174,7 +173,7 @@ template <class ELFT> void SDataSection<ELFT>::doPreFlight() { template <class ELFT> SDataSection<ELFT>::SDataSection(const HexagonLinkingContext &ctx) : AtomSection<ELFT>(ctx, ".sdata", DefinedAtom::typeDataFast, 0, - HexagonTargetLayout<ELFT>::ORDER_SDATA) { + HexagonTargetLayout::ORDER_SDATA) { this->_type = SHT_PROGBITS; this->_flags = SHF_ALLOC | SHF_WRITE; this->_alignment = 4096; @@ -193,8 +192,7 @@ const lld::AtomLayout *SDataSection<ELFT>::appendAtom(const Atom *atom) { return (this->_atoms.back()); } -template <class ELFT> -void finalizeHexagonRuntimeAtomValues(HexagonTargetLayout<ELFT> &layout) { +inline void finalizeHexagonRuntimeAtomValues(HexagonTargetLayout &layout) { AtomLayout *gotAtom = layout.findAbsoluteAtom("_GLOBAL_OFFSET_TABLE_"); OutputSection<ELFT> *gotpltSection = layout.findOutputSection(".got.plt"); if (gotpltSection) |

