From fdcfe466e38273f33ccb2bcaea5d409dbc132776 Mon Sep 17 00:00:00 2001 From: Rui Ueyama <ruiu@google.com> Date: Fri, 3 Apr 2015 21:22:20 +0000 Subject: [PATCH] ELF: Remove <Arch>ELFReader.h. NFC. <Arch>ELFReader.h contains only a few typedefs. The typedefs are used only by one class in <Arch>TargetHandler.h. Thus, the headers don't worth to be independent files. Since MipsELFReader.h contains code other than the boilerplate, I didn't touch that file in this patch. llvm-svn: 234056 --- .../ELF/AArch64/AArch64ELFReader.h | 30 ------------------- .../ELF/AArch64/AArch64TargetHandler.h | 13 +++++--- lld/lib/ReaderWriter/ELF/ARM/ARMELFReader.h | 28 ----------------- .../ReaderWriter/ELF/ARM/ARMTargetHandler.h | 13 +++++--- .../ELF/Hexagon/HexagonELFReader.h | 28 ----------------- .../ELF/Hexagon/HexagonTargetHandler.h | 16 ++++++---- lld/lib/ReaderWriter/ELF/X86/X86ELFReader.h | 28 ----------------- .../ReaderWriter/ELF/X86/X86TargetHandler.h | 13 +++++--- .../ReaderWriter/ELF/X86_64/X86_64ELFReader.h | 28 ----------------- .../ELF/X86_64/X86_64TargetHandler.h | 11 +++++-- 10 files changed, 46 insertions(+), 162 deletions(-) delete mode 100644 lld/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h delete mode 100644 lld/lib/ReaderWriter/ELF/ARM/ARMELFReader.h delete mode 100644 lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h delete mode 100644 lld/lib/ReaderWriter/ELF/X86/X86ELFReader.h delete mode 100644 lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h diff --git a/lld/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h b/lld/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h deleted file mode 100644 index 025b02735534..000000000000 --- a/lld/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h +++ /dev/null @@ -1,30 +0,0 @@ -//===- lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h --------------------===// -// -// The LLVM Linker -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLD_READER_WRITER_AARCH64_AARCH64_ELF_READER_H -#define LLD_READER_WRITER_AARCH64_AARCH64_ELF_READER_H - -#include "ELFReader.h" - -namespace lld { -namespace elf { - -class AArch64LinkingContext; - -typedef llvm::object::ELFType<llvm::support::little, 2, true> AArch64ELFType; - -typedef ELFObjectReader<AArch64ELFType, AArch64LinkingContext, - lld::elf::ELFFile> AArch64ELFObjectReader; - -typedef ELFDSOReader<AArch64ELFType, AArch64LinkingContext> AArch64ELFDSOReader; - -} // namespace elf -} // namespace lld - -#endif // LLD_READER_WRITER_AARCH64_AARCH64_ELF_READER_H diff --git a/lld/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h b/lld/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h index 476a9f87ceb1..9eafc4c9f1a0 100644 --- a/lld/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h @@ -10,8 +10,8 @@ #ifndef LLD_READER_WRITER_ELF_AARCH64_AARCH64_TARGET_HANDLER_H #define LLD_READER_WRITER_ELF_AARCH64_AARCH64_TARGET_HANDLER_H -#include "AArch64ELFReader.h" #include "AArch64RelocationHandler.h" +#include "ELFReader.h" #include "TargetLayout.h" #include "lld/Core/Simple.h" @@ -20,6 +20,11 @@ namespace elf { class AArch64LinkingContext; class AArch64TargetHandler final : public TargetHandler { + typedef llvm::object::ELFType<llvm::support::little, 2, true> ELFTy; + typedef ELFObjectReader<ELFTy, AArch64LinkingContext, lld::elf::ELFFile> + ObjReader; + typedef ELFDSOReader<AArch64ELFType, AArch64LinkingContext> DSOReader; + public: AArch64TargetHandler(AArch64LinkingContext &ctx); @@ -28,18 +33,18 @@ public: } std::unique_ptr<Reader> getObjReader() override { - return llvm::make_unique<AArch64ELFObjectReader>(_ctx); + return llvm::make_unique<ObjReader>(_ctx); } std::unique_ptr<Reader> getDSOReader() override { - return llvm::make_unique<AArch64ELFDSOReader>(_ctx); + return llvm::make_unique<DSOReader>(_ctx); } std::unique_ptr<Writer> getWriter() override; private: AArch64LinkingContext &_ctx; - std::unique_ptr<TargetLayout<AArch64ELFType>> _targetLayout; + std::unique_ptr<TargetLayout<ELFTy>> _targetLayout; std::unique_ptr<AArch64TargetRelocationHandler> _relocationHandler; }; diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMELFReader.h b/lld/lib/ReaderWriter/ELF/ARM/ARMELFReader.h deleted file mode 100644 index 299fe2821856..000000000000 --- a/lld/lib/ReaderWriter/ELF/ARM/ARMELFReader.h +++ /dev/null @@ -1,28 +0,0 @@ -//===--------- lib/ReaderWriter/ELF/ARM/ARMELFReader.h --------------------===// -// -// The LLVM Linker -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLD_READER_WRITER_ARM_ARM_ELF_READER_H -#define LLD_READER_WRITER_ARM_ARM_ELF_READER_H - -#include "ARMELFFile.h" -#include "ELFReader.h" - -namespace lld { -namespace elf { - -typedef llvm::object::ELFType<llvm::support::little, 2, false> ARMELFType; - -typedef ELFObjectReader<ARMELFType, ARMLinkingContext, lld::elf::ARMELFFile> - ARMELFObjectReader; -typedef ELFDSOReader<ARMELFType, ARMLinkingContext> ARMELFDSOReader; - -} // namespace elf -} // namespace lld - -#endif // LLD_READER_WRITER_ARM_ARM_ELF_READER_H diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h b/lld/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h index a1cb30a6be4f..0430ecc0e725 100644 --- a/lld/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h @@ -11,8 +11,8 @@ #define LLD_READER_WRITER_ELF_ARM_ARM_TARGET_HANDLER_H #include "ARMELFFile.h" -#include "ARMELFReader.h" #include "ARMRelocationHandler.h" +#include "ELFReader.h" #include "TargetLayout.h" #include "llvm/ADT/Optional.h" @@ -60,6 +60,11 @@ private: }; class ARMTargetHandler final : public TargetHandler { + typedef llvm::object::ELFType<llvm::support::little, 2, false> ELFTy; + typedef ELFObjectReader<ELFTy, ARMLinkingContext, lld::elf::ARMELFFile> + ObjReader; + typedef ELFDSOReader<ELFTy, ARMLinkingContext> DSOReader; + public: ARMTargetHandler(ARMLinkingContext &ctx); @@ -68,18 +73,18 @@ public: } std::unique_ptr<Reader> getObjReader() override { - return llvm::make_unique<ARMELFObjectReader>(_ctx); + return llvm::make_unique<ObjReader>(_ctx); } std::unique_ptr<Reader> getDSOReader() override { - return llvm::make_unique<ARMELFDSOReader>(_ctx); + return llvm::make_unique<DSOReader>(_ctx); } std::unique_ptr<Writer> getWriter() override; private: ARMLinkingContext &_ctx; - std::unique_ptr<ARMTargetLayout<ARMELFType>> _targetLayout; + std::unique_ptr<ARMTargetLayout<ELFTy>> _targetLayout; std::unique_ptr<ARMTargetRelocationHandler> _relocationHandler; }; diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h deleted file mode 100644 index 8706ecac45ff..000000000000 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h +++ /dev/null @@ -1,28 +0,0 @@ -//===- lib/ReaderWriter/ELF/HexagonELFReader.h ----------------------------===// -// -// The LLVM Linker -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLD_READER_WRITER_HEXAGON_ELF_READER_H -#define LLD_READER_WRITER_HEXAGON_ELF_READER_H - -#include "ELFReader.h" -#include "HexagonELFFile.h" - -namespace lld { -namespace elf { - -typedef llvm::object::ELFType<llvm::support::little, 2, false> HexagonELFType; - -typedef ELFObjectReader<HexagonELFType, HexagonLinkingContext, - lld::elf::HexagonELFFile> HexagonELFObjectReader; -typedef ELFDSOReader<HexagonELFType, HexagonLinkingContext> HexagonELFDSOReader; - -} // namespace elf -} // namespace lld - -#endif // LLD_READER_WRITER_ELF_READER_H diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h index facecf55670c..0f5b73befe9c 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h @@ -10,7 +10,8 @@ #ifndef HEXAGON_TARGET_HANDLER_H #define HEXAGON_TARGET_HANDLER_H -#include "HexagonELFReader.h" +#include "ELFReader.h" +#include "HexagonELFFile.h" #include "HexagonExecutableAtoms.h" #include "HexagonRelocationHandler.h" #include "HexagonSectionChunks.h" @@ -97,6 +98,11 @@ private: /// \brief TargetHandler for Hexagon class HexagonTargetHandler final : public TargetHandler { + typedef llvm::object::ELFType<llvm::support::little, 2, false> ELFTy; + typedef ELFObjectReader<ELFTy, HexagonLinkingContext, + lld::elf::HexagonELFFile> ObjReader; + typedef ELFDSOReader<ELFTy, HexagonLinkingContext> ELFDSOReader; + public: HexagonTargetHandler(HexagonLinkingContext &targetInfo); @@ -105,19 +111,19 @@ public: } std::unique_ptr<Reader> getObjReader() override { - return llvm::make_unique<HexagonELFObjectReader>(_ctx); + return llvm::make_unique<ObjReader>(_ctx); } std::unique_ptr<Reader> getDSOReader() override { - return llvm::make_unique<HexagonELFDSOReader>(_ctx); + return llvm::make_unique<ELFDSOReader>(_ctx); } std::unique_ptr<Writer> getWriter() override; private: HexagonLinkingContext &_ctx; - std::unique_ptr<HexagonRuntimeFile<HexagonELFType>> _runtimeFile; - std::unique_ptr<HexagonTargetLayout<HexagonELFType>> _targetLayout; + std::unique_ptr<HexagonRuntimeFile<ELFTy>> _runtimeFile; + std::unique_ptr<HexagonTargetLayout<ELFTy>> _targetLayout; std::unique_ptr<HexagonTargetRelocationHandler> _relocationHandler; }; diff --git a/lld/lib/ReaderWriter/ELF/X86/X86ELFReader.h b/lld/lib/ReaderWriter/ELF/X86/X86ELFReader.h deleted file mode 100644 index 94a2141e9602..000000000000 --- a/lld/lib/ReaderWriter/ELF/X86/X86ELFReader.h +++ /dev/null @@ -1,28 +0,0 @@ -//===- lib/ReaderWriter/ELF/X86/X86ELFReader.h ----------------------------===// -// -// The LLVM Linker -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLD_READER_WRITER_X86_X86_ELF_READER_H -#define LLD_READER_WRITER_X86_X86_ELF_READER_H - -#include "ELFReader.h" - -namespace lld { -namespace elf { - -class X86LinkingContext; -typedef llvm::object::ELFType<llvm::support::little, 2, false> X86ELFType; - -typedef ELFObjectReader<X86ELFType, X86LinkingContext, lld::elf::ELFFile> - X86ELFObjectReader; -typedef ELFDSOReader<X86ELFType, X86LinkingContext> X86ELFDSOReader; - -} // namespace elf -} // namespace lld - -#endif // LLD_READER_WRITER_X86_X86_ELF_READER_H diff --git a/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h b/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h index b1f67278c35a..75ee6be8d6bb 100644 --- a/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/X86/X86TargetHandler.h @@ -11,7 +11,7 @@ #define LLD_READER_WRITER_ELF_X86_TARGET_HANDLER_H #include "TargetLayout.h" -#include "X86ELFReader.h" +#include "ELFReader.h" #include "X86RelocationHandler.h" namespace lld { @@ -20,6 +20,11 @@ namespace elf { class X86LinkingContext; class X86TargetHandler final : public TargetHandler { + typedef llvm::object::ELFType<llvm::support::little, 2, false> ELFTy; + typedef ELFObjectReader<ELFTy, X86LinkingContext, lld::elf::ELFFile> + ObjReader; + typedef ELFDSOReader<ELFTy, X86LinkingContext> DSOReader; + public: X86TargetHandler(X86LinkingContext &ctx); @@ -28,18 +33,18 @@ public: } std::unique_ptr<Reader> getObjReader() override { - return llvm::make_unique<X86ELFObjectReader>(_ctx); + return llvm::make_unique<ObjReader>(_ctx); } std::unique_ptr<Reader> getDSOReader() override { - return llvm::make_unique<X86ELFDSOReader>(_ctx); + return llvm::make_unique<DSOReader>(_ctx); } std::unique_ptr<Writer> getWriter() override; protected: X86LinkingContext &_ctx; - std::unique_ptr<TargetLayout<X86ELFType>> _targetLayout; + std::unique_ptr<TargetLayout<ELFTy>> _targetLayout; std::unique_ptr<X86TargetRelocationHandler> _relocationHandler; }; } // end namespace elf diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h b/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h deleted file mode 100644 index 85e0030a96a9..000000000000 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h +++ /dev/null @@ -1,28 +0,0 @@ -//===- lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h ----------------------===// -// -// The LLVM Linker -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLD_READER_WRITER_X86_64_X86_64_ELF_READER_H -#define LLD_READER_WRITER_X86_64_X86_64_ELF_READER_H - -#include "ELFReader.h" - -namespace lld { -namespace elf { - -class X86_64LinkingContext; -typedef llvm::object::ELFType<llvm::support::little, 2, true> X86_64ELFType; - -typedef ELFObjectReader<X86_64ELFType, X86_64LinkingContext, lld::elf::ELFFile> - X86_64ELFObjectReader; -typedef ELFDSOReader<X86_64ELFType, X86_64LinkingContext> X86_64ELFDSOReader; - -} // namespace elf -} // namespace lld - -#endif // LLD_READER_WRITER_ELF_X86_64_X86_64_READER_H diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h index aa863746fcbe..f0760d726989 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h @@ -10,8 +10,8 @@ #ifndef LLD_READER_WRITER_ELF_X86_64_X86_64_TARGET_HANDLER_H #define LLD_READER_WRITER_ELF_X86_64_X86_64_TARGET_HANDLER_H +#include "ELFReader.h" #include "TargetLayout.h" -#include "X86_64ELFReader.h" #include "X86_64LinkingContext.h" #include "X86_64RelocationHandler.h" #include "lld/Core/Simple.h" @@ -58,6 +58,11 @@ private: }; class X86_64TargetHandler : public TargetHandler { + typedef llvm::object::ELFType<llvm::support::little, 2, true> ELFTy; + typedef ELFObjectReader<ELFTy, X86_64LinkingContext, lld::elf::ELFFile> + ObjReader; + typedef ELFDSOReader<ELFTy, X86_64LinkingContext> DSOReader; + public: X86_64TargetHandler(X86_64LinkingContext &ctx); @@ -66,11 +71,11 @@ public: } std::unique_ptr<Reader> getObjReader() override { - return llvm::make_unique<X86_64ELFObjectReader>(_ctx); + return llvm::make_unique<ObjReader>(_ctx); } std::unique_ptr<Reader> getDSOReader() override { - return llvm::make_unique<X86_64ELFDSOReader>(_ctx); + return llvm::make_unique<DSOReader>(_ctx); } std::unique_ptr<Writer> getWriter() override;