[lld] r233883 - ELF: Move registerRelocationNames() from TargetHandler to <Arch>ELFLinkingContext.
Shankar Easwaran
shankare at codeaurora.org
Thu Apr 2 10:03:21 PDT 2015
LinkingContext is only a way to say what and how to link.
I think moving relocation types / architecture definitions to the
linking context is not a good approach here, no ??
If you see MachO, even MachO uses a similar design by having all the
relocation kind strings in the ArchHandler and not in the linking context.
Shankar Easwaran
On 4/1/2015 11:18 PM, Rui Ueyama wrote:
> Author: ruiu
> Date: Wed Apr 1 23:18:54 2015
> New Revision: 233883
>
> URL: http://llvm.org/viewvc/llvm-project?rev=233883&view=rev
> Log:
> ELF: Move registerRelocationNames() from TargetHandler to <Arch>ELFLinkingContext.
>
> registerRelocationNames() function is called to register all known
> ELF relocation types to the central registry. Since we have separate
> LinkingContext class for each ELF machine type, we need to call the
> function for each LinkingContext.
>
> However, the function belonged to TargetHandler instead of LinkingContext.
> So we needed to do ctx.getTargetHandler().registerRelocationNames().
> This patch removes that redundant getTargetHandler call by moving the
> function from TargetHandler to LinkingContext.
>
> Conceptually this patch is small, but in reality it's not that small.
> It's because the same code is copied to each architecture.
> Most of this patch is just repetition. We need to merge them, but
> that cannot be done in this patch.
>
> Removed:
> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp
> Modified:
> lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
> lld/trunk/include/lld/ReaderWriter/ELFTargets.h
> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp
> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h
> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp
> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h
> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp
> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h
> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
> lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h
> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
> lld/trunk/lib/ReaderWriter/ELF/Reader.cpp
> lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp
> lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h
> lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp
> lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h
> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
>
> Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
> +++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -55,7 +55,6 @@ public:
> class TargetHandler {
> public:
> virtual ~TargetHandler() {}
> - virtual void registerRelocationNames(Registry &) = 0;
>
> /// Determines how relocations need to be applied.
> virtual const elf::TargetRelocationHandler &getRelocationHandler() const = 0;
> @@ -173,6 +172,8 @@ public:
> return *_targetHandler;
> }
>
> + virtual void registerRelocationNames(Registry &) = 0;
> +
> void addPasses(PassManager &pm) override;
>
> void setTriple(llvm::Triple trip) { _triple = trip; }
>
> Modified: lld/trunk/include/lld/ReaderWriter/ELFTargets.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFTargets.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/ELFTargets.h (original)
> +++ lld/trunk/include/lld/ReaderWriter/ELFTargets.h Wed Apr 1 23:18:54 2015
> @@ -16,7 +16,7 @@ namespace lld {
> namespace elf {
>
> #define LLVM_TARGET(TargetName) \
> - class TargetName##LinkingContext final : public ELFLinkingContext { \
> + class TargetName##LinkingContext : public ELFLinkingContext { \
> public: \
> static std::unique_ptr<ELFLinkingContext> create(llvm::Triple); \
> };
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp Wed Apr 1 23:18:54 2015
> @@ -12,21 +12,34 @@
> #include "AArch64TargetHandler.h"
>
> using namespace lld;
> +using namespace lld::elf;
>
> std::unique_ptr<ELFLinkingContext>
> -elf::AArch64LinkingContext::create(llvm::Triple triple) {
> +AArch64LinkingContext::create(llvm::Triple triple) {
> if (triple.getArch() == llvm::Triple::aarch64)
> - return llvm::make_unique<elf::AArch64LinkingContext>(triple);
> + return llvm::make_unique<AArch64LinkingContext>(triple);
> return nullptr;
> }
>
> -elf::AArch64LinkingContext::AArch64LinkingContext(llvm::Triple triple)
> +AArch64LinkingContext::AArch64LinkingContext(llvm::Triple triple)
> : ELFLinkingContext(triple, std::unique_ptr<TargetHandler>(
> new AArch64TargetHandler(*this))) {}
>
> -void elf::AArch64LinkingContext::addPasses(PassManager &pm) {
> +void AArch64LinkingContext::addPasses(PassManager &pm) {
> auto pass = createAArch64RelocationPass(*this);
> if (pass)
> pm.add(std::move(pass));
> ELFLinkingContext::addPasses(pm);
> }
> +
> +static const Registry::KindStrings kindStrings[] = {
> +#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> +#include "llvm/Support/ELFRelocs/AArch64.def"
> +#undef ELF_RELOC
> + LLD_KIND_STRING_END
> +};
> +
> +void AArch64LinkingContext::registerRelocationNames(Registry ®istry) {
> + registry.addKindTable(Reference::KindNamespace::ELF,
> + Reference::KindArch::AArch64, kindStrings);
> +}
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -28,6 +28,7 @@ public:
> AArch64LinkingContext(llvm::Triple);
>
> void addPasses(PassManager &) override;
> + void registerRelocationNames(Registry &r) override;
>
> uint64_t getBaseAddress() const override {
> if (_baseAddress == 0)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp Wed Apr 1 23:18:54 2015
> @@ -20,18 +20,6 @@ AArch64TargetHandler::AArch64TargetHandl
> : _ctx(ctx), _targetLayout(new TargetLayout<AArch64ELFType>(ctx)),
> _relocationHandler(new AArch64TargetRelocationHandler()) {}
>
> -static const Registry::KindStrings kindStrings[] = {
> -#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> -#include "llvm/Support/ELFRelocs/AArch64.def"
> -#undef ELF_RELOC
> - LLD_KIND_STRING_END
> -};
> -
> -void AArch64TargetHandler::registerRelocationNames(Registry ®istry) {
> - registry.addKindTable(Reference::KindNamespace::ELF,
> - Reference::KindArch::AArch64, kindStrings);
> -}
> -
> std::unique_ptr<Writer> AArch64TargetHandler::getWriter() {
> switch (this->_ctx.getOutputELFType()) {
> case llvm::ELF::ET_EXEC:
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h Wed Apr 1 23:18:54 2015
> @@ -24,8 +24,6 @@ class AArch64TargetHandler final : publi
> public:
> AArch64TargetHandler(AArch64LinkingContext &ctx);
>
> - void registerRelocationNames(Registry ®istry) override;
> -
> const AArch64TargetRelocationHandler &getRelocationHandler() const override {
> return *_relocationHandler;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp Wed Apr 1 23:18:54 2015
> @@ -11,39 +11,54 @@
> #include "ARMRelocationPass.h"
> #include "ARMTargetHandler.h"
>
> -using namespace lld;
> -using namespace lld::elf;
> +namespace lld {
> +namespace elf {
>
> std::unique_ptr<ELFLinkingContext>
> -elf::ARMLinkingContext::create(llvm::Triple triple) {
> +ARMLinkingContext::create(llvm::Triple triple) {
> if (triple.getArch() == llvm::Triple::arm)
> - return llvm::make_unique<elf::ARMLinkingContext>(triple);
> + return llvm::make_unique<ARMLinkingContext>(triple);
> return nullptr;
> }
>
> -elf::ARMLinkingContext::ARMLinkingContext(llvm::Triple triple)
> +ARMLinkingContext::ARMLinkingContext(llvm::Triple triple)
> : ELFLinkingContext(triple, llvm::make_unique<ARMTargetHandler>(*this)) {}
>
> -void elf::ARMLinkingContext::addPasses(PassManager &pm) {
> +void ARMLinkingContext::addPasses(PassManager &pm) {
> auto pass = createARMRelocationPass(*this);
> if (pass)
> pm.add(std::move(pass));
> ELFLinkingContext::addPasses(pm);
> }
>
> -bool elf::isARMCode(const DefinedAtom *atom) {
> +bool isARMCode(const DefinedAtom *atom) {
> return isARMCode(atom->codeModel());
> }
>
> -bool elf::isARMCode(DefinedAtom::CodeModel codeModel) {
> +bool isARMCode(DefinedAtom::CodeModel codeModel) {
> return !isThumbCode(codeModel);
> }
>
> -bool elf::isThumbCode(const DefinedAtom *atom) {
> +bool isThumbCode(const DefinedAtom *atom) {
> return isThumbCode(atom->codeModel());
> }
>
> -bool elf::isThumbCode(DefinedAtom::CodeModel codeModel) {
> +bool isThumbCode(DefinedAtom::CodeModel codeModel) {
> return codeModel == DefinedAtom::codeARMThumb ||
> codeModel == DefinedAtom::codeARM_t;
> }
> +
> +static const Registry::KindStrings kindStrings[] = {
> +#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> +#include "llvm/Support/ELFRelocs/ARM.def"
> +#undef ELF_RELOC
> + LLD_KIND_STRING_END
> +};
> +
> +void ARMLinkingContext::registerRelocationNames(Registry ®istry) {
> + registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM,
> + kindStrings);
> +}
> +
> +} // namespace elf
> +} // namespace lld
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -22,9 +22,10 @@ public:
> static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
> ARMLinkingContext(llvm::Triple);
>
> - bool isRelaOutputFormat() const override { return false; }
> -
> void addPasses(PassManager &) override;
> + void registerRelocationNames(Registry &r) override;
> +
> + bool isRelaOutputFormat() const override { return false; }
>
> uint64_t getBaseAddress() const override {
> if (_baseAddress == 0)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp Wed Apr 1 23:18:54 2015
> @@ -19,18 +19,6 @@ ARMTargetHandler::ARMTargetHandler(ARMLi
> : _ctx(ctx), _targetLayout(new ARMTargetLayout<ARMELFType>(ctx)),
> _relocationHandler(new ARMTargetRelocationHandler(*_targetLayout)) {}
>
> -static const Registry::KindStrings kindStrings[] = {
> -#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> -#include "llvm/Support/ELFRelocs/ARM.def"
> -#undef ELF_RELOC
> - LLD_KIND_STRING_END
> -};
> -
> -void ARMTargetHandler::registerRelocationNames(Registry ®istry) {
> - registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::ARM,
> - kindStrings);
> -}
> -
> std::unique_ptr<Writer> ARMTargetHandler::getWriter() {
> switch (this->_ctx.getOutputELFType()) {
> case llvm::ELF::ET_EXEC:
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h Wed Apr 1 23:18:54 2015
> @@ -61,8 +61,6 @@ class ARMTargetHandler final : public Ta
> public:
> ARMTargetHandler(ARMLinkingContext &ctx);
>
> - void registerRelocationNames(Registry ®istry) override;
> -
> const ARMTargetRelocationHandler &getRelocationHandler() const override {
> return *_relocationHandler;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp Wed Apr 1 23:18:54 2015
> @@ -10,6 +10,7 @@
> #include "HexagonLinkingContext.h"
> #include "HexagonTargetHandler.h"
>
> +using namespace lld;
> using namespace lld::elf;
>
> std::unique_ptr<lld::ELFLinkingContext>
> @@ -22,3 +23,15 @@ HexagonLinkingContext::create(llvm::Trip
> HexagonLinkingContext::HexagonLinkingContext(llvm::Triple triple)
> : ELFLinkingContext(triple, std::unique_ptr<TargetHandler>(
> new HexagonTargetHandler(*this))) {}
> +
> +static const Registry::KindStrings kindStrings[] = {
> +#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> +#include "llvm/Support/ELFRelocs/Hexagon.def"
> +#undef ELF_RELOC
> + LLD_KIND_STRING_END
> +};
> +
> +void HexagonLinkingContext::registerRelocationNames(Registry ®istry) {
> + registry.addKindTable(Reference::KindNamespace::ELF,
> + Reference::KindArch::Hexagon, kindStrings);
> +}
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -26,6 +26,7 @@ public:
> HexagonLinkingContext(llvm::Triple triple);
>
> void addPasses(PassManager &) override;
> + void registerRelocationNames(Registry &r) override;
>
> bool isDynamicRelocation(const Reference &r) const override {
> if (r.kindNamespace() != Reference::KindNamespace::ELF)
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Wed Apr 1 23:18:54 2015
> @@ -313,15 +313,3 @@ void elf::HexagonLinkingContext::addPass
> pm.add(llvm::make_unique<DynamicGOTPLTPass>(*this));
> ELFLinkingContext::addPasses(pm);
> }
> -
> -static const Registry::KindStrings kindStrings[] = {
> -#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> -#include "llvm/Support/ELFRelocs/Hexagon.def"
> -#undef ELF_RELOC
> - LLD_KIND_STRING_END
> -};
> -
> -void HexagonTargetHandler::registerRelocationNames(Registry ®istry) {
> - registry.addKindTable(Reference::KindNamespace::ELF,
> - Reference::KindArch::Hexagon, kindStrings);
> -}
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Wed Apr 1 23:18:54 2015
> @@ -100,8 +100,6 @@ class HexagonTargetHandler final : publi
> public:
> HexagonTargetHandler(HexagonLinkingContext &targetInfo);
>
> - void registerRelocationNames(Registry ®istry) override;
> -
> const HexagonTargetRelocationHandler &getRelocationHandler() const override {
> return *_relocationHandler;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt Wed Apr 1 23:18:54 2015
> @@ -4,7 +4,6 @@ add_llvm_library(lldMipsELFTarget
> MipsLinkingContext.cpp
> MipsRelocationHandler.cpp
> MipsRelocationPass.cpp
> - MipsTargetHandler.cpp
> LINK_LIBS
> lldELF
> lldReaderWriter
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp Wed Apr 1 23:18:54 2015
> @@ -127,3 +127,23 @@ bool MipsLinkingContext::isRelativeReloc
> return false;
> }
> }
> +
> +const Registry::KindStrings kindStrings[] = {
> +#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> +#include "llvm/Support/ELFRelocs/Mips.def"
> +#undef ELF_RELOC
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_GLOBAL_GOT),
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_32_HI16),
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_64_HI16),
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_GLOBAL_26),
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_HI16),
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_LO16),
> + LLD_KIND_STRING_ENTRY(LLD_R_MIPS_STO_PLT),
> + LLD_KIND_STRING_ENTRY(LLD_R_MICROMIPS_GLOBAL_26_S1),
> + LLD_KIND_STRING_END
> +};
> +
> +void MipsLinkingContext::registerRelocationNames(Registry ®istry) {
> + registry.addKindTable(Reference::KindNamespace::ELF,
> + Reference::KindArch::Mips, kindStrings);
> +}
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -47,6 +47,7 @@ public:
>
> uint32_t getMergedELFFlags() const;
> MipsELFFlagsMerger &getELFFlagsMerger();
> + void registerRelocationNames(Registry &r) override;
>
> // ELFLinkingContext
> uint64_t getBaseAddress() const override;
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp?rev=233882&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp (removed)
> @@ -1,33 +0,0 @@
> -//===- lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp --------------------===//
> -//
> -// The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "MipsTargetHandler.h"
> -
> -using namespace lld;
> -using namespace elf;
> -
> -const Registry::KindStrings kindStrings[] = {
> -#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> -#include "llvm/Support/ELFRelocs/Mips.def"
> -#undef ELF_RELOC
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_GLOBAL_GOT),
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_32_HI16),
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_64_HI16),
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_GLOBAL_26),
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_HI16),
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_LO16),
> - LLD_KIND_STRING_ENTRY(LLD_R_MIPS_STO_PLT),
> - LLD_KIND_STRING_ENTRY(LLD_R_MICROMIPS_GLOBAL_26_S1),
> - LLD_KIND_STRING_END
> -};
> -
> -void MipsRelocationStringTable::registerTable(Registry ®istry) {
> - registry.addKindTable(Reference::KindNamespace::ELF,
> - Reference::KindArch::Mips, kindStrings);
> -}
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Wed Apr 1 23:18:54 2015
> @@ -90,12 +90,6 @@ public:
> : RuntimeFile<ELFT>(ctx, "Mips runtime file") {}
> };
>
> -/// \brief Auxiliary class holds relocation's names table.
> -class MipsRelocationStringTable {
> -public:
> - static void registerTable(Registry ®istry);
> -};
> -
> /// \brief TargetHandler for Mips
> template <class ELFT> class MipsTargetHandler final : public TargetHandler {
> public:
> @@ -131,10 +125,6 @@ public:
> }
> }
>
> - void registerRelocationNames(Registry ®istry) override {
> - MipsRelocationStringTable::registerTable(registry);
> - }
> -
> private:
> MipsLinkingContext &_ctx;
> std::unique_ptr<MipsRuntimeFile<ELFT>> _runtimeFile;
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Reader.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Reader.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Reader.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Reader.cpp Wed Apr 1 23:18:54 2015
> @@ -32,7 +32,7 @@ void Registry::addSupportELFObjects(ELFL
> add(std::move(ctx.getTargetHandler().getObjReader()));
>
> // Tell registry about the relocation name to number mapping for this arch.
> - ctx.getTargetHandler().registerRelocationNames(*this);
> + ctx.registerRelocationNames(*this);
> }
>
> void Registry::addSupportELFDynamicSharedObjects(ELFLinkingContext &ctx) {
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp Wed Apr 1 23:18:54 2015
> @@ -14,13 +14,26 @@
> #include "llvm/Support/ErrorOr.h"
>
> using namespace lld;
> +using namespace lld::elf;
>
> std::unique_ptr<ELFLinkingContext>
> -elf::X86LinkingContext::create(llvm::Triple triple) {
> +X86LinkingContext::create(llvm::Triple triple) {
> if (triple.getArch() == llvm::Triple::x86)
> - return llvm::make_unique<elf::X86LinkingContext>(triple);
> + return llvm::make_unique<X86LinkingContext>(triple);
> return nullptr;
> }
>
> -elf::X86LinkingContext::X86LinkingContext(llvm::Triple triple)
> +X86LinkingContext::X86LinkingContext(llvm::Triple triple)
> : ELFLinkingContext(triple, llvm::make_unique<X86TargetHandler>(*this)) {}
> +
> +static const Registry::KindStrings kindStrings[] = {
> +#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> +#include "llvm/Support/ELFRelocs/i386.def"
> +#undef ELF_RELOC
> + LLD_KIND_STRING_END
> +};
> +
> +void X86LinkingContext::registerRelocationNames(Registry ®istry) {
> + registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::x86,
> + kindStrings);
> +}
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -20,6 +20,7 @@ class X86LinkingContext final : public E
> public:
> static std::unique_ptr<ELFLinkingContext> create(llvm::Triple);
> X86LinkingContext(llvm::Triple);
> + void registerRelocationNames(Registry &r) override;
>
> /// \brief X86 has only two relative relocation
> /// a) for supporting IFUNC relocs - R_386_IRELATIVE
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp Wed Apr 1 23:18:54 2015
> @@ -33,18 +33,6 @@ std::unique_ptr<Writer> X86TargetHandler
> }
> }
>
> -static const Registry::KindStrings kindStrings[] = {
> -#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> -#include "llvm/Support/ELFRelocs/i386.def"
> -#undef ELF_RELOC
> - LLD_KIND_STRING_END
> -};
> -
> -void X86TargetHandler::registerRelocationNames(Registry ®istry) {
> - registry.addKindTable(Reference::KindNamespace::ELF, Reference::KindArch::x86,
> - kindStrings);
> -}
> -
> X86TargetHandler::X86TargetHandler(X86LinkingContext &ctx)
> : _ctx(ctx), _targetLayout(new TargetLayout<X86ELFType>(ctx)),
> _relocationHandler(new X86TargetRelocationHandler()) {}
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h Wed Apr 1 23:18:54 2015
> @@ -24,8 +24,6 @@ class X86TargetHandler final : public Ta
> public:
> X86TargetHandler(X86LinkingContext &ctx);
>
> - void registerRelocationNames(Registry ®istry) override;
> -
> const X86TargetRelocationHandler &getRelocationHandler() const override {
> return *_relocationHandler;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp Wed Apr 1 23:18:54 2015
> @@ -12,7 +12,7 @@
> #include "X86_64TargetHandler.h"
>
> using namespace lld;
> -using namespace elf;
> +using namespace lld::elf;
>
> X86_64LinkingContext::X86_64LinkingContext(
> llvm::Triple triple, std::unique_ptr<TargetHandler> handler)
> @@ -32,6 +32,19 @@ void X86_64LinkingContext::addPasses(Pas
> std::unique_ptr<ELFLinkingContext>
> X86_64LinkingContext::create(llvm::Triple triple) {
> if (triple.getArch() == llvm::Triple::x86_64)
> - return llvm::make_unique<elf::X86_64LinkingContext>(triple);
> + return llvm::make_unique<X86_64LinkingContext>(triple);
> return nullptr;
> }
> +
> +static const Registry::KindStrings kindStrings[] = {
> +#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> +#include "llvm/Support/ELFRelocs/x86_64.def"
> +#undef ELF_RELOC
> + LLD_KIND_STRING_ENTRY(LLD_R_X86_64_GOTRELINDEX),
> + LLD_KIND_STRING_END
> +};
> +
> +void X86_64LinkingContext::registerRelocationNames(Registry ®istry) {
> + registry.addKindTable(Reference::KindNamespace::ELF,
> + Reference::KindArch::x86_64, kindStrings);
> +}
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h Wed Apr 1 23:18:54 2015
> @@ -33,6 +33,7 @@ public:
> X86_64LinkingContext(llvm::Triple);
>
> void addPasses(PassManager &) override;
> + void registerRelocationNames(Registry &r) override;
>
> uint64_t getBaseAddress() const override {
> if (_baseAddress == 0)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp?rev=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp Wed Apr 1 23:18:54 2015
> @@ -20,19 +20,6 @@ X86_64TargetHandler::X86_64TargetHandler
> : _ctx(ctx), _targetLayout(new X86_64TargetLayout(ctx)),
> _relocationHandler(new X86_64TargetRelocationHandler(*_targetLayout)) {}
>
> -static const Registry::KindStrings kindStrings[] = {
> -#define ELF_RELOC(name, value) LLD_KIND_STRING_ENTRY(name),
> -#include "llvm/Support/ELFRelocs/x86_64.def"
> -#undef ELF_RELOC
> - LLD_KIND_STRING_ENTRY(LLD_R_X86_64_GOTRELINDEX),
> - LLD_KIND_STRING_END
> -};
> -
> -void X86_64TargetHandler::registerRelocationNames(Registry ®istry) {
> - registry.addKindTable(Reference::KindNamespace::ELF,
> - Reference::KindArch::x86_64, kindStrings);
> -}
> -
> std::unique_ptr<Writer> X86_64TargetHandler::getWriter() {
> switch (this->_ctx.getOutputELFType()) {
> case llvm::ELF::ET_EXEC:
>
> 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=233883&r1=233882&r2=233883&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h Wed Apr 1 23:18:54 2015
> @@ -62,8 +62,6 @@ class X86_64TargetHandler : public Targe
> public:
> X86_64TargetHandler(X86_64LinkingContext &ctx);
>
> - void registerRelocationNames(Registry ®istry) override;
> -
> const X86_64TargetRelocationHandler &getRelocationHandler() const override {
> return *_relocationHandler;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
More information about the llvm-commits
mailing list