[lld] r233748 - ELF: Remove TargetHandler::getTargetLayout.
Rui Ueyama
ruiu at google.com
Tue Mar 31 13:31:48 PDT 2015
Author: ruiu
Date: Tue Mar 31 15:31:48 2015
New Revision: 233748
URL: http://llvm.org/viewvc/llvm-project?rev=233748&view=rev
Log:
ELF: Remove TargetHandler::getTargetLayout.
Only MIPS used that member function, and by removing the use of the
function, I removed a static_cast. Seems like it's a win.
Modified:
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h Tue Mar 31 15:31:48 2015
@@ -30,10 +30,6 @@ class AArch64TargetHandler final : publi
public:
AArch64TargetHandler(AArch64LinkingContext &ctx);
- AArch64TargetLayout<AArch64ELFType> &getTargetLayout() override {
- return *_aarch64TargetLayout;
- }
-
void registerRelocationNames(Registry ®istry) override;
const AArch64TargetRelocationHandler &getRelocationHandler() const override {
Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h Tue Mar 31 15:31:48 2015
@@ -64,10 +64,6 @@ class ARMTargetHandler final : public De
public:
ARMTargetHandler(ARMLinkingContext &ctx);
- ARMTargetLayout<ARMELFType> &getTargetLayout() override {
- return *_armTargetLayout;
- }
-
void registerRelocationNames(Registry ®istry) override;
const ARMTargetRelocationHandler &getRelocationHandler() const override {
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=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Tue Mar 31 15:31:48 2015
@@ -113,10 +113,6 @@ public:
return *_relocationHandler;
}
- HexagonTargetLayout<HexagonELFType> &getTargetLayout() override {
- return *_targetLayout;
- }
-
std::unique_ptr<Reader> getObjReader() override {
return llvm::make_unique<HexagonELFObjectReader>(_ctx);
}
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Tue Mar 31 15:31:48 2015
@@ -32,7 +32,8 @@ struct MipsRelocationParams {
template <class ELFT> class RelocationHandler : public MipsRelocationHandler {
public:
- RelocationHandler(MipsLinkingContext &ctx) : _ctx(ctx) {}
+ RelocationHandler(MipsLinkingContext &ctx, MipsTargetLayout<ELFT> &layout)
+ : _ctx(ctx), _targetLayout(layout) {}
std::error_code applyRelocation(ELFWriter &writer,
llvm::FileOutputBuffer &buf,
@@ -44,6 +45,7 @@ public:
private:
MipsLinkingContext &_ctx;
+ MipsTargetLayout<ELFT> &_targetLayout;
};
}
@@ -530,13 +532,10 @@ std::error_code RelocationHandler<ELFT>:
return std::error_code();
assert(ref.kindArch() == Reference::KindArch::Mips);
- auto &targetLayout = static_cast<MipsTargetLayout<ELFT> &>(
- _ctx.getTargetHandler<ELFT>().getTargetLayout());
-
- AtomLayout *gpAtom = targetLayout.getGP();
+ AtomLayout *gpAtom = _targetLayout.getGP();
uint64_t gpAddr = gpAtom ? gpAtom->_virtualAddr : 0;
- AtomLayout *gpDispAtom = targetLayout.getGPDisp();
+ AtomLayout *gpDispAtom = _targetLayout.getGPDisp();
bool isGpDisp = gpDispAtom && ref.target() == gpDispAtom->_atom;
uint8_t *atomContent = buf.getBufferStart() + atom._fileOffset;
@@ -598,14 +597,16 @@ namespace elf {
template <>
std::unique_ptr<TargetRelocationHandler>
-createMipsRelocationHandler<Mips32ELType>(MipsLinkingContext &ctx) {
- return llvm::make_unique<RelocationHandler<Mips32ELType>>(ctx);
+createMipsRelocationHandler<Mips32ELType>(MipsLinkingContext &ctx,
+ MipsTargetLayout<Mips32ELType> &layout) {
+ return llvm::make_unique<RelocationHandler<Mips32ELType>>(ctx, layout);
}
template <>
std::unique_ptr<TargetRelocationHandler>
-createMipsRelocationHandler<Mips64ELType>(MipsLinkingContext &ctx) {
- return llvm::make_unique<RelocationHandler<Mips64ELType>>(ctx);
+createMipsRelocationHandler<Mips64ELType>(MipsLinkingContext &ctx,
+ MipsTargetLayout<Mips64ELType> &layout) {
+ return llvm::make_unique<RelocationHandler<Mips64ELType>>(ctx, layout);
}
} // elf
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h Tue Mar 31 15:31:48 2015
@@ -15,6 +15,8 @@
namespace lld {
namespace elf {
+template<typename ELFT> class MipsTargetLayout;
+
class MipsRelocationHandler : public TargetRelocationHandler {
public:
virtual Reference::Addend readAddend(Reference::KindValue kind,
@@ -23,7 +25,7 @@ public:
template <class ELFT>
std::unique_ptr<TargetRelocationHandler>
-createMipsRelocationHandler(MipsLinkingContext &ctx);
+createMipsRelocationHandler(MipsLinkingContext &ctx, MipsTargetLayout<ELFT> &layout);
} // elf
} // lld
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Tue Mar 31 15:31:48 2015
@@ -110,9 +110,7 @@ public:
MipsTargetHandler(MipsLinkingContext &ctx)
: _ctx(ctx), _runtimeFile(new MipsRuntimeFile<ELFT>(ctx)),
_targetLayout(new MipsTargetLayout<ELFT>(ctx)),
- _relocationHandler(createMipsRelocationHandler<ELFT>(ctx)) {}
-
- MipsTargetLayout<ELFT> &getTargetLayout() override { return *_targetLayout; }
+ _relocationHandler(createMipsRelocationHandler<ELFT>(ctx, *_targetLayout)) {}
std::unique_ptr<Reader> getObjReader() override {
return llvm::make_unique<MipsELFObjectReader<ELFT>>(_ctx);
Modified: lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h Tue Mar 31 15:31:48 2015
@@ -54,9 +54,6 @@ public:
/// of creating atoms and how the atoms are written to the output file.
template <class ELFT> class TargetHandler : public TargetHandlerBase {
public:
- /// The layout determined completely by the Target.
- virtual TargetLayout<ELFT> &getTargetLayout() = 0;
-
/// Determine how relocations need to be applied.
virtual const TargetRelocationHandler &getRelocationHandler() const = 0;
Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h Tue Mar 31 15:31:48 2015
@@ -31,10 +31,6 @@ class X86TargetHandler final
public:
X86TargetHandler(X86LinkingContext &ctx);
- X86TargetLayout<X86ELFType> &getTargetLayout() override {
- return *_x86TargetLayout;
- }
-
void registerRelocationNames(Registry ®istry) override;
const X86TargetRelocationHandler &getRelocationHandler() const override {
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h?rev=233748&r1=233747&r2=233748&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h Tue Mar 31 15:31:48 2015
@@ -35,10 +35,6 @@ class X86_64TargetHandler
public:
X86_64TargetHandler(X86_64LinkingContext &ctx);
- X86_64TargetLayout &getTargetLayout() override {
- return *_x86_64TargetLayout;
- }
-
void registerRelocationNames(Registry ®istry) override;
const X86_64TargetRelocationHandler &getRelocationHandler() const override {
More information about the llvm-commits
mailing list