[lld] r234820 - ELF: Remove useless templates that takes always the same ELF type.
Rui Ueyama
ruiu at google.com
Mon Apr 13 17:08:09 PDT 2015
Author: ruiu
Date: Mon Apr 13 19:08:09 2015
New Revision: 234820
URL: http://llvm.org/viewvc/llvm-project?rev=234820&view=rev
Log:
ELF: Remove useless templates that takes always the same ELF type.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h?rev=234820&r1=234819&r2=234820&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h Mon Apr 13 19:08:09 2015
@@ -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())
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h?rev=234820&r1=234819&r2=234820&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h Mon Apr 13 19:08:09 2015
@@ -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
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h?rev=234820&r1=234819&r2=234820&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h Mon Apr 13 19:08:09 2015
@@ -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>::crea
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_");
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h?rev=234820&r1=234819&r2=234820&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h Mon Apr 13 19:08:09 2015
@@ -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
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=234820&r1=234819&r2=234820&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Mon Apr 13 19:08:09 2015
@@ -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:
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h?rev=234820&r1=234819&r2=234820&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Mon Apr 13 19:08:09 2015
@@ -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<
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
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)
More information about the llvm-commits
mailing list