10 #ifndef LLVM_OBJECT_ELFTYPES_H
11 #define LLVM_OBJECT_ELFTYPES_H
39 template <endianness E,
bool Is64>
struct ELFType {
41 template <
typename Ty>
48 typedef typename std::conditional<Is64, uint64_t, uint32_t>::type
uint;
105 template <endianness TargetEndianness>
116 template <endianness TargetEndianness>
128 #define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) \
129 typedef typename ELFT::Addr Elf_Addr; \
130 typedef typename ELFT::Off Elf_Off; \
131 typedef typename ELFT::Half Elf_Half; \
132 typedef typename ELFT::Word Elf_Word; \
133 typedef typename ELFT::Sword Elf_Sword; \
134 typedef typename ELFT::Xword Elf_Xword; \
135 typedef typename ELFT::Sxword Elf_Sxword;
137 #define LLD_ELF_COMMA ,
138 #define LLVM_ELF_IMPORT_TYPES(E, W) \
139 LLVM_ELF_IMPORT_TYPES_ELFT(ELFType<E LLD_ELF_COMMA W>)
144 template <endianness TargetEndianness>
155 Elf_Word sh_addralign;
170 Elf_Xword sh_addralign;
171 Elf_Xword sh_entsize;
174 template <class ELFT>
183 return sh_size / sh_entsize;
189 template <endianness TargetEndianness>
195 unsigned char st_info;
196 unsigned char st_other;
204 unsigned char st_info;
205 unsigned char st_other;
211 template <class ELFT>
221 unsigned char getType()
const {
return st_info & 0x0f; }
224 void setType(
unsigned char t) { setBindingAndType(getBinding(), t); }
226 st_info = (b << 4) + (t & 0x0f);
236 assert(v < 4 &&
"Invalid value for visibility");
237 st_other = (st_other & ~0x3) | v;
264 template <
class ELFT>
267 if (Offset >= StrTab.
size())
274 template <
class ELFT>
284 template <class ELFT>
298 return reinterpret_cast<const Elf_Verdaux *
>((
const char *)
this + vd_aux);
304 template <
class ELFT>
313 template <class ELFT>
325 template <class ELFT>
349 template <endianness TargetEndianness>
360 template <
class ELFT>
364 typedef typename std::conditional<ELFT::Is64Bits,
366 typedef typename std::conditional<ELFT::Is64Bits,
373 template <endianness TargetEndianness>
392 return this->getRInfo(isMips64EL) >> 8;
394 unsigned char getType(
bool isMips64EL)
const {
395 return (
unsigned char)(this->getRInfo(isMips64EL) & 0x0ff);
398 setSymbolAndType(s,
getType(), IsMips64EL);
401 setSymbolAndType(
getSymbol(), t, IsMips64EL);
404 this->setRInfo((s << 8) + t, IsMips64EL);
408 template <endianness TargetEndianness>
410 :
public Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
423 uint64_t getRInfo(
bool isMips64EL)
const {
430 return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) |
431 ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff);
435 r_info = (R >> 32) | ((R & 0xff000000) << 8) | ((R & 0x00ff0000) << 24) |
436 ((R & 0x0000ff00) << 40) | ((R & 0x000000ff) << 56);
444 return (
uint32_t)(this->getRInfo(isMips64EL) >> 32);
447 return (
uint32_t)(this->getRInfo(isMips64EL) & 0xffffffff
L);
450 setSymbolAndType(s,
getType(), IsMips64EL);
453 setSymbolAndType(
getSymbol(), t, IsMips64EL);
456 this->setRInfo(((uint64_t)s << 32) + (t & 0xffffffffL), IsMips64EL);
460 template <endianness TargetEndianness>
462 :
public Elf_Rel_Impl<ELFType<TargetEndianness, true>, false> {
468 template <class ELFT>
480 Elf_Half e_phentsize;
482 Elf_Half e_shentsize;
486 bool checkMagic()
const {
495 template <endianness TargetEndianness>
522 template <class ELFT>
534 &nbucket + 2 + nbucket + nchain);
539 template <
class ELFT>
554 reinterpret_cast<const Elf_Word *
>(filter().end()), nbuckets);
564 template <endianness TargetEndianness>
569 Elf_Word ch_addralign;
576 Elf_Word ch_reserved;
578 Elf_Xword ch_addralign;
582 template <class ELFT>
585 template <llvm::support::
endianness TargetEndianness>
589 Elf_Word ri_cprmask[4];
590 Elf_Addr ri_gp_value;
593 template <llvm::support::
endianness TargetEndianness>
594 struct Elf_Mips_RegInfo<
ELFType<TargetEndianness, true>> {
598 Elf_Word ri_cprmask[4];
599 Elf_Addr ri_gp_value;
611 Elf_Mips_RegInfo<ELFT> &getRegInfo() {
614 (uint8_t *)
this +
sizeof(Elf_Mips_Options));
unsigned char getType() const
void setSymbolAndType(uint32_t s, uint32_t t, bool IsMips64EL)
Elf_Shdr_Impl< ELFType< E, Is64 > > Shdr
void setType(unsigned char t, bool IsMips64EL)
void setSymbolAndType(uint32_t s, unsigned char t, bool IsMips64EL)
void setVisibility(unsigned char v)
Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section (.gnu.version_d).
unsigned char getDataEncoding() const
std::conditional< ELFT::Is64Bits, uint64_t, uint32_t >::type uintX_t
ArrayRef< Elf_Word > values(unsigned DynamicSymCount) const
unsigned char getType(bool isMips64EL) const
void setBinding(unsigned char b)
void setSymbol(uint32_t s, bool IsMips64EL)
ArrayRef< Phdr > PhdrRange
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
bool isOSSpecific() const
Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters.
static const endianness TargetEndianness
ELFType< support::little, true > ELF64LE
ELFType< support::big, false > ELF32BE
uint64_t getValue() const
void setType(uint32_t t, bool IsMips64EL)
support::detail::packed_endian_specific_integral< int32_t, target_endianness, 2 > Elf_Sword
uint32_t getSymbol(bool isMips64EL) const
unsigned char getFileClass() const
support::detail::packed_endian_specific_integral< value_type, TargetEndianness, 2 > Elf_Addr
ArrayRef< Shdr > ShdrRange
Elf_Dyn_Impl< ELFType< E, Is64 > > Dyn
static StringRef getName(Value *V)
Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed section (.gnu.version_r).
Tagged union holding either a T or a Error.
Elf_Versym_Impl< ELFType< E, Is64 > > Versym
Elf_Chdr_Impl< ELFType< E, Is64 > > Chdr
Elf_GnuHash_Impl< ELFType< E, Is64 > > GnuHash
#define LLVM_ELF_IMPORT_TYPES(E, W)
ArrayRef< Elf_Word > buckets() const
Function Alias Analysis false
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
support::detail::packed_endian_specific_integral< uint16_t, target_endianness, 2 > Elf_Half
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
support::detail::packed_endian_specific_integral< value_type, TargetEndianness, 2 > Elf_Addr
void setSymbol(uint32_t s, bool IsMips64EL)
Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef section (...
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isProcessorSpecific() const
ELFType< support::little, false > ELF32LE
ArrayRef< Rela > RelaRange
Expected< StringRef > getName(StringRef StrTab) const
void setType(unsigned char t)
support::detail::packed_endian_specific_integral< value_type, TargetEndianness, 2 > Elf_Off
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
unsigned char getVisibility() const
Access to the STV_xxx flag stored in the first two bits of st_other.
Elf_Dyn_Base: This structure matches the form of entries in the dynamic table section (...
Elf_Rel_Impl< ELFType< E, Is64 >, true > Rela
ELFType< support::big, true > ELF64BE
Elf_Vernaux_Impl< ELFType< E, Is64 > > Vernaux
Elf_Rel_Impl< ELFType< E, Is64 >, false > Rel
support::detail::packed_endian_specific_integral< uint32_t, target_endianness, 2 > Elf_Word
static const char ElfMagic[]
Elf_Ehdr_Impl< ELFType< E, Is64 > > Ehdr
Elf_Hash_Impl< ELFType< E, Is64 > > Hash
std::conditional< Is64, uint64_t, uint32_t >::type uint
void setBindingAndType(unsigned char b, unsigned char t)
Elf_Phdr_Impl< ELFType< E, Is64 > > Phdr
support::detail::packed_endian_specific_integral< int64_t, target_endianness, 2 > Elf_Sxword
Elf_Verdef_Impl< ELFType< E, Is64 > > Verdef
std::conditional< ELFT::Is64Bits, int64_t, int32_t >::type intX_t
Elf_Versym: This is the structure of entries in the SHT_GNU_versym section (.gnu.version).
void setRInfo(uint64_t R, bool IsMips64EL)
ArrayRef< Elf_Word > chains() const
unsigned getEntityCount() const
Get the number of entities this section contains if it has any.
void setRInfo(uint32_t R, bool IsMips64EL)
Provides ErrorOr<T> smart pointer.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
support::detail::packed_endian_specific_integral< value_type, TargetEndianness, 2 > Elf_Off
uint32_t getType(bool isMips64EL) const
static const bool Is64Bits
const Elf_Mips_RegInfo< ELFT > & getRegInfo() const
uint32_t getSymbol(bool isMips64EL) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
StringRef - Represent a constant reference to a string, i.e.
Elf_Verneed_Impl< ELFType< E, Is64 > > Verneed
Elf_Verdaux_Impl< ELFType< E, Is64 > > Verdaux
Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed section (.gnu.version_r).
unsigned char getBinding() const
support::detail::packed_endian_specific_integral< uint64_t, target_endianness, 2 > Elf_Xword
Elf_Sym_Impl< ELFType< E, Is64 > > Sym