13#ifndef LLVM_OBJECT_ELF_H
14#define LLVM_OBJECT_ELF_H
77inline std::pair<unsigned char, unsigned char>
96template <
class ELFT>
class ELFFile;
113 "the index is greater than or equal to the number of entries (" +
116 const uint8_t *EntryStart = (
const uint8_t *)
First +
N *
sizeof(
T);
117 if (EntryStart +
sizeof(
T) >
BufEnd)
118 return createError(
"can't read past the end of the file");
130 const typename ELFT::Shdr &Sec) {
133 return "[index " + std::to_string(&Sec - &TableOrErr->front()) +
"]";
139 return "[unknown index]";
144 const typename ELFT::Shdr &Sec) {
148 " section with index " +
Twine(SecNdx))
154 const typename ELFT::Phdr &Phdr) {
157 return (
"[index " +
Twine(&Phdr - &Headers->front()) +
"]").str();
160 return "[unknown index]";
186 std::vector<Elf_Shdr> FakeSections;
193 return *
reinterpret_cast<const Elf_Ehdr *
>(
base());
196 template <
typename T>
198 template <
typename T>
207 uint32_t SymbolVersionIndex,
bool &IsDefault,
208 SmallVector<std::optional<VersionEntry>, 0> &VersionMap,
209 std::optional<bool> IsSymHidden)
const;
216 Elf_Shdr_Range Sections)
const;
221 Elf_Shdr_Range Sections)
const;
235 const Elf_Shdr *SymTab)
const;
238 loadVersionMap(
const Elf_Shdr *VerNeedSec,
const Elf_Shdr *VerDefSec)
const;
264 return getSectionContentsAsArray<Elf_Sym>(*Sec);
268 return getSectionContentsAsArray<Elf_Rela>(Sec);
272 return getSectionContentsAsArray<Elf_Rel>(Sec);
276 return getSectionContentsAsArray<Elf_Relr>(Sec);
292 if (PhOff + HeadersSize < PhOff || PhOff + HeadersSize >
getBufSize())
293 return createError(
"program headers are longer than binary of size " +
299 auto *Begin =
reinterpret_cast<const Elf_Phdr *
>(
base() + PhOff);
313 if (Phdr.p_offset + Phdr.p_filesz >
getBufSize()) {
317 return Elf_Note_Iterator(Err);
319 return Elf_Note_Iterator(
base() + Phdr.p_offset, Phdr.p_filesz, Err);
336 return Elf_Note_Iterator(Err);
338 return Elf_Note_Iterator(
base() +
Shdr.sh_offset,
Shdr.sh_size, Err);
343 return Elf_Note_Iterator();
371 Elf_Shdr_Range Sections,
376 const Elf_Shdr *SymTab,
379 Elf_Sym_Range Symtab,
391 template <
typename T>
401 decodeBBAddrMap(
const Elf_Shdr &Sec,
const Elf_Shdr *RelaSec =
nullptr)
const;
422 if (
Index >= Sections.size())
424 return &Sections[
Index];
432 if (!ShndxTable.
First)
434 "found an extended symbol index (" +
Twine(SymIndex) +
435 "), but unable to locate the extended symbol index table");
439 return createError(
"unable to read an extended symbol table at index " +
440 Twine(SymIndex) +
": " +
452 getExtendedSymbolTableIndex<ELFT>(Sym, &Sym - Syms.begin(), ShndxTable);
455 return *ErrorOrIndex;
466 auto SymsOrErr = symbols(SymTab);
468 return SymsOrErr.takeError();
469 return getSection(Sym, *SymsOrErr, ShndxTable);
476 auto IndexOrErr = getSectionIndex(Sym, Symbols, ShndxTable);
478 return IndexOrErr.takeError();
488 auto SymsOrErr = symbols(Sec);
490 return SymsOrErr.takeError();
492 Elf_Sym_Range Symbols = *SymsOrErr;
493 if (
Index >= Symbols.size())
494 return createError(
"unable to get symbol from section " +
496 ": invalid symbol index (" +
Twine(
Index) +
")");
497 return &Symbols[
Index];
504 if (Sec.sh_entsize !=
sizeof(
T) &&
sizeof(
T) != 1)
506 " has invalid sh_entsize: expected " +
Twine(
sizeof(
T)) +
507 ", but got " +
Twine(Sec.sh_entsize));
509 uintX_t
Offset = Sec.sh_offset;
510 uintX_t
Size = Sec.sh_size;
512 if (
Size %
sizeof(
T))
514 " has an invalid sh_size (" +
Twine(
Size) +
515 ") which is not a multiple of its sh_entsize (" +
516 Twine(Sec.sh_entsize) +
")");
517 if (std::numeric_limits<uintX_t>::max() -
Offset <
Size)
521 ") that cannot be represented");
526 ") that is greater than the file size (0x" +
533 const T *Start =
reinterpret_cast<const T *
>(base() +
Offset);
540 uintX_t
Offset = Phdr.p_offset;
541 uintX_t
Size = Phdr.p_filesz;
543 if (std::numeric_limits<uintX_t>::max() -
Offset <
Size)
547 ") that cannot be represented");
552 ") that is greater than the file size (0x" +
560 return getSectionContentsAsArray<uint8_t>(Sec);
571 if (!isMipsELF64()) {
573 Result.append(
Name.begin(),
Name.end());
581 uint8_t Type1 = (
Type >> 0) & 0xFF;
587 Result.append(
Name.begin(),
Name.end());
590 Result.append(1,
'/');
591 Result.append(
Name.begin(),
Name.end());
594 Result.append(1,
'/');
595 Result.append(
Name.begin(),
Name.end());
607 const Elf_Shdr *VerDefSec)
const {
615 auto InsertEntry = [&](
unsigned N,
StringRef Version,
bool IsVerdef) {
616 if (
N >= VersionMap.
size())
618 VersionMap[
N] = {std::string(Version), IsVerdef};
625 for (
const VerDef &Def : *Defs)
633 for (
const VerNeed &Dep : *Deps)
634 for (
const VernAux &Aux : Dep.AuxV)
644 const Elf_Shdr *SymTab)
const {
648 return getEntry<Elf_Sym>(*SymTab,
Index);
661 if (Sections.empty())
663 "e_shstrndx == SHN_XINDEX, but the section header table is empty");
665 Index = Sections[0].sh_link;
671 return FakeSectionStrings;
673 if (
Index >= Sections.size())
676 return getStringTable(Sections[
Index], WarnHandler);
685 const void *BufEnd) {
686 using Elf_Word =
typename ELFT::Word;
687 if (Table.nbuckets == 0)
688 return Table.symndx + 1;
691 for (Elf_Word Val : Table.buckets())
692 LastSymIdx = std::max(LastSymIdx, (
uint64_t)Val);
694 reinterpret_cast<const Elf_Word *
>(Table.values(LastSymIdx).end());
696 while (It < BufEnd && (*It & 1) == 0) {
703 "no terminator found for GNU hash section before buffer end");
705 return LastSymIdx + 1;
715 if (!SectionsOrError)
717 for (
const Elf_Shdr &Sec : *SectionsOrError) {
719 if (Sec.sh_size % Sec.sh_entsize != 0) {
721 "SHT_DYNSYM section has sh_size (" +
722 Twine(Sec.sh_size) +
") % sh_entsize (" +
723 Twine(Sec.sh_entsize) +
") that is not 0");
725 return Sec.sh_size / Sec.sh_entsize;
729 if (!SectionsOrError->empty()) {
740 std::optional<uint64_t> ElfHash;
741 std::optional<uint64_t> ElfGnuHash;
742 for (
const Elf_Dyn &Entry : *DynTable) {
743 switch (Entry.d_tag) {
745 ElfHash = Entry.d_un.d_ptr;
747 case ELF::DT_GNU_HASH:
748 ElfGnuHash = Entry.d_un.d_ptr;
756 const Elf_GnuHash *Table =
757 reinterpret_cast<const Elf_GnuHash *
>(TablePtr.
get());
758 return getDynSymtabSizeFromGnuHash<ELFT>(*Table, this->Buf.
bytes_end());
766 const Elf_Hash *Table =
reinterpret_cast<const Elf_Hash *
>(TablePtr.
get());
767 return Table->nchain;
776 if (
sizeof(Elf_Ehdr) >
Object.size())
778 ") is smaller than an ELF header (" +
779 Twine(
sizeof(Elf_Ehdr)) +
")");
787 if (!FakeSections.empty())
789 auto PhdrsOrErr = program_headers();
793 FakeSectionStrings +=
'\0';
797 Elf_Shdr FakeShdr = {};
800 FakeShdr.sh_addr = Phdr.p_vaddr;
801 FakeShdr.sh_size = Phdr.p_memsz;
802 FakeShdr.sh_offset = Phdr.p_offset;
804 FakeShdr.sh_name = FakeSectionStrings.
size();
805 FakeSectionStrings += (
"PT_LOAD#" +
Twine(
Idx)).str();
806 FakeSectionStrings +=
'\0';
813 const uintX_t SectionTableOffset = getHeader().e_shoff;
814 if (SectionTableOffset == 0) {
815 if (!FakeSections.empty())
816 return ArrayRef(FakeSections.data(), FakeSections.size());
820 if (getHeader().e_shentsize !=
sizeof(Elf_Shdr))
821 return createError(
"invalid e_shentsize in ELF header: " +
822 Twine(getHeader().e_shentsize));
825 if (SectionTableOffset +
sizeof(Elf_Shdr) > FileSize ||
826 SectionTableOffset + (uintX_t)
sizeof(Elf_Shdr) < SectionTableOffset)
828 "section header table goes past the end of the file: e_shoff = 0x" +
832 if (SectionTableOffset & (
alignof(Elf_Shdr) - 1))
834 return createError(
"invalid alignment of section headers");
836 const Elf_Shdr *First =
837 reinterpret_cast<const Elf_Shdr *
>(base() + SectionTableOffset);
839 uintX_t NumSections = getHeader().e_shnum;
840 if (NumSections == 0)
841 NumSections = First->sh_size;
843 if (NumSections >
UINT64_MAX /
sizeof(Elf_Shdr))
844 return createError(
"invalid number of sections specified in the NULL "
845 "section's sh_size field (" +
846 Twine(NumSections) +
")");
848 const uint64_t SectionTableSize = NumSections *
sizeof(Elf_Shdr);
849 if (SectionTableOffset + SectionTableSize < SectionTableOffset)
851 "invalid section header table offset (e_shoff = 0x" +
853 ") or invalid number of sections specified in the first section "
854 "header's sh_size field (0x" +
858 if (SectionTableOffset + SectionTableSize > FileSize)
859 return createError(
"section table goes past the end of file");
860 return ArrayRef(First, NumSections);
869 return SecOrErr.takeError();
870 return getEntry<T>(**SecOrErr, Entry);
882 if (Entry >= Arr.
size())
884 "can't read an entry at 0x" +
886 ": it goes past the end of the section (0x" +
891template <
typename ELFT>
893 uint32_t SymbolVersionIndex,
bool &IsDefault,
894 SmallVector<std::optional<VersionEntry>, 0> &VersionMap,
895 std::optional<bool> IsSymHidden)
const {
906 if (VersionIndex >= VersionMap.size() || !VersionMap[VersionIndex])
907 return createError(
"SHT_GNU_versym section refers to a version index " +
908 Twine(VersionIndex) +
" which is missing");
912 if (!Entry.IsVerDef || IsSymHidden.value_or(
false))
916 return Entry.Name.c_str();
931 const uint8_t *Start = ContentsOrErr->data();
932 const uint8_t *End = Start + ContentsOrErr->size();
934 auto ExtractNextAux = [&](
const uint8_t *&VerdauxBuf,
936 if (VerdauxBuf +
sizeof(Elf_Verdaux) > End)
938 ": version definition " +
Twine(VerDefNdx) +
939 " refers to an auxiliary entry that goes past the end "
942 auto *Verdaux =
reinterpret_cast<const Elf_Verdaux *
>(VerdauxBuf);
943 VerdauxBuf += Verdaux->vda_next;
946 Aux.
Offset = VerdauxBuf - Start;
947 if (Verdaux->vda_name <= StrTabOrErr->size())
948 Aux.
Name = std::string(StrTabOrErr->drop_front(Verdaux->vda_name));
950 Aux.
Name = (
"<invalid vda_name: " +
Twine(Verdaux->vda_name) +
">").str();
954 std::vector<VerDef> Ret;
955 const uint8_t *VerdefBuf = Start;
956 for (
unsigned I = 1;
I <= Sec.sh_info; ++
I) {
957 if (VerdefBuf +
sizeof(Elf_Verdef) > End)
959 ": version definition " +
Twine(
I) +
960 " goes past the end of the section");
962 if (
reinterpret_cast<uintptr_t
>(VerdefBuf) %
sizeof(
uint32_t) != 0)
965 ": found a misaligned version definition entry at offset 0x" +
968 unsigned Version = *
reinterpret_cast<const Elf_Half *
>(VerdefBuf);
971 ": version " +
Twine(Version) +
972 " is not yet supported");
974 const Elf_Verdef *
D =
reinterpret_cast<const Elf_Verdef *
>(VerdefBuf);
975 VerDef &VD = *Ret.emplace(Ret.end());
976 VD.
Offset = VerdefBuf - Start;
981 VD.
Hash =
D->vd_hash;
983 const uint8_t *VerdauxBuf = VerdefBuf +
D->vd_aux;
984 for (
unsigned J = 0; J <
D->vd_cnt; ++J) {
985 if (
reinterpret_cast<uintptr_t
>(VerdauxBuf) %
sizeof(
uint32_t) != 0)
987 ": found a misaligned auxiliary entry at offset 0x" +
995 VD.
Name = AuxOrErr->Name;
997 VD.
AuxV.push_back(*AuxOrErr);
1000 VerdefBuf +=
D->vd_next;
1006template <
class ELFT>
1014 return std::move(
E);
1016 StrTab = *StrTabOrErr;
1024 const uint8_t *Start = ContentsOrErr->data();
1025 const uint8_t *End = Start + ContentsOrErr->size();
1026 const uint8_t *VerneedBuf = Start;
1028 std::vector<VerNeed> Ret;
1029 for (
unsigned I = 1;
I <= Sec.sh_info; ++
I) {
1030 if (VerneedBuf +
sizeof(Elf_Verdef) > End)
1032 ": version dependency " +
Twine(
I) +
1033 " goes past the end of the section");
1035 if (
reinterpret_cast<uintptr_t
>(VerneedBuf) %
sizeof(
uint32_t) != 0)
1037 "invalid " +
describe(*
this, Sec) +
1038 ": found a misaligned version dependency entry at offset 0x" +
1041 unsigned Version = *
reinterpret_cast<const Elf_Half *
>(VerneedBuf);
1044 ": version " +
Twine(Version) +
1045 " is not yet supported");
1047 const Elf_Verneed *Verneed =
1048 reinterpret_cast<const Elf_Verneed *
>(VerneedBuf);
1050 VerNeed &VN = *Ret.emplace(Ret.end());
1051 VN.
Version = Verneed->vn_version;
1052 VN.
Cnt = Verneed->vn_cnt;
1053 VN.
Offset = VerneedBuf - Start;
1055 if (Verneed->vn_file < StrTab.
size())
1056 VN.
File = std::string(StrTab.
data() + Verneed->vn_file);
1058 VN.
File = (
"<corrupt vn_file: " +
Twine(Verneed->vn_file) +
">").str();
1060 const uint8_t *VernauxBuf = VerneedBuf + Verneed->vn_aux;
1061 for (
unsigned J = 0; J < Verneed->vn_cnt; ++J) {
1062 if (
reinterpret_cast<uintptr_t
>(VernauxBuf) %
sizeof(
uint32_t) != 0)
1064 ": found a misaligned auxiliary entry at offset 0x" +
1067 if (VernauxBuf +
sizeof(Elf_Vernaux) > End)
1069 "invalid " +
describe(*
this, Sec) +
": version dependency " +
1071 " refers to an auxiliary entry that goes past the end "
1074 const Elf_Vernaux *Vernaux =
1075 reinterpret_cast<const Elf_Vernaux *
>(VernauxBuf);
1078 Aux.
Hash = Vernaux->vna_hash;
1079 Aux.
Flags = Vernaux->vna_flags;
1080 Aux.
Other = Vernaux->vna_other;
1081 Aux.
Offset = VernauxBuf - Start;
1082 if (StrTab.
size() <= Vernaux->vna_name)
1083 Aux.
Name =
"<corrupt>";
1087 VernauxBuf += Vernaux->vna_next;
1089 VerneedBuf += Verneed->vn_next;
1094template <
class ELFT>
1097 auto TableOrErr = sections();
1099 return TableOrErr.takeError();
1100 return object::getSection<ELFT>(*TableOrErr,
Index);
1103template <
class ELFT>
1108 if (
Error E = WarnHandler(
"invalid sh_type for string table section " +
1110 ": expected SHT_STRTAB, but got " +
1112 getHeader().e_machine, Section.sh_type)))
1113 return std::move(
E);
1115 auto V = getSectionContentsAsArray<char>(Section);
1117 return V.takeError();
1120 return createError(
"SHT_STRTAB string table section " +
1122 if (
Data.back() !=
'\0')
1123 return createError(
"SHT_STRTAB string table section " +
1125 " is non-null terminated");
1129template <
class ELFT>
1132 auto SectionsOrErr = sections();
1134 return SectionsOrErr.takeError();
1135 return getSHNDXTable(Section, *SectionsOrErr);
1138template <
class ELFT>
1141 Elf_Shdr_Range Sections)
const {
1143 auto VOrErr = getSectionContentsAsArray<Elf_Word>(Section);
1145 return VOrErr.takeError();
1147 auto SymTableOrErr = object::getSection<ELFT>(Sections, Section.sh_link);
1149 return SymTableOrErr.takeError();
1150 const Elf_Shdr &SymTable = **SymTableOrErr;
1154 "SHT_SYMTAB_SHNDX section is linked with " +
1156 " section (expected SHT_SYMTAB/SHT_DYNSYM)");
1158 uint64_t Syms = SymTable.sh_size /
sizeof(Elf_Sym);
1159 if (V.size() != Syms)
1161 " entries, but the symbol table associated has " +
1167template <
class ELFT>
1170 auto SectionsOrErr = sections();
1172 return SectionsOrErr.takeError();
1173 return getStringTableForSymtab(Sec, *SectionsOrErr);
1176template <
class ELFT>
1179 Elf_Shdr_Range Sections)
const {
1183 "invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM");
1185 object::getSection<ELFT>(Sections, Sec.sh_link);
1188 return getStringTable(**SectionOrErr);
1191template <
class ELFT>
1196 if (!StrTabSecOrErr)
1202 return createError(
"invalid string table linked to " +
1205 return *StrTabOrErr;
1208template <
class ELFT>
1212 auto SectionsOrErr = sections();
1214 return SectionsOrErr.takeError();
1215 auto Table = getSectionStringTable(*SectionsOrErr, WarnHandler);
1217 return Table.takeError();
1218 return getSectionName(Section, *Table);
1221template <
class ELFT>
1229 " has an invalid sh_name (0x" +
1231 ") offset which goes past the end of the "
1232 "section name string table");
1241 for (
char C : SymbolName) {
1243 g = h & 0xf0000000L;
1256 for (uint8_t
C :
Name)
1257 H = (
H << 5) +
H +
C;
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool isMips64EL(const ELFYAML::Object &Obj)
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
This file implements a map that provides insertion order iteration.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
INLINE void g(uint32_t *state, size_t a, size_t b, size_t c, size_t d, uint32_t x, uint32_t y)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Helper for Errors used as out-parameters.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
const unsigned char * bytes_end() const
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
size - Get the string size.
const unsigned char * bytes_begin() const
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(const uint64_t &Val)
The instances of the Type class are immutable: once they are created, they are never changed.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
const Elf_Ehdr & getHeader() const
Expected< std::vector< Elf_Rela > > android_relas(const Elf_Shdr &Sec) const
Expected< StringRef > getLinkAsStrtab(const typename ELFT::Shdr &Sec) const
static Expected< ELFFile > create(StringRef Object)
Expected< const Elf_Sym * > getSymbol(const Elf_Shdr *Sec, uint32_t Index) const
Expected< std::vector< VerDef > > getVersionDefinitions(const Elf_Shdr &Sec) const
std::string getDynamicTagAsString(unsigned Arch, uint64_t Type) const
Expected< ArrayRef< Elf_Word > > getSHNDXTable(const Elf_Shdr &Section) const
Expected< Elf_Sym_Range > symbols(const Elf_Shdr *Sec) const
Expected< std::vector< BBAddrMap > > decodeBBAddrMap(const Elf_Shdr &Sec, const Elf_Shdr *RelaSec=nullptr) const
Returns a vector of BBAddrMap structs corresponding to each function within the text section that the...
Expected< ArrayRef< uint8_t > > getSegmentContents(const Elf_Phdr &Phdr) const
Elf_Note_Iterator notes_begin(const Elf_Shdr &Shdr, Error &Err) const
Get an iterator over notes in a section.
uint32_t getRelativeRelocationType() const
iterator_range< Elf_Note_Iterator > notes(const Elf_Phdr &Phdr, Error &Err) const
Get an iterator range over notes of a program header.
Expected< StringRef > getSymbolVersionByIndex(uint32_t SymbolVersionIndex, bool &IsDefault, SmallVector< std::optional< VersionEntry >, 0 > &VersionMap, std::optional< bool > IsSymHidden) const
Elf_Note_Iterator notes_begin(const Elf_Phdr &Phdr, Error &Err) const
Get an iterator over notes in a program header.
Expected< ArrayRef< uint8_t > > getSectionContents(const Elf_Shdr &Sec) const
Expected< Elf_Rela_Range > relas(const Elf_Shdr &Sec) const
Expected< Elf_Phdr_Range > program_headers() const
Iterate over program header table.
Expected< StringRef > getStringTableForSymtab(const Elf_Shdr &Section) const
Expected< std::vector< VerNeed > > getVersionDependencies(const Elf_Shdr &Sec, WarningHandler WarnHandler=&defaultWarningHandler) const
size_t getBufSize() const
Expected< const T * > getEntry(uint32_t Section, uint32_t Entry) const
Expected< const Elf_Sym * > getRelocationSymbol(const Elf_Rel &Rel, const Elf_Shdr *SymTab) const
Get the symbol for a given relocation.
const uint8_t * end() const
Expected< StringRef > getSectionStringTable(Elf_Shdr_Range Sections, WarningHandler WarnHandler=&defaultWarningHandler) const
Expected< uint64_t > getDynSymtabSize() const
This function determines the number of dynamic symbols.
Expected< Elf_Dyn_Range > dynamicEntries() const
void createFakeSections()
Used by llvm-objdump -d (which needs sections for disassembly) to disassemble objects without a secti...
Expected< Elf_Shdr_Range > sections() const
iterator_range< Elf_Note_Iterator > notes(const Elf_Shdr &Shdr, Error &Err) const
Get an iterator range over notes of a section.
const uint8_t * base() const
Expected< const uint8_t * > toMappedAddr(uint64_t VAddr, WarningHandler WarnHandler=&defaultWarningHandler) const
Expected< Elf_Relr_Range > relrs(const Elf_Shdr &Sec) const
Expected< MapVector< const Elf_Shdr *, const Elf_Shdr * > > getSectionAndRelocations(std::function< Expected< bool >(const Elf_Shdr &)> IsMatch) const
Returns a map from every section matching IsMatch to its relocation section, or nullptr if it has no ...
Elf_Note_Iterator notes_end() const
Get the end iterator for notes.
Expected< StringRef > getSectionName(const Elf_Shdr &Section, WarningHandler WarnHandler=&defaultWarningHandler) const
StringRef getRelocationTypeName(uint32_t Type) const
Expected< StringRef > getStringTable(const Elf_Shdr &Section, WarningHandler WarnHandler=&defaultWarningHandler) const
llvm::function_ref< Error(const Twine &Msg)> WarningHandler
Expected< ArrayRef< T > > getSectionContentsAsArray(const Elf_Shdr &Sec) const
Expected< SmallVector< std::optional< VersionEntry >, 0 > > loadVersionMap(const Elf_Shdr *VerNeedSec, const Elf_Shdr *VerDefSec) const
Expected< Elf_Rel_Range > rels(const Elf_Shdr &Sec) const
Expected< const Elf_Shdr * > getSection(const Elf_Sym &Sym, const Elf_Shdr *SymTab, DataRegion< Elf_Word > ShndxTable) const
std::vector< Elf_Rel > decode_relrs(Elf_Relr_Range relrs) const
Expected< uint32_t > getSectionIndex(const Elf_Sym &Sym, Elf_Sym_Range Syms, DataRegion< Elf_Word > ShndxTable) const
@ C
The default llvm calling convention, compatible with C.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
Expected< uint32_t > getExtendedSymbolTableIndex(const typename ELFT::Sym &Sym, unsigned SymIndex, DataRegion< typename ELFT::Word > ShndxTable)
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
Error createError(const Twine &Err)
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type)
static Expected< uint64_t > getDynSymtabSizeFromGnuHash(const typename ELFT::GnuHash &Table, const void *BufEnd)
This function finds the number of dynamic symbols using a GNU hash table.
uint32_t getELFRelativeRelocationType(uint32_t Machine)
static std::string describe(const ELFFile< ELFT > &Obj, const typename ELFT::Shdr &Sec)
std::string getPhdrIndexForError(const ELFFile< ELFT > &Obj, const typename ELFT::Phdr &Phdr)
uint32_t hashGnu(StringRef Name)
This function returns the hash value for a symbol in the .dynsym section for the GNU hash table.
StringRef getELFSectionTypeName(uint32_t Machine, uint32_t Type)
unsigned hashSysV(StringRef SymbolName)
This function returns the hash value for a symbol in the .dynsym section Name of the API remains cons...
@ ADDIS_R12_TO_R2_NO_DISP
@ ADDI_R12_TO_R12_NO_DISP
std::pair< unsigned char, unsigned char > getElfArchType(StringRef Object)
static Error defaultWarningHandler(const Twine &Msg)
std::string getSecIndexForError(const ELFFile< ELFT > &Obj, const typename ELFT::Shdr &Sec)
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are are tuples (A,...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
void consumeError(Error Err)
Consume a Error without doing anything.
Expected< T > operator[](uint64_t N)
DataRegion(const T *Data, const uint8_t *BufferEnd)
DataRegion(ArrayRef< T > Arr)
std::optional< uint64_t > Size
std::vector< VerdAux > AuxV
std::vector< VernAux > AuxV