LLVM: include/llvm/Object/ELFObjectFile.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_OBJECT_ELFOBJECTFILE_H
14#define LLVM_OBJECT_ELFOBJECTFILE_H
15
39#include
40#include
41
42namespace llvm {
43
45
47
51
53
58};
59
64
70
71 StringRef getAMDGPUCPUName() const;
72 StringRef getNVPTXCPUName() const;
73
74protected:
76
81
85
88
89public:
91
93
94
96
98
99 static bool classof(const Binary *v) { return v->isELF(); }
100
102
103 std::optional tryGetCPUName() const override;
104
105 void setARMSubArch(Triple &TheTriple) const override;
106
108
110
112
114
115
116
118
119
120
121
122
123
124
125
127 readBBAddrMap(std::optional TextSectionIndex = std::nullopt,
128 std::vector *PGOAnalyses = nullptr) const;
129
131};
132
134public:
138
142
146
150
154};
155
170
172public:
176
180
184
188
192
196
200 if (EE.Value == Type) {
201 return EE.AltName;
202 }
203 }
204 return "";
205 }
206};
207
209 const DataRefImpl &DRIA = A.getRawDataRefImpl();
210 const DataRefImpl &DRIB = B.getRawDataRefImpl();
212 return DRIA.d.b < DRIB.d.b;
213 return DRIA.d.a < DRIB.d.a;
214}
215
230
245
262
267
273
274public:
276
280
284
286
287private:
291
292 bool ContentValid = false;
293
294protected:
296
297 const Elf_Shdr *DotDynSymSec = nullptr;
298 const Elf_Shdr *DotSymtabSec = nullptr;
300
301
304
306
319 const Elf_Shdr *SymTab) const;
321
343
350
355
358 if (!SymTable) {
361 return DRI;
362 }
365
366 auto SectionsOrErr = EF.sections();
367 if (!SectionsOrErr) {
370 return DRI;
371 }
372 uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
373 unsigned SymTableIndex =
374 (reinterpret_cast<uintptr_t>(SymTable) - SHT) / sizeof(Elf_Shdr);
375
378 return DRI;
379 }
380
382 return reinterpret_cast<const Elf_Shdr *>(Sec.p);
383 }
384
387 DRI.p = reinterpret_cast<uintptr_t>(Sec);
388 return DRI;
389 }
390
393 DRI.p = reinterpret_cast<uintptr_t>(Dyn);
394 return DRI;
395 }
396
398 unsigned char Binding = ESym->getBinding();
399 unsigned char Visibility = ESym->getVisibility();
400
401
402
403
404 return (
408 }
409
415 break;
418 break;
421 break;
424 break;
425 default:
427 }
428
429 auto SectionsOrErr = EF.sections();
430 if (!SectionsOrErr)
431 return SectionsOrErr.takeError();
432 for (const Elf_Shdr &Sec : *SectionsOrErr) {
433 if (Sec.sh_type != Type)
434 continue;
435 auto ErrorOrContents = EF.getSectionContents(Sec);
436 if (!ErrorOrContents)
437 return ErrorOrContents.takeError();
438
439 auto Contents = ErrorOrContents.get();
442
443 if (Error E = Attributes.parse(Contents, ELFT::Endianness))
444 return E;
445 break;
446 }
448 }
449
450
451
452
454
455public:
458 bool InitContent = true);
459
463
465 return EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);
466 }
467
468
470 auto RelSecOrErr = EF.getSection(Rel.d.a);
471 if (!RelSecOrErr)
474 return *RelSecOrErr;
475 }
476
478 return reinterpret_cast<const Elf_Shdr *>(Sec.p);
479 }
480
483
485
488
491
493
499
501
503
506 return v->getType() ==
508 ELFT::Is64Bits);
509 }
510
512
514
516
518};
519
524
525template
529
531 auto SectionsOrErr = EF.sections();
532 if (!SectionsOrErr)
533 return SectionsOrErr.takeError();
534
535 for (const Elf_Shdr &Sec : *SectionsOrErr) {
536 switch (Sec.sh_type) {
540 break;
541 }
545 break;
546 }
550 break;
551 }
552 }
553 }
554
555 ContentValid = true;
557}
558
559template
562 if (!SymOrErr)
564 auto SymTabOrErr = EF.getSection(Sym.d.a);
565 if (!SymTabOrErr)
566 return SymTabOrErr.takeError();
567 const Elf_Shdr *SymTableSec = *SymTabOrErr;
568 auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
569 if (!StrTabOrErr)
570 return StrTabOrErr.takeError();
571 const Elf_Shdr *StringTableSec = *StrTabOrErr;
572 auto SymStrTabOrErr = EF.getStringTable(*StringTableSec);
573 if (!SymStrTabOrErr)
574 return SymStrTabOrErr.takeError();
576 if (Name && !Name->empty())
577 return Name;
578
579
582 if (SecOrErr)
583 return (*SecOrErr)->getName();
585 }
586 return Name;
587}
588
589template
593
594template
598
599template
603
604template
607 if (!SymOrErr)
609
610 uint64_t Ret = (*SymOrErr)->st_value;
612 return Ret;
613
614 const Elf_Ehdr &Header = EF.getHeader();
615
618 Ret &= ~1;
619
620 return Ret;
621}
622
623template
627 if (!SymbolValueOrErr)
628
629 return SymbolValueOrErr.takeError();
630
631 uint64_t Result = *SymbolValueOrErr;
633 if (!SymOrErr)
635
636 switch ((*SymOrErr)->st_shndx) {
640 return Result;
641 }
642
643 auto SymTabOrErr = EF.getSection(Symb.d.a);
644 if (!SymTabOrErr)
645 return SymTabOrErr.takeError();
646
650
653 ShndxTable = *ShndxTableOrErr;
654 else
655 return ShndxTableOrErr.takeError();
656 }
657
659 EF.getSection(**SymOrErr, *SymTabOrErr, ShndxTable);
660 if (!SectionOrErr)
662 const Elf_Shdr *Section = *SectionOrErr;
663 if (Section)
664 Result += Section->sh_addr;
665 }
666
667 return Result;
668}
669
670template
673 if (!SymOrErr)
676 return (*SymOrErr)->st_value;
677 return 0;
678}
679
680template
682 return EF.getHeader().e_machine;
683}
684
686 return EF.getHeader().e_type;
687}
688
691}
692
693template
694uint64_t ELFObjectFile::getSymbolSize(DataRefImpl Sym) const {
695 Expected<const Elf_Sym *> SymOrErr = getSymbol(Sym);
696 if (!SymOrErr)
698 return (*SymOrErr)->st_size;
699}
700
701template
703 return getSymbolSize(Symb);
704}
705
706template
709 if (!SymOrErr)
711 return (*SymOrErr)->getBinding();
712}
713
714template
717 if (!SymOrErr)
719 return (*SymOrErr)->st_other;
720}
721
722template
725 if (!SymOrErr)
727 return (*SymOrErr)->getType();
728}
729
730template
734 if (!SymOrErr)
736
737 switch ((*SymOrErr)->getType()) {
750 default:
752 }
753}
754
755template
758 if (!SymOrErr)
760
761 const Elf_Sym *ESym = *SymOrErr;
763
766
769
772
775
778
779 if (ESym == SymbolsOrErr->begin())
781 } else
782
783 return SymbolsOrErr.takeError();
784
787
788 if (ESym == SymbolsOrErr->begin())
790 } else
791
792 return SymbolsOrErr.takeError();
793
797 if (Name.starts_with("$d") || Name.starts_with("$x"))
799 } else {
800
802 }
803 } else if (EF.getHeader().e_machine == ELF::EM_ARM) {
806
807 if (Name.empty() || Name.starts_with("$d") || Name.starts_with("$t") ||
808 Name.starts_with("$a"))
810 } else {
811
813 }
814 if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1)
816 } else if (EF.getHeader().e_machine == ELF::EM_CSKY) {
819 if (Name.starts_with("$d") || Name.starts_with("$t"))
821 } else {
822
824 }
828
829 if (Name == ".L0 " || Name.starts_with("$d") || Name.starts_with("$x"))
831 } else {
832
834 }
835 }
836
839
842
845
848
851
852 return Result;
853}
854
855template
858 const Elf_Shdr *SymTab) const {
861
864 if (!ShndxTableOrErr)
865 return ShndxTableOrErr.takeError();
866 ShndxTable = *ShndxTableOrErr;
867 }
868
869 auto ESecOrErr = EF.getSection(*ESym, SymTab, ShndxTable);
870 if (!ESecOrErr)
871 return ESecOrErr.takeError();
872
873 const Elf_Shdr *ESec = *ESecOrErr;
874 if (!ESec)
876
878 Sec.p = reinterpret_cast<intptr_t>(ESec);
880}
881
882template
886 if (!SymOrErr)
888
889 auto SymTabOrErr = EF.getSection(Symb.d.a);
890 if (!SymTabOrErr)
891 return SymTabOrErr.takeError();
893}
894
895template
900
901template
905
906template
910
911template
913 auto SectionsOrErr = EF.sections();
916 llvm_unreachable("unable to get section index");
917 });
918 const Elf_Shdr *First = SectionsOrErr->begin();
920}
921
922template
926
927template
930 const Elf_Shdr *EShdr = getSection(Sec);
935 (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
936 return std::move(E);
937 return ArrayRef((const uint8_t *)base() + EShdr->sh_offset, EShdr->sh_size);
938}
939
940template
944
945template
949
950template
954
955template
962
963template
968
969template
970std::vector
972 std::vector Res;
973 std::vector<uintptr_t> Offsets;
974
975 auto SectionsOrErr = EF.sections();
976 if (!SectionsOrErr)
977 return Res;
978
979 for (const Elf_Shdr &Sec : *SectionsOrErr) {
981 continue;
983 reinterpret_cast<Elf_Dyn *>((uintptr_t)base() + Sec.sh_offset);
985 if (Dynamic->d_tag == ELF::DT_REL || Dynamic->d_tag == ELF::DT_RELA ||
986 Dynamic->d_tag == ELF::DT_JMPREL) {
987 Offsets.push_back(Dynamic->d_un.d_val);
988 }
989 }
990 }
991 for (const Elf_Shdr &Sec : *SectionsOrErr) {
993 Res.emplace_back(toDRI(&Sec), this);
994 }
995 return Res;
996}
997
998template
1002
1003template
1009
1010template
1012 const Elf_Shdr *EShdr = getSection(Sec);
1015}
1016
1017template
1020 if (!SectionNameOrErr) {
1021
1023 return false;
1024 }
1026 return SectionName.starts_with(".debug") ||
1028}
1029
1030template
1034 auto SectionsOrErr = EF.sections();
1035 if (!SectionsOrErr)
1037 uintptr_t SHT = reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
1038 RelData.d.a = (Sec.p - SHT) / EF.getHeader().e_shentsize;
1040 if (reinterpret_cast<const Elf_Shdr *>(Sec.p)->sh_type == ELF::SHT_CREL) {
1041 if (RelData.d.a + 1 > Crels.size())
1042 Crels.resize(RelData.d.a + 1);
1043 auto &Crel = Crels[RelData.d.a];
1044 if (Crel.empty()) {
1046 size_t I = 0;
1049 [&](Elf_Crel Crel) { Crels[RelData.d.a][I++] = Crel; });
1050 if (Err) {
1051 Crel.assign(1, Elf_Crel{0, 0, 0, 0});
1055 }
1056 }
1057 }
1059}
1060
1061template
1064 const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
1068 RelData.d.b = Crels[RelData.d.a].size();
1070 }
1072 return Begin;
1073 const Elf_Shdr *RelSec = getRelSection(RelData);
1074
1075
1076 auto SymSecOrErr = EF.getSection(RelSec->sh_link);
1077 if (!SymSecOrErr)
1080
1081 RelData.d.b += S->sh_size / S->sh_entsize;
1083}
1084
1085template
1088 const Elf_Shdr *EShdr = getSection(Sec);
1089 uintX_t Type = EShdr->sh_type;
1092
1094 if (!SecOrErr)
1097}
1098
1099
1100template
1104
1105template
1111 symbolIdx = getCrel(Rel).r_symidx;
1113 symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
1114 else
1115 symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
1116 if (!symbolIdx)
1118
1119
1121 SymbolData.d.a = sec->sh_link;
1122 SymbolData.d.b = symbolIdx;
1124}
1125
1126template
1130 return getCrel(Rel).r_offset;
1132 return getRel(Rel)->r_offset;
1133
1134 return getRela(Rel)->r_offset;
1135}
1136
1137template
1141 return getCrel(Rel).r_type;
1143 return getRel(Rel)->getType(EF.isMips64EL());
1144 else
1145 return getRela(Rel)->getType(EF.isMips64EL());
1146}
1147
1148template
1152
1153template
1157 EF.getRelocationTypeName(type, Result);
1158}
1159
1160template
1164 return (int64_t)getRela(Rel)->r_addend;
1166 return (int64_t)getCrel(Rel).r_addend;
1167 return createError("Relocation section does not have addends");
1168}
1169
1170template
1174 auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
1175 if (!Ret)
1177 return *Ret;
1178}
1179
1180template
1184 auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
1185 if (!Ret)
1187 return *Ret;
1188}
1189
1190template
1197
1198template
1202 if (Error E = EFOrErr.takeError())
1203 return std::move(E);
1204
1205 ELFObjectFile Obj = {Object, std::move(*EFOrErr), nullptr, nullptr,
1206 nullptr};
1207 if (InitContent)
1208 if (Error E = Obj.initContent())
1209 return std::move(E);
1210 return std::move(Obj);
1211}
1212
1213template
1215 const Elf_Shdr *DotDynSymSec,
1216 const Elf_Shdr *DotSymtabSec,
1217 const Elf_Shdr *DotSymtabShndx)
1219 ELFT::Is64Bits),
1220 Object),
1221 EF(std::move(EF)), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec),
1222 DotSymtabShndxSec(DotSymtabShndx) {}
1223
1224template
1225ELFObjectFile::ELFObjectFile(ELFObjectFile &&Other)
1228
1229template
1236
1237template
1240 if (!SymTab)
1242 DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1244}
1245
1246template
1255
1256template
1259 if (!SymTab)
1261 DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
1263}
1264
1265template
1267 auto SectionsOrErr = EF.sections();
1268 if (!SectionsOrErr)
1271}
1272
1273template
1275 auto SectionsOrErr = EF.sections();
1276 if (!SectionsOrErr)
1279}
1280
1281template
1283 return ELFT::Is64Bits ? 8 : 4;
1284}
1285
1286template
1291 switch (EF.getHeader().e_machine) {
1293 return "elf32-m68k";
1295 return "elf32-i386";
1297 return "elf32-iamcu";
1299 return "elf32-x86-64";
1301 return (IsLittleEndian ? "elf32-littlearm" : "elf32-bigarm");
1303 return "elf32-avr";
1305 return "elf32-hexagon";
1307 return "elf32-lanai";
1309 return "elf32-mips";
1311 return "elf32-msp430";
1313 return (IsLittleEndian ? "elf32-powerpcle" : "elf32-powerpc");
1315 return (IsLittleEndian ? "elf32-littleriscv" : "elf32-bigriscv");
1317 return "elf32-csky";
1320 return "elf32-sparc";
1322 return "elf32-amdgpu";
1324 return "elf32-loongarch";
1326 return "elf32-xtensa";
1327 default:
1328 return "elf32-unknown";
1329 }
1331 switch (EF.getHeader().e_machine) {
1333 return "elf64-i386";
1335 return "elf64-x86-64";
1337 return (IsLittleEndian ? "elf64-littleaarch64" : "elf64-bigaarch64");
1339 return (IsLittleEndian ? "elf64-powerpcle" : "elf64-powerpc");
1341 return (IsLittleEndian ? "elf64-littleriscv" : "elf64-bigriscv");
1343 return "elf64-s390";
1345 return "elf64-sparc";
1347 return "elf64-mips";
1349 return "elf64-amdgpu";
1351 return "elf64-bpf";
1353 return "elf64-ve";
1355 return "elf64-loongarch";
1356 default:
1357 return "elf64-unknown";
1358 }
1359 default:
1360
1362 }
1363}
1364
1367 switch (EF.getHeader().e_machine) {
1391 default:
1393 }
1406 default:
1408 }
1411
1417
1419 if (!IsLittleEndian)
1421
1429
1431 }
1432
1437 }
1438
1441
1446
1453 default:
1455 }
1456
1459
1460 default:
1462 }
1463}
1464
1490 default:
1492 }
1493}
1494
1495template
1497 return EF.getHeader().e_entry;
1498}
1499
1500template
1505
1509
1510template
1512 uintptr_t SHT = reinterpret_cast<uintptr_t>(cantFail(EF.sections()).begin());
1513 auto I = (Sec.p - SHT) / EF.getHeader().e_shentsize;
1516 return "";
1517}
1518
1519}
1520}
1521
1522#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static StringRef getSymbolName(SymbolKind SymKind)
DXIL Resource Implicit Binding
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< StringRef > ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
static uint64_t getSymbolValue(const MCSymbolCOFF &Symbol, const MCAssembler &Asm)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Base class for error info classes.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
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.
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
A range adaptor for a pair of iterators.
const SymbolicFile * getObject() const
DataRefImpl getRawDataRefImpl() const
static unsigned int getELFType(bool isLE, bool is64Bits)
MemoryBufferRef getMemoryBufferRef() const
static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
static Expected< ELFFile > create(StringRef Object)
Definition ELFObjectFile.h:60
virtual uint64_t getSymbolSize(DataRefImpl Symb) const =0
friend class ELFRelocationRef
Definition ELFObjectFile.h:61
virtual uint8_t getEIdentABIVersion() const =0
friend class ELFSectionRef
Definition ELFObjectFile.h:62
virtual Error getBuildAttributes(ELFAttributeParser &Attributes) const =0
std::vector< ELFPltEntry > getPltEntries(const MCSubtargetInfo &STI) const
virtual uint64_t getSectionFlags(DataRefImpl Sec) const =0
virtual uint16_t getEType() const =0
virtual uint8_t getSymbolELFType(DataRefImpl Symb) const =0
Expected< std::vector< VersionEntry > > readDynsymVersions() const
Returns a vector containing a symbol version for each dynamic symbol.
virtual uint8_t getSymbolOther(DataRefImpl Symb) const =0
virtual elf_symbol_iterator_range getDynamicSymbolIterators() const =0
virtual uint32_t getSectionType(DataRefImpl Sec) const =0
friend class ELFSymbolRef
Definition ELFObjectFile.h:63
StringRef getCrelDecodeProblem(SectionRef Sec) const
elf_symbol_iterator_range symbols() const
Definition ELFObjectFile.h:264
virtual Expected< int64_t > getRelocationAddend(DataRefImpl Rel) const =0
virtual uint8_t getSymbolBinding(DataRefImpl Symb) const =0
iterator_range< elf_symbol_iterator > elf_symbol_iterator_range
Definition ELFObjectFile.h:90
virtual uint16_t getEMachine() const =0
static bool classof(const Binary *v)
Definition ELFObjectFile.h:99
virtual unsigned getPlatformFlags() const =0
Returns platform-specific object flags, if any.
ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source)
virtual uint64_t getSectionOffset(DataRefImpl Sec) const =0
Expected< std::vector< BBAddrMap > > readBBAddrMap(std::optional< unsigned > TextSectionIndex=std::nullopt, std::vector< PGOAnalysisMap > *PGOAnalyses=nullptr) const
Returns a vector of all BB address maps in the object file.
Definition ELFObjectFile.h:268
static bool classof(const Binary *v)
Definition ELFObjectFile.h:505
const ELFFile< ELFT > & getELFFile() const
Definition ELFObjectFile.h:502
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
Definition ELFObjectFile.h:902
std::vector< SectionRef > dynamic_relocation_sections() const override
Definition ELFObjectFile.h:971
uint64_t getRelocationType(DataRefImpl Rel) const override
Definition ELFObjectFile.h:1138
bool isSectionText(DataRefImpl Sec) const override
Definition ELFObjectFile.h:951
uint8_t getSymbolELFType(DataRefImpl Symb) const override
Definition ELFObjectFile.h:723
uint64_t getSectionAlignment(DataRefImpl Sec) const override
Definition ELFObjectFile.h:941
bool is64Bit() const override
Definition ELFObjectFile.h:484
DataRefImpl toDRI(const Elf_Dyn *Dyn) const
Definition ELFObjectFile.h:391
bool isSectionVirtual(DataRefImpl Sec) const override
Definition ELFObjectFile.h:999
Triple::OSType getOS() const override
Definition ELFObjectFile.h:1465
bool isDyldELFObject
Definition ELFObjectFile.h:453
SectionRef toSectionRef(const Elf_Shdr *Sec) const
Definition ELFObjectFile.h:277
ELFFile< ELFT > EF
Definition ELFObjectFile.h:295
bool IsContentValid() const
Definition ELFObjectFile.h:285
uint32_t getSectionType(DataRefImpl Sec) const override
Definition ELFObjectFile.h:595
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
Definition ELFObjectFile.h:1107
elf_symbol_iterator_range getDynamicSymbolIterators() const override
Definition ELFObjectFile.h:1502
void createFakeSections()
Definition ELFObjectFile.h:515
Expected< const Elf_Sym * > getSymbol(DataRefImpl Sym) const
Definition ELFObjectFile.h:464
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
Definition ELFObjectFile.h:884
StringRef getRelocationTypeName(uint32_t Type) const
Definition ELFObjectFile.h:1149
const Elf_Rel * getRel(DataRefImpl Rel) const
Definition ELFObjectFile.h:1172
Elf_Crel getCrel(DataRefImpl Crel) const
Definition ELFObjectFile.h:1192
ELFObjectFile(ELFObjectFile< ELFT > &&Other)
Definition ELFObjectFile.h:1225
Expected< section_iterator > getSymbolSection(const Elf_Sym *Symb, const Elf_Shdr *SymTab) const
Definition ELFObjectFile.h:857
bool isDyldType() const
Definition ELFObjectFile.h:504
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
Definition ELFObjectFile.h:605
basic_symbol_iterator symbol_begin() const override
Definition ELFObjectFile.h:1230
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
Definition ELFObjectFile.h:625
ELFSymbolRef toSymbolRef(const Elf_Shdr *SymTable, unsigned SymbolNum) const
Definition ELFObjectFile.h:281
SmallVector< std::string, 0 > CrelDecodeProblems
Definition ELFObjectFile.h:303
const Elf_Rela * getRela(DataRefImpl Rela) const
Definition ELFObjectFile.h:1182
static Expected< ELFObjectFile< ELFT > > create(MemoryBufferRef Object, bool InitContent=true)
Definition ELFObjectFile.h:1200
bool isExportedToOtherDSO(const Elf_Sym *ESym) const
Definition ELFObjectFile.h:397
uint64_t getSectionAddress(DataRefImpl Sec) const override
Definition ELFObjectFile.h:907
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
Definition ELFObjectFile.h:929
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
Definition ELFObjectFile.h:1154
uint64_t getSectionIndex(DataRefImpl Sec) const override
Definition ELFObjectFile.h:912
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Definition ELFObjectFile.h:756
bool isSectionData(DataRefImpl Sec) const override
Definition ELFObjectFile.h:956
const Elf_Shdr * DotSymtabSec
Definition ELFObjectFile.h:298
const Elf_Shdr * DotDynSymSec
Definition ELFObjectFile.h:297
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
Definition ELFObjectFile.h:671
const Elf_Shdr * toELFShdrIter(DataRefImpl Sec) const
Definition ELFObjectFile.h:381
Triple::ArchType getArch() const override
Definition ELFObjectFile.h:1365
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
Definition ELFObjectFile.h:702
uint64_t getSectionSize(DataRefImpl Sec) const override
Definition ELFObjectFile.h:923
bool isBerkeleyData(DataRefImpl Sec) const override
Definition ELFObjectFile.h:1011
StringRef getFileFormatName() const override
Definition ELFObjectFile.h:1287
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
Definition ELFObjectFile.h:1506
void moveSymbolNext(DataRefImpl &Symb) const override
Definition ELFObjectFile.h:526
uint8_t getSymbolOther(DataRefImpl Symb) const override
Definition ELFObjectFile.h:715
section_iterator section_end() const override
Definition ELFObjectFile.h:1274
const Elf_Shdr * getRelSection(DataRefImpl Rel) const
Get the relocation section that contains Rel.
Definition ELFObjectFile.h:469
Expected< int64_t > getRelocationAddend(DataRefImpl Rel) const override
Definition ELFObjectFile.h:1162
uint64_t getRelocationOffset(DataRefImpl Rel) const override
Definition ELFObjectFile.h:1127
Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const override
Definition ELFObjectFile.h:1087
void moveSectionNext(DataRefImpl &Sec) const override
Definition ELFObjectFile.h:896
bool isSectionBSS(DataRefImpl Sec) const override
Definition ELFObjectFile.h:964
unsigned getPlatformFlags() const override
Returns platform-specific object flags, if any.
Definition ELFObjectFile.h:500
uint64_t getSectionFlags(DataRefImpl Sec) const override
Definition ELFObjectFile.h:590
void moveRelocationNext(DataRefImpl &Rel) const override
Definition ELFObjectFile.h:1101
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
Definition ELFObjectFile.h:1032
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
Definition ELFObjectFile.h:560
Error initContent() override
Definition ELFObjectFile.h:530
basic_symbol_iterator symbol_end() const override
Definition ELFObjectFile.h:1238
uint8_t getSymbolBinding(DataRefImpl Symb) const override
Definition ELFObjectFile.h:707
uint64_t getSectionOffset(DataRefImpl Sec) const override
Definition ELFObjectFile.h:600
relocation_iterator section_rel_end(DataRefImpl Sec) const override
Definition ELFObjectFile.h:1063
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
Definition ELFObjectFile.h:732
const Elf_Shdr * getSection(DataRefImpl Sec) const
Definition ELFObjectFile.h:477
Error getBuildAttributes(ELFAttributeParser &Attributes) const override
Definition ELFObjectFile.h:410
DataRefImpl toDRI(const Elf_Shdr *Sec) const
Definition ELFObjectFile.h:385
elf_symbol_iterator dynamic_symbol_begin() const
Definition ELFObjectFile.h:1247
const Elf_Shdr * DotSymtabShndxSec
Definition ELFObjectFile.h:299
elf_symbol_iterator dynamic_symbol_end() const
Definition ELFObjectFile.h:1257
DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const
Definition ELFObjectFile.h:356
bool isDebugSection(DataRefImpl Sec) const override
Definition ELFObjectFile.h:1018
section_iterator section_begin() const override
Definition ELFObjectFile.h:1266
bool isSectionCompressed(DataRefImpl Sec) const override
Definition ELFObjectFile.h:946
SmallVector< SmallVector< Elf_Crel, 0 >, 0 > Crels
Definition ELFObjectFile.h:302
bool isBerkeleyText(DataRefImpl Sec) const override
Definition ELFObjectFile.h:1004
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
Definition ELFObjectFile.h:1282
Expected< uint64_t > getStartAddress() const override
Definition ELFObjectFile.h:1496
StringRef getCrelDecodeProblem(DataRefImpl Sec) const
Definition ELFObjectFile.h:1511
Definition ELFObjectFile.h:231
Expected< int64_t > getAddend() const
Definition ELFObjectFile.h:241
const ELFObjectFileBase * getObject() const
Definition ELFObjectFile.h:237
ELFRelocationRef(const RelocationRef &B)
Definition ELFObjectFile.h:233
Definition ELFObjectFile.h:133
uint64_t getFlags() const
Definition ELFObjectFile.h:147
const ELFObjectFileBase * getObject() const
Definition ELFObjectFile.h:139
uint64_t getOffset() const
Definition ELFObjectFile.h:151
ELFSectionRef(const SectionRef &B)
Definition ELFObjectFile.h:135
uint32_t getType() const
Definition ELFObjectFile.h:143
Definition ELFObjectFile.h:171
uint8_t getOther() const
Definition ELFObjectFile.h:189
const ELFObjectFileBase * getObject() const
Definition ELFObjectFile.h:177
uint8_t getELFType() const
Definition ELFObjectFile.h:193
ELFSymbolRef(const SymbolRef &B)
Definition ELFObjectFile.h:173
uint8_t getBinding() const
Definition ELFObjectFile.h:185
uint64_t getSize() const
Definition ELFObjectFile.h:181
StringRef getELFTypeName() const
Definition ELFObjectFile.h:197
const uint8_t * base() const
ObjectFile(unsigned int Type, MemoryBufferRef Source)
This is a value type class that represents a single relocation in the list of relocations in the obje...
const ObjectFile * getObject() const
DataRefImpl getRawDataRefImpl() const
This is a value type class that represents a single section in the list of sections in the object fil...
DataRefImpl getRawDataRefImpl() const
const ObjectFile * getObject() const
This is a value type class that represents a single symbol in the list of symbols in the object file.
const ObjectFile * getObject() const
virtual basic_symbol_iterator symbol_begin() const =0
virtual basic_symbol_iterator symbol_end() const =0
const SectionRef & operator*() const
const SectionRef * operator->() const
const ELFRelocationRef & operator*() const
Definition ELFObjectFile.h:257
elf_relocation_iterator(const relocation_iterator &B)
Definition ELFObjectFile.h:248
const ELFRelocationRef * operator->() const
Definition ELFObjectFile.h:252
elf_section_iterator(const section_iterator &B)
Definition ELFObjectFile.h:158
const ELFSectionRef * operator->() const
Definition ELFObjectFile.h:162
const ELFSectionRef & operator*() const
Definition ELFObjectFile.h:166
Definition ELFObjectFile.h:216
const ELFSymbolRef & operator*() const
Definition ELFObjectFile.h:226
elf_symbol_iterator(const basic_symbol_iterator &B)
Definition ELFObjectFile.h:218
const ELFSymbolRef * operator->() const
Definition ELFObjectFile.h:222
const SymbolRef * operator->() const
const SymbolRef & operator*() const
symbol_iterator(SymbolRef Sym)
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ EF_AMDGPU_MACH_AMDGCN_LAST
@ EF_AMDGPU_MACH_R600_LAST
@ EF_AMDGPU_MACH_AMDGCN_FIRST
@ EF_AMDGPU_MACH_R600_FIRST
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
bool operator<(const ELFSymbolRef &A, const ELFSymbolRef &B)
Definition ELFObjectFile.h:208
content_iterator< SectionRef > section_iterator
Error createError(const Twine &Err)
LLVM_ABI StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type)
ELFObjectFile< ELF32BE > ELF32BEObjectFile
Definition ELFObjectFile.h:522
constexpr int NumElfSymbolTypes
Definition ELFObjectFile.h:48
content_iterator< BasicSymbolRef > basic_symbol_iterator
ELFObjectFile< ELF64LE > ELF64LEObjectFile
Definition ELFObjectFile.h:521
ELFObjectFile< ELF32LE > ELF32LEObjectFile
Definition ELFObjectFile.h:520
static Error decodeCrel(ArrayRef< uint8_t > Content, function_ref< void(uint64_t, bool)> HdrHandler, function_ref< void(Elf_Crel_Impl< Is64 >)> EntryHandler)
LLVM_ABI const llvm::EnumEntry< unsigned > ElfSymbolTypes[NumElfSymbolTypes]
content_iterator< RelocationRef > relocation_iterator
ELFObjectFile< ELF64BE > ELF64BEObjectFile
Definition ELFObjectFile.h:523
This is an optimization pass for GlobalISel generic memory operations.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
FunctionAddr VTableAddr Count
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
@ Dynamic
Denotes mode unknown at compile time.
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
Definition ELFObjectFile.h:54
uint64_t Address
Definition ELFObjectFile.h:57
std::optional< DataRefImpl > Symbol
Definition ELFObjectFile.h:56
StringRef Section
Definition ELFObjectFile.h:55
struct llvm::object::DataRefImpl::@005117267142344013370254144343227032034000327225 d