forked from OSchip/llvm-project
[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. llvm-svn: 182230
This commit is contained in:
parent
f927800325
commit
87a594835f
|
@ -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@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@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@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@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
|
||||
|
|
|
@ -13,58 +13,58 @@
|
|||
#include "Atoms.h"
|
||||
#include "X86_64TargetInfo.h"
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
/// \brief Specify various atom contents that are used by X86_64 dynamic
|
||||
/// linking
|
||||
namespace {
|
||||
// .got values
|
||||
const uint8_t x86_64GotAtomContent[8] = { 0 };
|
||||
|
||||
class X86_64GOTAtom : public GOTAtom {
|
||||
static const uint8_t _defaultContent[8];
|
||||
|
||||
public:
|
||||
X86_64GOTAtom(const File &f, StringRef secName) : GOTAtom(f, secName) {}
|
||||
|
||||
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 };
|
||||
|
||||
class X86_64PLTAtom : public PLTAtom {
|
||||
static const uint8_t _defaultContent[16];
|
||||
|
||||
public:
|
||||
X86_64PLTAtom(const File &f, StringRef secName) : PLTAtom(f, secName) {}
|
||||
|
||||
virtual ArrayRef<uint8_t> rawContent() const {
|
||||
return ArrayRef<uint8_t>(_defaultContent, 16);
|
||||
}
|
||||
};
|
||||
|
||||
const uint8_t X86_64PLTAtom::_defaultContent[16] = {
|
||||
// .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]
|
||||
};
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
namespace elf {
|
||||
|
||||
class X86_64GOTAtom : public GOTAtom {
|
||||
public:
|
||||
X86_64GOTAtom(const File &f, StringRef secName) : GOTAtom(f, secName) {}
|
||||
|
||||
virtual ArrayRef<uint8_t> rawContent() const {
|
||||
return ArrayRef<uint8_t>(x86_64GotAtomContent, 8);
|
||||
}
|
||||
};
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue