[lld] r250330 - ELF2: Move Target concrete classes from .h to .cpp.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 14:47:24 PDT 2015


Thanks!


On 14 October 2015 at 17:30, Rui Ueyama via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: ruiu
> Date: Wed Oct 14 16:30:32 2015
> New Revision: 250330
>
> URL: http://llvm.org/viewvc/llvm-project?rev=250330&view=rev
> Log:
> ELF2: Move Target concrete classes from .h to .cpp.
>
> Modified:
>     lld/trunk/ELF/Target.cpp
>     lld/trunk/ELF/Target.h
>
> Modified: lld/trunk/ELF/Target.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=250330&r1=250329&r2=250330&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Target.cpp (original)
> +++ lld/trunk/ELF/Target.cpp Wed Oct 14 16:30:32 2015
> @@ -32,6 +32,92 @@ namespace elf2 {
>
>  std::unique_ptr<TargetInfo> Target;
>
> +static void add32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) + V); }
> +static void add32be(uint8_t *L, int32_t V) { write32be(L, read32be(L) + V); }
> +static void or32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) | V); }
> +
> +template <bool IsLE> static void add32(uint8_t *L, int32_t V);
> +template <> void add32<true>(uint8_t *L, int32_t V) { add32le(L, V); }
> +template <> void add32<false>(uint8_t *L, int32_t V) { add32be(L, V); }
> +
> +namespace {
> +class X86TargetInfo final : public TargetInfo {
> +public:
> +  X86TargetInfo();
> +  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> +                     uint64_t PltEntryAddr) const override;
> +  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> +  bool relocPointsToGot(uint32_t Type) const override;
> +  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> +  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> +                   uint32_t Type, uint64_t BaseAddr,
> +                   uint64_t SymVA) const override;
> +};
> +
> +class X86_64TargetInfo final : public TargetInfo {
> +public:
> +  X86_64TargetInfo();
> +  unsigned getPLTRefReloc(unsigned Type) const override;
> +  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> +                     uint64_t PltEntryAddr) const override;
> +  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> +  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> +  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> +                   uint32_t Type, uint64_t BaseAddr,
> +                   uint64_t SymVA) const override;
> +  bool isRelRelative(uint32_t Type) const override;
> +};
> +
> +class PPC64TargetInfo final : public TargetInfo {
> +public:
> +  PPC64TargetInfo();
> +  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> +                     uint64_t PltEntryAddr) const override;
> +  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> +  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> +  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> +                   uint32_t Type, uint64_t BaseAddr,
> +                   uint64_t SymVA) const override;
> +  bool isRelRelative(uint32_t Type) const override;
> +};
> +
> +class PPCTargetInfo final : public TargetInfo {
> +public:
> +  PPCTargetInfo();
> +  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> +                     uint64_t PltEntryAddr) const override;
> +  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> +  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> +  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> +                   uint32_t Type, uint64_t BaseAddr,
> +                   uint64_t SymVA) const override;
> +};
> +
> +class AArch64TargetInfo final : public TargetInfo {
> +public:
> +  AArch64TargetInfo();
> +  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> +                     uint64_t PltEntryAddr) const override;
> +  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> +  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> +  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> +                   uint32_t Type, uint64_t BaseAddr,
> +                   uint64_t SymVA) const override;
> +};
> +
> +template <class ELFT> class MipsTargetInfo final : public TargetInfo {
> +public:
> +  MipsTargetInfo();
> +  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> +                     uint64_t PltEntryAddr) const override;
> +  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> +  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> +  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> +                   uint32_t Type, uint64_t BaseAddr,
> +                   uint64_t SymVA) const override;
> +};
> +} // anonymous namespace
> +
>  TargetInfo *createTarget() {
>    switch (Config->EMachine) {
>    case EM_386:
> @@ -92,14 +178,6 @@ bool X86TargetInfo::relocNeedsPlt(uint32
>    return Type == R_386_PLT32 || (Type == R_386_PC32 && S.isShared());
>  }
>
> -static void add32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) + V); }
> -static void add32be(uint8_t *L, int32_t V) { write32be(L, read32be(L) + V); }
> -static void or32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) | V); }
> -
> -template <bool IsLE> static void add32(uint8_t *L, int32_t V);
> -template <> void add32<true>(uint8_t *L, int32_t V) { add32le(L, V); }
> -template <> void add32<false>(uint8_t *L, int32_t V) { add32be(L, V); }
> -
>  void X86TargetInfo::relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
>                                  uint32_t Type, uint64_t BaseAddr,
>                                  uint64_t SymVA) const {
>
> Modified: lld/trunk/ELF/Target.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=250330&r1=250329&r2=250330&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Target.h (original)
> +++ lld/trunk/ELF/Target.h Wed Oct 14 16:30:32 2015
> @@ -48,82 +48,6 @@ protected:
>    unsigned PltEntrySize = 8;
>  };
>
> -class X86TargetInfo final : public TargetInfo {
> -public:
> -  X86TargetInfo();
> -  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> -                     uint64_t PltEntryAddr) const override;
> -  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> -  bool relocPointsToGot(uint32_t Type) const override;
> -  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> -  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> -                   uint32_t Type, uint64_t BaseAddr,
> -                   uint64_t SymVA) const override;
> -};
> -
> -class X86_64TargetInfo final : public TargetInfo {
> -public:
> -  X86_64TargetInfo();
> -  unsigned getPLTRefReloc(unsigned Type) const override;
> -  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> -                     uint64_t PltEntryAddr) const override;
> -  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> -  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> -  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> -                   uint32_t Type, uint64_t BaseAddr,
> -                   uint64_t SymVA) const override;
> -  bool isRelRelative(uint32_t Type) const override;
> -};
> -
> -class PPC64TargetInfo final : public TargetInfo {
> -public:
> -  PPC64TargetInfo();
> -  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> -                     uint64_t PltEntryAddr) const override;
> -  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> -  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> -  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> -                   uint32_t Type, uint64_t BaseAddr,
> -                   uint64_t SymVA) const override;
> -  bool isRelRelative(uint32_t Type) const override;
> -};
> -
> -class PPCTargetInfo final : public TargetInfo {
> -public:
> -  PPCTargetInfo();
> -  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> -                     uint64_t PltEntryAddr) const override;
> -  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> -  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> -  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> -                   uint32_t Type, uint64_t BaseAddr,
> -                   uint64_t SymVA) const override;
> -};
> -
> -class AArch64TargetInfo final : public TargetInfo {
> -public:
> -  AArch64TargetInfo();
> -  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> -                     uint64_t PltEntryAddr) const override;
> -  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> -  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> -  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> -                   uint32_t Type, uint64_t BaseAddr,
> -                   uint64_t SymVA) const override;
> -};
> -
> -template <class ELFT> class MipsTargetInfo final : public TargetInfo {
> -public:
> -  MipsTargetInfo();
> -  void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
> -                     uint64_t PltEntryAddr) const override;
> -  bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;
> -  bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;
> -  void relocateOne(uint8_t *Buf, uint8_t *BufEnd, const void *RelP,
> -                   uint32_t Type, uint64_t BaseAddr,
> -                   uint64_t SymVA) const override;
> -};
> -
>  extern std::unique_ptr<TargetInfo> Target;
>  TargetInfo *createTarget();
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list