[lld] r182230 - [lld][ELF][x86_64, hexagon] Changed dynamic atoms to live in anonymous namespace
Rafael EspĂndola
rafael.espindola at gmail.com
Tue May 21 12:53:57 PDT 2013
HexagonDynamicAtoms.h is only included by HexagonTargetHandler.cpp.
Why do you even need this header?
On 19 May 2013 23:57, Shankar Easwaran <shankare at codeaurora.org> wrote:
> Author: shankare
> Date: Sun May 19 22:57:01 2013
> New Revision: 182230
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182230&view=rev
> Log:
> [lld][ELF][x86_64,hexagon] Changed dynamic atoms to live in anonymous namespace
> so that their names are hidden.
>
> This addresses comments raised by Sean/Rafael.
>
> Modified:
> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicAtoms.h
> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicAtoms.h
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicAtoms.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicAtoms.h?rev=182230&r1=182229&r2=182230&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicAtoms.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonDynamicAtoms.h Sun May 19 22:57:01 2013
> @@ -13,75 +13,72 @@
> #include "Atoms.h"
> #include "HexagonTargetInfo.h"
>
> +/// \brief Specify various atom contents that are used by Hexagon dynamic
> +/// linking
> +namespace {
> +// .got atom
> +const uint8_t hexagonGotAtomContent[4] = { 0 };
> +// .got.plt atom (entry 0)
> +const uint8_t hexagonGotPlt0AtomContent[16] = { 0 };
> +// .got.plt atom (all other entries)
> +const uint8_t hexagonGotPltAtomContent[4] = { 0 };
> +// .plt (entry 0)
> +const uint8_t hexagonPlt0AtomContent[28] = {
> + 0x00, 0x40, 0x00, 0x00, // { immext (#0)
> + 0x1c, 0xc0, 0x49, 0x6a, // r28 = add (pc, ##GOT0 at PCREL) } # address of GOT0
> + 0x0e, 0x42, 0x9c, 0xe2, // { r14 -= add (r28, #16) # offset of GOTn from GOTa
> + 0x4f, 0x40, 0x9c, 0x91, // r15 = memw (r28 + #8) # object ID at GOT2
> + 0x3c, 0xc0, 0x9c, 0x91, // r28 = memw (r28 + #4) }# dynamic link at GOT1
> + 0x0e, 0x42, 0x0e, 0x8c, // { r14 = asr (r14, #2) # index of PLTn
> + 0x00, 0xc0, 0x9c, 0x52, // jumpr r28 } # call dynamic linker
> +};
> +
> +// .plt (other entries)
> +const uint8_t hexagonPltAtomContent[16] = {
> + 0x00, 0x40, 0x00, 0x00, // { immext (#0)
> + 0x0e, 0xc0, 0x49, 0x6a, // r14 = add (pc, ##GOTn at PCREL) } # address of GOTn
> + 0x1c, 0xc0, 0x8e, 0x91, // r28 = memw (r14) # contents of GOTn
> + 0x00, 0xc0, 0x9c, 0x52, // jumpr r28 # call it
> +};
> +}
> +
> namespace lld {
> namespace elf {
>
> class HexagonGOTAtom : public GOTAtom {
> - static const uint8_t _defaultContent[4];
> -
> public:
> HexagonGOTAtom(const File &f) : GOTAtom(f, ".got") {}
>
> virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_defaultContent, 4);
> + return ArrayRef<uint8_t>(hexagonGotAtomContent, 4);
> }
>
> virtual Alignment alignment() const { return Alignment(2); }
> };
>
> class HexagonGOTPLTAtom : public GOTAtom {
> - static const uint8_t _defaultContent[4];
> -
> public:
> HexagonGOTPLTAtom(const File &f) : GOTAtom(f, ".got.plt") {}
>
> virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_defaultContent, 4);
> + return ArrayRef<uint8_t>(hexagonGotPltAtomContent, 4);
> }
>
> virtual Alignment alignment() const { return Alignment(2); }
> };
>
> class HexagonGOTPLT0Atom : public GOTAtom {
> - static const uint8_t _defaultContent[16];
> -
> public:
> HexagonGOTPLT0Atom(const File &f) : GOTAtom(f, ".got.plt") {}
>
> virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_defaultContent, 16);
> + return ArrayRef<uint8_t>(hexagonGotPlt0AtomContent, 16);
> }
>
> virtual Alignment alignment() const { return Alignment(3); }
> };
>
> -const uint8_t HexagonGOTAtom::_defaultContent[4] = { 0 };
> -const uint8_t HexagonGOTPLTAtom::_defaultContent[4] = { 0 };
> -const uint8_t HexagonGOTPLT0Atom::_defaultContent[16] = { 0 };
> -
> -class HexagonPLTAtom : public PLTAtom {
> - static const uint8_t _defaultContent[16];
> -
> -public:
> - HexagonPLTAtom(const File &f, StringRef secName)
> - : PLTAtom(f, secName) {
> - }
> -
> - virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_defaultContent, 16);
> - }
> -};
> -
> -const uint8_t HexagonPLTAtom::_defaultContent[16] = {
> - 0x00, 0x40, 0x00, 0x00, // { immext (#0)
> - 0x0e, 0xc0, 0x49, 0x6a, // r14 = add (pc, ##GOTn at PCREL) } # address of GOTn
> - 0x1c, 0xc0, 0x8e, 0x91, // r28 = memw (r14) # contents of GOTn
> - 0x00, 0xc0, 0x9c, 0x52, // jumpr r28 # call it
> -};
> -
> class HexagonPLT0Atom : public PLT0Atom {
> - static const uint8_t _plt0Content[28];
> -
> public:
> HexagonPLT0Atom(const File &f) : PLT0Atom(f) {
> #ifndef NDEBUG
> @@ -90,18 +87,18 @@ public:
> }
>
> virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_plt0Content, 28);
> + return ArrayRef<uint8_t>(hexagonPlt0AtomContent, 28);
> }
> };
>
> -const uint8_t HexagonPLT0Atom::_plt0Content[28] = {
> - 0x00, 0x40, 0x00, 0x00, // { immext (#0)
> - 0x1c, 0xc0, 0x49, 0x6a, // r28 = add (pc, ##GOT0 at PCREL) } # address of GOT0
> - 0x0e, 0x42, 0x9c, 0xe2, // { r14 -= add (r28, #16) # offset of GOTn from GOTa
> - 0x4f, 0x40, 0x9c, 0x91, // r15 = memw (r28 + #8) # object ID at GOT2
> - 0x3c, 0xc0, 0x9c, 0x91, // r28 = memw (r28 + #4) }# dynamic link at GOT1
> - 0x0e, 0x42, 0x0e, 0x8c, // { r14 = asr (r14, #2) # index of PLTn
> - 0x00, 0xc0, 0x9c, 0x52, // jumpr r28 } # call dynamic linker
> +class HexagonPLTAtom : public PLTAtom {
> +
> +public:
> + HexagonPLTAtom(const File &f, StringRef secName) : PLTAtom(f, secName) {}
> +
> + virtual ArrayRef<uint8_t> rawContent() const {
> + return ArrayRef<uint8_t>(hexagonPltAtomContent, 16);
> + }
> };
>
> } // elf
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicAtoms.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicAtoms.h?rev=182230&r1=182229&r2=182230&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicAtoms.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicAtoms.h Sun May 19 22:57:01 2013
> @@ -13,58 +13,58 @@
> #include "Atoms.h"
> #include "X86_64TargetInfo.h"
>
> -namespace lld {
> -namespace elf {
> -
> -class X86_64GOTAtom : public GOTAtom {
> - static const uint8_t _defaultContent[8];
> -
> -public:
> - X86_64GOTAtom(const File &f, StringRef secName) : GOTAtom(f, secName) {}
> +/// \brief Specify various atom contents that are used by X86_64 dynamic
> +/// linking
> +namespace {
> +// .got values
> +const uint8_t x86_64GotAtomContent[8] = { 0 };
>
> - virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_defaultContent, 8);
> - }
> +// .plt value (entry 0)
> +const uint8_t x86_64Plt0AtomContent[16] = {
> + 0xff, 0x35, 0x00, 0x00, 0x00, 0x00, // pushq GOT+8(%rip)
> + 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *GOT+16(%rip)
> + 0x90, 0x90, 0x90, 0x90 // nopnopnop
> };
>
> -const uint8_t X86_64GOTAtom::_defaultContent[8] = { 0 };
> +// .plt values (other entries)
> +const uint8_t x86_64PltAtomContent[16] = {
> + 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmpq *gotatom(%rip)
> + 0x68, 0x00, 0x00, 0x00, 0x00, // pushq reloc-index
> + 0xe9, 0x00, 0x00, 0x00, 0x00 // jmpq plt[-1]
> +};
> +}
>
> -class X86_64PLTAtom : public PLTAtom {
> - static const uint8_t _defaultContent[16];
> +namespace lld {
> +namespace elf {
>
> +class X86_64GOTAtom : public GOTAtom {
> public:
> - X86_64PLTAtom(const File &f, StringRef secName) : PLTAtom(f, secName) {}
> + X86_64GOTAtom(const File &f, StringRef secName) : GOTAtom(f, secName) {}
>
> virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_defaultContent, 16);
> + return ArrayRef<uint8_t>(x86_64GotAtomContent, 8);
> }
> };
>
> -const uint8_t X86_64PLTAtom::_defaultContent[16] = {
> - 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmpq *gotatom(%rip)
> - 0x68, 0x00, 0x00, 0x00, 0x00, // pushq reloc-index
> - 0xe9, 0x00, 0x00, 0x00, 0x00 // jmpq plt[-1]
> -};
> -
> class X86_64PLT0Atom : public PLT0Atom {
> - static const uint8_t _plt0Content[16];
> -
> public:
> X86_64PLT0Atom(const File &f) : PLT0Atom(f) {
> #ifndef NDEBUG
> _name = ".PLT0";
> #endif
> }
> -
> virtual ArrayRef<uint8_t> rawContent() const {
> - return ArrayRef<uint8_t>(_plt0Content, 16);
> + return ArrayRef<uint8_t>(x86_64Plt0AtomContent, 16);
> }
> };
>
> -const uint8_t X86_64PLT0Atom::_plt0Content[16] = {
> - 0xff, 0x35, 0x00, 0x00, 0x00, 0x00, // pushq GOT+8(%rip)
> - 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *GOT+16(%rip)
> - 0x90, 0x90, 0x90, 0x90 // nopnopnop
> +class X86_64PLTAtom : public PLTAtom {
> +public:
> + X86_64PLTAtom(const File &f, StringRef secName) : PLTAtom(f, secName) {}
> +
> + virtual ArrayRef<uint8_t> rawContent() const {
> + return ArrayRef<uint8_t>(x86_64PltAtomContent, 16);
> + }
> };
>
> } // elf
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list