Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
ELFObjectFile.h
Go to the documentation of this file.
1//===- ELFObjectFile.h - ELF object file implementation ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the ELFObjectFile template class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_OBJECT_ELFOBJECTFILE_H
14#define LLVM_OBJECT_ELFOBJECTFILE_H
15
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/STLExtras.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/ADT/iterator_range.h"
20#include "llvm/BinaryFormat/ELF.h"
21#include "llvm/Object/Binary.h"
22#include "llvm/Object/ELF.h"
23#include "llvm/Object/ELFTypes.h"
24#include "llvm/Object/Error.h"
25#include "llvm/Object/ObjectFile.h"
26#include "llvm/Object/SymbolicFile.h"
27#include "llvm/Support/Casting.h"
28#include "llvm/Support/ELFAttributeParser.h"
29#include "llvm/Support/ELFAttributes.h"
30#include "llvm/Support/Error.h"
31#include "llvm/Support/ErrorHandling.h"
32#include "llvm/Support/LEB128.h"
33#include "llvm/Support/MemoryBufferRef.h"
34#include "llvm/Support/ScopedPrinter.h"
35#include "llvm/TargetParser/SubtargetFeature.h"
36#include "llvm/TargetParser/Triple.h"
37#include <cassert>
38#include <cstdint>
39
40namespacellvm {
41
42template <typename T>classSmallVectorImpl;
43
44namespaceobject {
45
46constexprintNumElfSymbolTypes = 16;
47externconstllvm::EnumEntry<unsigned>ElfSymbolTypes[NumElfSymbolTypes];
48
49clasself_symbol_iterator;
50
51structELFPltEntry {
52StringRefSection;
53 std::optional<DataRefImpl>Symbol;
54uint64_tAddress;
55};
56
57classELFObjectFileBase :publicObjectFile {
58friendclassELFRelocationRef;
59friendclassELFSectionRef;
60friendclassELFSymbolRef;
61
62SubtargetFeatures getMIPSFeatures()const;
63SubtargetFeatures getARMFeatures()const;
64SubtargetFeatures getHexagonFeatures()const;
65Expected<SubtargetFeatures> getRISCVFeatures()const;
66SubtargetFeatures getLoongArchFeatures()const;
67
68StringRef getAMDGPUCPUName()const;
69StringRef getNVPTXCPUName()const;
70
71protected:
72ELFObjectFileBase(unsignedintType,MemoryBufferRef Source);
73
74virtualuint64_tgetSymbolSize(DataRefImpl Symb)const = 0;
75virtualuint8_tgetSymbolBinding(DataRefImpl Symb)const = 0;
76virtualuint8_tgetSymbolOther(DataRefImpl Symb)const = 0;
77virtualuint8_tgetSymbolELFType(DataRefImpl Symb)const = 0;
78
79virtualuint32_tgetSectionType(DataRefImpl Sec)const = 0;
80virtualuint64_tgetSectionFlags(DataRefImpl Sec)const = 0;
81virtualuint64_tgetSectionOffset(DataRefImpl Sec)const = 0;
82
83virtualExpected<int64_t>getRelocationAddend(DataRefImpl Rel)const = 0;
84virtualErrorgetBuildAttributes(ELFAttributeParser &Attributes)const = 0;
85
86public:
87usingelf_symbol_iterator_range =iterator_range<elf_symbol_iterator>;
88
89virtualelf_symbol_iterator_rangegetDynamicSymbolIterators()const = 0;
90
91 /// Returns platform-specific object flags, if any.
92virtualunsignedgetPlatformFlags()const = 0;
93
94elf_symbol_iterator_rangesymbols()const;
95
96staticboolclassof(constBinary *v) {return v->isELF(); }
97
98Expected<SubtargetFeatures>getFeatures()const override;
99
100 std::optional<StringRef>tryGetCPUName()const override;
101
102voidsetARMSubArch(Triple &TheTriple)const override;
103
104virtualuint16_tgetEType()const = 0;
105
106virtualuint16_tgetEMachine()const = 0;
107
108virtualuint8_tgetEIdentABIVersion()const = 0;
109
110 std::vector<ELFPltEntry>getPltEntries()const;
111
112 /// Returns a vector containing a symbol version for each dynamic symbol.
113 /// Returns an empty vector if version sections do not exist.
114Expected<std::vector<VersionEntry>>readDynsymVersions()const;
115
116 /// Returns a vector of all BB address maps in the object file. When
117 /// `TextSectionIndex` is specified, only returns the BB address maps
118 /// corresponding to the section with that index. When `PGOAnalyses`is
119 /// specified (PGOAnalyses is not nullptr), the vector is cleared then filled
120 /// with extra PGO data. `PGOAnalyses` will always be the same length as the
121 /// return value when it is requested assuming no error occurs. Upon failure,
122 /// `PGOAnalyses` will be emptied.
123Expected<std::vector<BBAddrMap>>
124readBBAddrMap(std::optional<unsigned> TextSectionIndex = std::nullopt,
125 std::vector<PGOAnalysisMap> *PGOAnalyses =nullptr)const;
126
127StringRefgetCrelDecodeProblem(SectionRef Sec)const;
128};
129
130classELFSectionRef :publicSectionRef {
131public:
132ELFSectionRef(constSectionRef &B) :SectionRef(B) {
133assert(isa<ELFObjectFileBase>(SectionRef::getObject()));
134 }
135
136constELFObjectFileBase *getObject() const{
137return cast<ELFObjectFileBase>(SectionRef::getObject());
138 }
139
140uint32_tgetType() const{
141returngetObject()->getSectionType(getRawDataRefImpl());
142 }
143
144uint64_tgetFlags() const{
145returngetObject()->getSectionFlags(getRawDataRefImpl());
146 }
147
148uint64_tgetOffset() const{
149returngetObject()->getSectionOffset(getRawDataRefImpl());
150 }
151};
152
153clasself_section_iterator :publicsection_iterator {
154public:
155elf_section_iterator(constsection_iterator &B) :section_iterator(B) {
156assert(isa<ELFObjectFileBase>(B->getObject()));
157 }
158
159constELFSectionRef *operator->() const{
160returnstatic_cast<constELFSectionRef *>(section_iterator::operator->());
161 }
162
163constELFSectionRef &operator*() const{
164returnstatic_cast<constELFSectionRef &>(section_iterator::operator*());
165 }
166};
167
168classELFSymbolRef :publicSymbolRef {
169public:
170ELFSymbolRef(constSymbolRef &B) :SymbolRef(B) {
171assert(isa<ELFObjectFileBase>(SymbolRef::getObject()));
172 }
173
174constELFObjectFileBase *getObject() const{
175return cast<ELFObjectFileBase>(BasicSymbolRef::getObject());
176 }
177
178uint64_tgetSize() const{
179returngetObject()->getSymbolSize(getRawDataRefImpl());
180 }
181
182uint8_tgetBinding() const{
183returngetObject()->getSymbolBinding(getRawDataRefImpl());
184 }
185
186uint8_tgetOther() const{
187returngetObject()->getSymbolOther(getRawDataRefImpl());
188 }
189
190uint8_tgetELFType() const{
191returngetObject()->getSymbolELFType(getRawDataRefImpl());
192 }
193
194StringRefgetELFTypeName() const{
195uint8_tType =getELFType();
196for (constauto &EE :ElfSymbolTypes) {
197if (EE.Value ==Type) {
198return EE.AltName;
199 }
200 }
201return"";
202 }
203};
204
205inlinebooloperator<(constELFSymbolRef &A,constELFSymbolRef &B) {
206constDataRefImpl &DRIA =A.getRawDataRefImpl();
207constDataRefImpl &DRIB =B.getRawDataRefImpl();
208if (DRIA.d.a == DRIB.d.a)
209return DRIA.d.b < DRIB.d.b;
210return DRIA.d.a < DRIB.d.a;
211}
212
213clasself_symbol_iterator :publicsymbol_iterator {
214public:
215elf_symbol_iterator(constbasic_symbol_iterator &B)
216 :symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
217cast<ELFObjectFileBase>(B->getObject()))) {}
218
219constELFSymbolRef *operator->() const{
220returnstatic_cast<constELFSymbolRef *>(symbol_iterator::operator->());
221 }
222
223constELFSymbolRef &operator*() const{
224returnstatic_cast<constELFSymbolRef &>(symbol_iterator::operator*());
225 }
226};
227
228classELFRelocationRef :publicRelocationRef {
229public:
230ELFRelocationRef(constRelocationRef &B) :RelocationRef(B) {
231assert(isa<ELFObjectFileBase>(RelocationRef::getObject()));
232 }
233
234constELFObjectFileBase *getObject() const{
235return cast<ELFObjectFileBase>(RelocationRef::getObject());
236 }
237
238Expected<int64_t>getAddend() const{
239returngetObject()->getRelocationAddend(getRawDataRefImpl());
240 }
241};
242
243clasself_relocation_iterator :publicrelocation_iterator {
244public:
245elf_relocation_iterator(constrelocation_iterator &B)
246 :relocation_iterator(RelocationRef(
247B->getRawDataRefImpl(),cast<ELFObjectFileBase>(B->getObject()))) {}
248
249constELFRelocationRef *operator->() const{
250returnstatic_cast<constELFRelocationRef *>(
251relocation_iterator::operator->());
252 }
253
254constELFRelocationRef &operator*() const{
255returnstatic_cast<constELFRelocationRef &>(
256relocation_iterator::operator*());
257 }
258};
259
260inlineELFObjectFileBase::elf_symbol_iterator_range
261ELFObjectFileBase::symbols() const{
262returnelf_symbol_iterator_range(symbol_begin(),symbol_end());
263}
264
265template <class ELFT>classELFObjectFile :publicELFObjectFileBase {
266uint16_t getEMachine()const override;
267uint16_t getEType()const override;
268uint8_t getEIdentABIVersion()const override;
269uint64_t getSymbolSize(DataRefImplSym)const override;
270
271public:
272LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
273
274SectionReftoSectionRef(const Elf_Shdr *Sec) const{
275returnSectionRef(toDRI(Sec),this);
276 }
277
278ELFSymbolReftoSymbolRef(const Elf_Shdr *SymTable,unsigned SymbolNum) const{
279returnELFSymbolRef({toDRI(SymTable, SymbolNum),this});
280 }
281
282boolIsContentValid() const{return ContentValid; }
283
284private:
285ELFObjectFile(MemoryBufferRef Object,ELFFile<ELFT>EF,
286const Elf_Shdr *DotDynSymSec,const Elf_Shdr *DotSymtabSec,
287const Elf_Shdr *DotSymtabShndxSec);
288
289bool ContentValid =false;
290
291protected:
292ELFFile<ELFT>EF;
293
294const Elf_Shdr *DotDynSymSec =nullptr;// Dynamic symbol table section.
295const Elf_Shdr *DotSymtabSec =nullptr;// Symbol table section.
296const Elf_Shdr *DotSymtabShndxSec =nullptr;// SHT_SYMTAB_SHNDX section.
297
298// Hold CREL relocations for SectionRef::relocations().
299mutableSmallVector<SmallVector<Elf_Crel, 0>, 0>Crels;
300mutableSmallVector<std::string, 0>CrelDecodeProblems;
301
302ErrorinitContent()override;
303
304voidmoveSymbolNext(DataRefImpl &Symb)const override;
305Expected<StringRef>getSymbolName(DataRefImpl Symb)const override;
306Expected<uint64_t>getSymbolAddress(DataRefImpl Symb)const override;
307uint64_tgetSymbolValueImpl(DataRefImpl Symb)const override;
308uint32_tgetSymbolAlignment(DataRefImpl Symb)const override;
309uint64_tgetCommonSymbolSizeImpl(DataRefImpl Symb)const override;
310Expected<uint32_t>getSymbolFlags(DataRefImpl Symb)const override;
311uint8_tgetSymbolBinding(DataRefImpl Symb)const override;
312uint8_tgetSymbolOther(DataRefImpl Symb)const override;
313uint8_tgetSymbolELFType(DataRefImpl Symb)const override;
314Expected<SymbolRef::Type>getSymbolType(DataRefImpl Symb)const override;
315Expected<section_iterator>getSymbolSection(const Elf_Sym *Symb,
316const Elf_Shdr *SymTab)const;
317Expected<section_iterator>getSymbolSection(DataRefImpl Symb)const override;
318
319voidmoveSectionNext(DataRefImpl &Sec)const override;
320Expected<StringRef>getSectionName(DataRefImpl Sec)const override;
321uint64_tgetSectionAddress(DataRefImpl Sec)const override;
322uint64_tgetSectionIndex(DataRefImpl Sec)const override;
323uint64_tgetSectionSize(DataRefImpl Sec)const override;
324Expected<ArrayRef<uint8_t>>
325getSectionContents(DataRefImpl Sec)const override;
326uint64_tgetSectionAlignment(DataRefImpl Sec)const override;
327boolisSectionCompressed(DataRefImpl Sec)const override;
328boolisSectionText(DataRefImpl Sec)const override;
329boolisSectionData(DataRefImpl Sec)const override;
330boolisSectionBSS(DataRefImpl Sec)const override;
331boolisSectionVirtual(DataRefImpl Sec)const override;
332boolisBerkeleyText(DataRefImpl Sec)const override;
333boolisBerkeleyData(DataRefImpl Sec)const override;
334boolisDebugSection(DataRefImpl Sec)const override;
335relocation_iteratorsection_rel_begin(DataRefImpl Sec)const override;
336relocation_iteratorsection_rel_end(DataRefImpl Sec)const override;
337 std::vector<SectionRef>dynamic_relocation_sections()const override;
338Expected<section_iterator>
339getRelocatedSection(DataRefImpl Sec)const override;
340
341voidmoveRelocationNext(DataRefImpl &Rel)const override;
342uint64_tgetRelocationOffset(DataRefImpl Rel)const override;
343symbol_iteratorgetRelocationSymbol(DataRefImpl Rel)const override;
344uint64_tgetRelocationType(DataRefImpl Rel)const override;
345voidgetRelocationTypeName(DataRefImpl Rel,
346SmallVectorImpl<char> &Result)const override;
347
348uint32_tgetSectionType(DataRefImpl Sec)const override;
349uint64_tgetSectionFlags(DataRefImpl Sec)const override;
350uint64_tgetSectionOffset(DataRefImpl Sec)const override;
351StringRefgetRelocationTypeName(uint32_tType)const;
352
353DataRefImpltoDRI(const Elf_Shdr *SymTable,unsigned SymbolNum) const{
354DataRefImpl DRI;
355if (!SymTable) {
356 DRI.d.a = 0;
357 DRI.d.b = 0;
358return DRI;
359 }
360assert(SymTable->sh_type ==ELF::SHT_SYMTAB ||
361 SymTable->sh_type ==ELF::SHT_DYNSYM);
362
363auto SectionsOrErr =EF.sections();
364if (!SectionsOrErr) {
365 DRI.d.a = 0;
366 DRI.d.b = 0;
367return DRI;
368 }
369 uintptr_t SHT =reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
370unsigned SymTableIndex =
371 (reinterpret_cast<uintptr_t>(SymTable) - SHT) /sizeof(Elf_Shdr);
372
373 DRI.d.a = SymTableIndex;
374 DRI.d.b = SymbolNum;
375return DRI;
376 }
377
378const Elf_Shdr *toELFShdrIter(DataRefImpl Sec) const{
379returnreinterpret_cast<constElf_Shdr *>(Sec.p);
380 }
381
382DataRefImpltoDRI(const Elf_Shdr *Sec) const{
383DataRefImpl DRI;
384 DRI.p =reinterpret_cast<uintptr_t>(Sec);
385return DRI;
386 }
387
388DataRefImpltoDRI(const Elf_Dyn *Dyn) const{
389DataRefImpl DRI;
390 DRI.p =reinterpret_cast<uintptr_t>(Dyn);
391return DRI;
392 }
393
394boolisExportedToOtherDSO(const Elf_Sym *ESym) const{
395unsignedchar Binding = ESym->getBinding();
396unsignedchar Visibility = ESym->getVisibility();
397
398// A symbol is exported if its binding is either GLOBAL or WEAK, and its
399// visibility is either DEFAULT or PROTECTED. All other symbols are not
400// exported.
401return (
402 (Binding ==ELF::STB_GLOBAL || Binding ==ELF::STB_WEAK ||
403 Binding ==ELF::STB_GNU_UNIQUE) &&
404 (Visibility ==ELF::STV_DEFAULT || Visibility ==ELF::STV_PROTECTED));
405 }
406
407ErrorgetBuildAttributes(ELFAttributeParser &Attributes) const override{
408uint32_tType;
409switch (getEMachine()) {
410caseELF::EM_ARM:
411Type =ELF::SHT_ARM_ATTRIBUTES;
412break;
413caseELF::EM_RISCV:
414Type =ELF::SHT_RISCV_ATTRIBUTES;
415break;
416caseELF::EM_HEXAGON:
417Type =ELF::SHT_HEXAGON_ATTRIBUTES;
418break;
419default:
420returnError::success();
421 }
422
423auto SectionsOrErr =EF.sections();
424if (!SectionsOrErr)
425return SectionsOrErr.takeError();
426for (const Elf_Shdr &Sec : *SectionsOrErr) {
427if (Sec.sh_type !=Type)
428continue;
429auto ErrorOrContents =EF.getSectionContents(Sec);
430if (!ErrorOrContents)
431return ErrorOrContents.takeError();
432
433auto Contents = ErrorOrContents.get();
434if (Contents[0] !=ELFAttrs::Format_Version || Contents.size() == 1)
435returnError::success();
436
437if (ErrorE =Attributes.parse(Contents, ELFT::Endianness))
438returnE;
439break;
440 }
441returnError::success();
442 }
443
444// This flag is used for classof, to distinguish ELFObjectFile from
445// its subclass. If more subclasses will be created, this flag will
446// have to become an enum.
447boolisDyldELFObject =false;
448
449public:
450ELFObjectFile(ELFObjectFile<ELFT> &&Other);
451staticExpected<ELFObjectFile<ELFT>>create(MemoryBufferRef Object,
452bool InitContent =true);
453
454const Elf_Rel *getRel(DataRefImpl Rel)const;
455const Elf_Rela *getRela(DataRefImpl Rela)const;
456 Elf_CrelgetCrel(DataRefImpl Crel)const;
457
458Expected<const Elf_Sym *>getSymbol(DataRefImplSym) const{
459returnEF.template getEntry<Elf_Sym>(Sym.d.a,Sym.d.b);
460 }
461
462 /// Get the relocation section that contains \a Rel.
463const Elf_Shdr *getRelSection(DataRefImpl Rel) const{
464auto RelSecOrErr =EF.getSection(Rel.d.a);
465if (!RelSecOrErr)
466report_fatal_error(
467Twine(errorToErrorCode(RelSecOrErr.takeError()).message()));
468return *RelSecOrErr;
469 }
470
471const Elf_Shdr *getSection(DataRefImpl Sec) const{
472returnreinterpret_cast<constElf_Shdr *>(Sec.p);
473 }
474
475basic_symbol_iteratorsymbol_begin()const override;
476basic_symbol_iteratorsymbol_end()const override;
477
478boolis64Bit() const override{returngetBytesInAddress() == 8; }
479
480elf_symbol_iteratordynamic_symbol_begin()const;
481elf_symbol_iteratordynamic_symbol_end()const;
482
483section_iteratorsection_begin()const override;
484section_iteratorsection_end()const override;
485
486Expected<int64_t>getRelocationAddend(DataRefImpl Rel)const override;
487
488uint8_tgetBytesInAddress()const override;
489StringRefgetFileFormatName()const override;
490Triple::ArchTypegetArch()const override;
491Triple::OSTypegetOS()const override;
492Expected<uint64_t>getStartAddress()const override;
493
494unsignedgetPlatformFlags() const override{returnEF.getHeader().e_flags; }
495
496constELFFile<ELFT> &getELFFile() const{returnEF; }
497
498boolisDyldType() const{returnisDyldELFObject; }
499staticboolclassof(constBinary *v) {
500return v->getType() ==
501getELFType(ELFT::Endianness ==llvm::endianness::little,
502 ELFT::Is64Bits);
503 }
504
505elf_symbol_iterator_rangegetDynamicSymbolIterators()const override;
506
507boolisRelocatableObject()const override;
508
509voidcreateFakeSections() {EF.createFakeSections(); }
510
511StringRefgetCrelDecodeProblem(DataRefImpl Sec)const;
512};
513
514usingELF32LEObjectFile =ELFObjectFile<ELF32LE>;
515usingELF64LEObjectFile =ELFObjectFile<ELF64LE>;
516usingELF32BEObjectFile =ELFObjectFile<ELF32BE>;
517usingELF64BEObjectFile =ELFObjectFile<ELF64BE>;
518
519template <class ELFT>
520voidELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Sym) const{
521 ++Sym.d.b;
522}
523
524template <class ELFT>ErrorELFObjectFile<ELFT>::initContent() {
525auto SectionsOrErr = EF.sections();
526if (!SectionsOrErr)
527return SectionsOrErr.takeError();
528
529for (const Elf_Shdr &Sec : *SectionsOrErr) {
530switch (Sec.sh_type) {
531caseELF::SHT_DYNSYM: {
532if (!DotDynSymSec)
533 DotDynSymSec = &Sec;
534break;
535 }
536caseELF::SHT_SYMTAB: {
537if (!DotSymtabSec)
538 DotSymtabSec = &Sec;
539break;
540 }
541caseELF::SHT_SYMTAB_SHNDX: {
542if (!DotSymtabShndxSec)
543 DotSymtabShndxSec = &Sec;
544break;
545 }
546 }
547 }
548
549 ContentValid =true;
550returnError::success();
551}
552
553template <class ELFT>
554Expected<StringRef>ELFObjectFile<ELFT>::getSymbolName(DataRefImplSym) const{
555Expected<const Elf_Sym *> SymOrErr = getSymbol(Sym);
556if (!SymOrErr)
557return SymOrErr.takeError();
558auto SymTabOrErr = EF.getSection(Sym.d.a);
559if (!SymTabOrErr)
560return SymTabOrErr.takeError();
561const Elf_Shdr *SymTableSec = *SymTabOrErr;
562auto StrTabOrErr = EF.getSection(SymTableSec->sh_link);
563if (!StrTabOrErr)
564return StrTabOrErr.takeError();
565const Elf_Shdr *StringTableSec = *StrTabOrErr;
566auto SymStrTabOrErr = EF.getStringTable(*StringTableSec);
567if (!SymStrTabOrErr)
568return SymStrTabOrErr.takeError();
569Expected<StringRef>Name = (*SymOrErr)->getName(*SymStrTabOrErr);
570if (Name && !Name->empty())
571returnName;
572
573// If the symbol name is empty use the section name.
574if ((*SymOrErr)->getType() ==ELF::STT_SECTION) {
575Expected<section_iterator> SecOrErr = getSymbolSection(Sym);
576if (SecOrErr)
577return (*SecOrErr)->getName();
578return SecOrErr.takeError();
579 }
580returnName;
581}
582
583template <class ELFT>
584uint64_tELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const{
585returngetSection(Sec)->sh_flags;
586}
587
588template <class ELFT>
589uint32_tELFObjectFile<ELFT>::getSectionType(DataRefImpl Sec) const{
590returngetSection(Sec)->sh_type;
591}
592
593template <class ELFT>
594uint64_tELFObjectFile<ELFT>::getSectionOffset(DataRefImpl Sec) const{
595returngetSection(Sec)->sh_offset;
596}
597
598template <class ELFT>
599uint64_tELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const{
600Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
601if (!SymOrErr)
602report_fatal_error(SymOrErr.takeError());
603
604uint64_t Ret = (*SymOrErr)->st_value;
605if ((*SymOrErr)->st_shndx ==ELF::SHN_ABS)
606return Ret;
607
608const Elf_Ehdr &Header = EF.getHeader();
609// Clear the ARM/Thumb or microMIPS indicator flag.
610if ((Header.e_machine ==ELF::EM_ARM || Header.e_machine ==ELF::EM_MIPS) &&
611 (*SymOrErr)->getType() ==ELF::STT_FUNC)
612 Ret &= ~1;
613
614return Ret;
615}
616
617template <class ELFT>
618Expected<uint64_t>
619ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb) const{
620Expected<uint64_t> SymbolValueOrErr =getSymbolValue(Symb);
621if (!SymbolValueOrErr)
622// TODO: Test this error.
623return SymbolValueOrErr.takeError();
624
625uint64_t Result = *SymbolValueOrErr;
626Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
627if (!SymOrErr)
628return SymOrErr.takeError();
629
630switch ((*SymOrErr)->st_shndx) {
631caseELF::SHN_COMMON:
632caseELF::SHN_UNDEF:
633caseELF::SHN_ABS:
634return Result;
635 }
636
637auto SymTabOrErr = EF.getSection(Symb.d.a);
638if (!SymTabOrErr)
639return SymTabOrErr.takeError();
640
641if (EF.getHeader().e_type ==ELF::ET_REL) {
642ArrayRef<Elf_Word> ShndxTable;
643if (DotSymtabShndxSec) {
644// TODO: Test this error.
645if (Expected<ArrayRef<Elf_Word>> ShndxTableOrErr =
646 EF.getSHNDXTable(*DotSymtabShndxSec))
647 ShndxTable = *ShndxTableOrErr;
648else
649return ShndxTableOrErr.takeError();
650 }
651
652Expected<const Elf_Shdr *> SectionOrErr =
653 EF.getSection(**SymOrErr, *SymTabOrErr, ShndxTable);
654if (!SectionOrErr)
655return SectionOrErr.takeError();
656const Elf_Shdr *Section = *SectionOrErr;
657if (Section)
658 Result += Section->sh_addr;
659 }
660
661return Result;
662}
663
664template <class ELFT>
665uint32_tELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const{
666Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
667if (!SymOrErr)
668report_fatal_error(SymOrErr.takeError());
669if ((*SymOrErr)->st_shndx ==ELF::SHN_COMMON)
670return (*SymOrErr)->st_value;
671return 0;
672}
673
674template <class ELFT>
675uint16_tELFObjectFile<ELFT>::getEMachine() const{
676return EF.getHeader().e_machine;
677}
678
679template <class ELFT>uint16_t ELFObjectFile<ELFT>::getEType() const{
680return EF.getHeader().e_type;
681}
682
683template <class ELFT>uint8_t ELFObjectFile<ELFT>::getEIdentABIVersion() const{
684return EF.getHeader().e_ident[ELF::EI_ABIVERSION];
685}
686
687template <class ELFT>
688uint64_t ELFObjectFile<ELFT>::getSymbolSize(DataRefImplSym) const{
689 Expected<const Elf_Sym *> SymOrErr = getSymbol(Sym);
690if (!SymOrErr)
691report_fatal_error(SymOrErr.takeError());
692return (*SymOrErr)->st_size;
693}
694
695template <class ELFT>
696uint64_tELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const{
697return getSymbolSize(Symb);
698}
699
700template <class ELFT>
701uint8_tELFObjectFile<ELFT>::getSymbolBinding(DataRefImpl Symb) const{
702Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
703if (!SymOrErr)
704report_fatal_error(SymOrErr.takeError());
705return (*SymOrErr)->getBinding();
706}
707
708template <class ELFT>
709uint8_tELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const{
710Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
711if (!SymOrErr)
712report_fatal_error(SymOrErr.takeError());
713return (*SymOrErr)->st_other;
714}
715
716template <class ELFT>
717uint8_tELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const{
718Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
719if (!SymOrErr)
720report_fatal_error(SymOrErr.takeError());
721return (*SymOrErr)->getType();
722}
723
724template <class ELFT>
725Expected<SymbolRef::Type>
726ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const{
727Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
728if (!SymOrErr)
729return SymOrErr.takeError();
730
731switch ((*SymOrErr)->getType()) {
732caseELF::STT_NOTYPE:
733returnSymbolRef::ST_Unknown;
734caseELF::STT_SECTION:
735returnSymbolRef::ST_Debug;
736caseELF::STT_FILE:
737returnSymbolRef::ST_File;
738caseELF::STT_FUNC:
739returnSymbolRef::ST_Function;
740caseELF::STT_OBJECT:
741caseELF::STT_COMMON:
742returnSymbolRef::ST_Data;
743caseELF::STT_TLS:
744default:
745returnSymbolRef::ST_Other;
746 }
747}
748
749template <class ELFT>
750Expected<uint32_t>ELFObjectFile<ELFT>::getSymbolFlags(DataRefImplSym) const{
751Expected<const Elf_Sym *> SymOrErr = getSymbol(Sym);
752if (!SymOrErr)
753return SymOrErr.takeError();
754
755const Elf_Sym *ESym = *SymOrErr;
756uint32_t Result =SymbolRef::SF_None;
757
758if (ESym->getBinding() !=ELF::STB_LOCAL)
759 Result |=SymbolRef::SF_Global;
760
761if (ESym->getBinding() ==ELF::STB_WEAK)
762 Result |=SymbolRef::SF_Weak;
763
764if (ESym->st_shndx ==ELF::SHN_ABS)
765 Result |=SymbolRef::SF_Absolute;
766
767if (ESym->getType() ==ELF::STT_FILE || ESym->getType() ==ELF::STT_SECTION)
768 Result |=SymbolRef::SF_FormatSpecific;
769
770if (Expected<typename ELFT::SymRange> SymbolsOrErr =
771 EF.symbols(DotSymtabSec)) {
772// Set the SF_FormatSpecific flag for the 0-index null symbol.
773if (ESym == SymbolsOrErr->begin())
774 Result |=SymbolRef::SF_FormatSpecific;
775 }else
776// TODO: Test this error.
777return SymbolsOrErr.takeError();
778
779if (Expected<typename ELFT::SymRange> SymbolsOrErr =
780 EF.symbols(DotDynSymSec)) {
781// Set the SF_FormatSpecific flag for the 0-index null symbol.
782if (ESym == SymbolsOrErr->begin())
783 Result |=SymbolRef::SF_FormatSpecific;
784 }else
785// TODO: Test this error.
786return SymbolsOrErr.takeError();
787
788if (EF.getHeader().e_machine ==ELF::EM_AARCH64) {
789if (Expected<StringRef> NameOrErr =getSymbolName(Sym)) {
790StringRefName = *NameOrErr;
791if (Name.starts_with("$d") ||Name.starts_with("$x"))
792 Result |=SymbolRef::SF_FormatSpecific;
793 }else {
794// TODO: Actually report errors helpfully.
795consumeError(NameOrErr.takeError());
796 }
797 }elseif (EF.getHeader().e_machine ==ELF::EM_ARM) {
798if (Expected<StringRef> NameOrErr =getSymbolName(Sym)) {
799StringRefName = *NameOrErr;
800// TODO Investigate why empty name symbols need to be marked.
801if (Name.empty() ||Name.starts_with("$d") ||Name.starts_with("$t") ||
802Name.starts_with("$a"))
803 Result |=SymbolRef::SF_FormatSpecific;
804 }else {
805// TODO: Actually report errors helpfully.
806consumeError(NameOrErr.takeError());
807 }
808if (ESym->getType() ==ELF::STT_FUNC && (ESym->st_value & 1) == 1)
809 Result |=SymbolRef::SF_Thumb;
810 }elseif (EF.getHeader().e_machine ==ELF::EM_CSKY) {
811if (Expected<StringRef> NameOrErr =getSymbolName(Sym)) {
812StringRefName = *NameOrErr;
813if (Name.starts_with("$d") ||Name.starts_with("$t"))
814 Result |=SymbolRef::SF_FormatSpecific;
815 }else {
816// TODO: Actually report errors helpfully.
817consumeError(NameOrErr.takeError());
818 }
819 }elseif (EF.getHeader().e_machine ==ELF::EM_RISCV) {
820if (Expected<StringRef> NameOrErr =getSymbolName(Sym)) {
821StringRefName = *NameOrErr;
822// Mark fake labels (used for label differences) and mapping symbols.
823if (Name ==".L0 " ||Name.starts_with("$d") ||Name.starts_with("$x"))
824 Result |=SymbolRef::SF_FormatSpecific;
825 }else {
826// TODO: Actually report errors helpfully.
827consumeError(NameOrErr.takeError());
828 }
829 }
830
831if (ESym->st_shndx ==ELF::SHN_UNDEF)
832 Result |=SymbolRef::SF_Undefined;
833
834if (ESym->getType() ==ELF::STT_COMMON || ESym->st_shndx ==ELF::SHN_COMMON)
835 Result |=SymbolRef::SF_Common;
836
837if (isExportedToOtherDSO(ESym))
838 Result |=SymbolRef::SF_Exported;
839
840if (ESym->getType() ==ELF::STT_GNU_IFUNC)
841 Result |=SymbolRef::SF_Indirect;
842
843if (ESym->getVisibility() ==ELF::STV_HIDDEN)
844 Result |=SymbolRef::SF_Hidden;
845
846return Result;
847}
848
849template <class ELFT>
850Expected<section_iterator>
851ELFObjectFile<ELFT>::getSymbolSection(const Elf_Sym *ESym,
852const Elf_Shdr *SymTab) const{
853ArrayRef<Elf_Word> ShndxTable;
854if (DotSymtabShndxSec) {
855// TODO: Test this error.
856Expected<ArrayRef<Elf_Word>> ShndxTableOrErr =
857 EF.getSHNDXTable(*DotSymtabShndxSec);
858if (!ShndxTableOrErr)
859return ShndxTableOrErr.takeError();
860 ShndxTable = *ShndxTableOrErr;
861 }
862
863auto ESecOrErr = EF.getSection(*ESym, SymTab, ShndxTable);
864if (!ESecOrErr)
865return ESecOrErr.takeError();
866
867const Elf_Shdr *ESec = *ESecOrErr;
868if (!ESec)
869return section_end();
870
871DataRefImpl Sec;
872 Sec.p =reinterpret_cast<intptr_t>(ESec);
873returnsection_iterator(SectionRef(Sec,this));
874}
875
876template <class ELFT>
877Expected<section_iterator>
878ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb) const{
879Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);
880if (!SymOrErr)
881return SymOrErr.takeError();
882
883auto SymTabOrErr = EF.getSection(Symb.d.a);
884if (!SymTabOrErr)
885return SymTabOrErr.takeError();
886return getSymbolSection(*SymOrErr, *SymTabOrErr);
887}
888
889template <class ELFT>
890voidELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const{
891const Elf_Shdr *ESec =getSection(Sec);
892 Sec = toDRI(++ESec);
893}
894
895template <class ELFT>
896Expected<StringRef>ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec) const{
897return EF.getSectionName(*getSection(Sec));
898}
899
900template <class ELFT>
901uint64_tELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec) const{
902returngetSection(Sec)->sh_addr;
903}
904
905template <class ELFT>
906uint64_tELFObjectFile<ELFT>::getSectionIndex(DataRefImpl Sec) const{
907auto SectionsOrErr = EF.sections();
908handleAllErrors(std::move(SectionsOrErr.takeError()),
909 [](constErrorInfoBase &) {
910 llvm_unreachable("unable to get section index");
911 });
912const Elf_Shdr *First = SectionsOrErr->begin();
913returngetSection(Sec) -First;
914}
915
916template <class ELFT>
917uint64_tELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec) const{
918returngetSection(Sec)->sh_size;
919}
920
921template <class ELFT>
922Expected<ArrayRef<uint8_t>>
923ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec) const{
924const Elf_Shdr *EShdr =getSection(Sec);
925if (EShdr->sh_type ==ELF::SHT_NOBITS)
926returnArrayRef((constuint8_t *)base(), (size_t)0);
927if (ErrorE =
928 checkOffset(getMemoryBufferRef(),
929 (uintptr_t)base() + EShdr->sh_offset, EShdr->sh_size))
930return std::move(E);
931returnArrayRef((constuint8_t *)base() + EShdr->sh_offset, EShdr->sh_size);
932}
933
934template <class ELFT>
935uint64_tELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec) const{
936returngetSection(Sec)->sh_addralign;
937}
938
939template <class ELFT>
940boolELFObjectFile<ELFT>::isSectionCompressed(DataRefImpl Sec) const{
941returngetSection(Sec)->sh_flags &ELF::SHF_COMPRESSED;
942}
943
944template <class ELFT>
945boolELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec) const{
946returngetSection(Sec)->sh_flags &ELF::SHF_EXECINSTR;
947}
948
949template <class ELFT>
950boolELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec) const{
951const Elf_Shdr *EShdr =getSection(Sec);
952return (EShdr->sh_flags &ELF::SHF_ALLOC) &&
953 !(EShdr->sh_flags &ELF::SHF_EXECINSTR) &&
954 EShdr->sh_type !=ELF::SHT_NOBITS;
955}
956
957template <class ELFT>
958boolELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const{
959const Elf_Shdr *EShdr =getSection(Sec);
960return EShdr->sh_flags &ELF::SHF_ALLOC && EShdr->sh_type ==ELF::SHT_NOBITS;
961}
962
963template <class ELFT>
964std::vector<SectionRef>
965ELFObjectFile<ELFT>::dynamic_relocation_sections() const{
966 std::vector<SectionRef> Res;
967 std::vector<uintptr_t> Offsets;
968
969auto SectionsOrErr = EF.sections();
970if (!SectionsOrErr)
971return Res;
972
973for (const Elf_Shdr &Sec : *SectionsOrErr) {
974if (Sec.sh_type !=ELF::SHT_DYNAMIC)
975continue;
976 Elf_Dyn *Dynamic =
977reinterpret_cast<Elf_Dyn *>((uintptr_t)base() + Sec.sh_offset);
978for (;Dynamic->d_tag != ELF::DT_NULL;Dynamic++) {
979if (Dynamic->d_tag == ELF::DT_REL ||Dynamic->d_tag == ELF::DT_RELA ||
980Dynamic->d_tag == ELF::DT_JMPREL) {
981 Offsets.push_back(Dynamic->d_un.d_val);
982 }
983 }
984 }
985for (const Elf_Shdr &Sec : *SectionsOrErr) {
986if (is_contained(Offsets, Sec.sh_addr))
987 Res.emplace_back(toDRI(&Sec),this);
988 }
989return Res;
990}
991
992template <class ELFT>
993boolELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec) const{
994returngetSection(Sec)->sh_type ==ELF::SHT_NOBITS;
995}
996
997template <class ELFT>
998boolELFObjectFile<ELFT>::isBerkeleyText(DataRefImpl Sec) const{
999returngetSection(Sec)->sh_flags &ELF::SHF_ALLOC &&
1000 (getSection(Sec)->sh_flags &ELF::SHF_EXECINSTR ||
1001 !(getSection(Sec)->sh_flags &ELF::SHF_WRITE));
1002}
1003
1004template <class ELFT>
1005boolELFObjectFile<ELFT>::isBerkeleyData(DataRefImpl Sec) const{
1006const Elf_Shdr *EShdr =getSection(Sec);
1007return !isBerkeleyText(Sec) && EShdr->sh_type !=ELF::SHT_NOBITS &&
1008 EShdr->sh_flags &ELF::SHF_ALLOC;
1009}
1010
1011template <class ELFT>
1012boolELFObjectFile<ELFT>::isDebugSection(DataRefImpl Sec) const{
1013Expected<StringRef> SectionNameOrErr =getSectionName(Sec);
1014if (!SectionNameOrErr) {
1015// TODO: Report the error message properly.
1016consumeError(SectionNameOrErr.takeError());
1017returnfalse;
1018 }
1019StringRefSectionName = SectionNameOrErr.get();
1020returnSectionName.starts_with(".debug") ||
1021SectionName.starts_with(".zdebug") ||SectionName ==".gdb_index";
1022}
1023
1024template <class ELFT>
1025relocation_iterator
1026ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const{
1027DataRefImpl RelData;
1028auto SectionsOrErr = EF.sections();
1029if (!SectionsOrErr)
1030returnrelocation_iterator(RelocationRef());
1031 uintptr_t SHT =reinterpret_cast<uintptr_t>((*SectionsOrErr).begin());
1032 RelData.d.a = (Sec.p - SHT) / EF.getHeader().e_shentsize;
1033 RelData.d.b = 0;
1034if (reinterpret_cast<constElf_Shdr *>(Sec.p)->sh_type ==ELF::SHT_CREL) {
1035if (RelData.d.a + 1 > Crels.size())
1036 Crels.resize(RelData.d.a + 1);
1037auto &Crel = Crels[RelData.d.a];
1038if (Crel.empty()) {
1039ArrayRef<uint8_t>Content =cantFail(getSectionContents(Sec));
1040size_tI = 0;
1041Error Err = decodeCrel<ELFT::Is64Bits>(
1042Content, [&](uint64_t Count,bool) { Crel.resize(Count); },
1043 [&](Elf_Crel Crel) { Crels[RelData.d.a][I++] = Crel; });
1044if (Err) {
1045 Crel.assign(1, Elf_Crel{0, 0, 0, 0});
1046if (RelData.d.a + 1 > CrelDecodeProblems.size())
1047 CrelDecodeProblems.resize(RelData.d.a + 1);
1048 CrelDecodeProblems[RelData.d.a] =toString(std::move(Err));
1049 }
1050 }
1051 }
1052returnrelocation_iterator(RelocationRef(RelData,this));
1053}
1054
1055template <class ELFT>
1056relocation_iterator
1057ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const{
1058const Elf_Shdr *S =reinterpret_cast<constElf_Shdr *>(Sec.p);
1059relocation_iterator Begin = section_rel_begin(Sec);
1060DataRefImpl RelData = Begin->getRawDataRefImpl();
1061if (S->sh_type ==ELF::SHT_CREL) {
1062 RelData.d.b = Crels[RelData.d.a].size();
1063returnrelocation_iterator(RelocationRef(RelData,this));
1064 }
1065if (S->sh_type !=ELF::SHT_RELA && S->sh_type !=ELF::SHT_REL)
1066return Begin;
1067const Elf_Shdr *RelSec = getRelSection(RelData);
1068
1069// Error check sh_link here so that getRelocationSymbol can just use it.
1070auto SymSecOrErr = EF.getSection(RelSec->sh_link);
1071if (!SymSecOrErr)
1072report_fatal_error(
1073Twine(errorToErrorCode(SymSecOrErr.takeError()).message()));
1074
1075 RelData.d.b += S->sh_size / S->sh_entsize;
1076returnrelocation_iterator(RelocationRef(RelData,this));
1077}
1078
1079template <class ELFT>
1080Expected<section_iterator>
1081ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const{
1082const Elf_Shdr *EShdr =getSection(Sec);
1083 uintX_tType = EShdr->sh_type;
1084if (Type !=ELF::SHT_REL &&Type !=ELF::SHT_RELA &&Type !=ELF::SHT_CREL)
1085return section_end();
1086
1087Expected<const Elf_Shdr *> SecOrErr = EF.getSection(EShdr->sh_info);
1088if (!SecOrErr)
1089return SecOrErr.takeError();
1090returnsection_iterator(SectionRef(toDRI(*SecOrErr),this));
1091}
1092
1093// Relocations
1094template <class ELFT>
1095voidELFObjectFile<ELFT>::moveRelocationNext(DataRefImpl &Rel) const{
1096 ++Rel.d.b;
1097}
1098
1099template <class ELFT>
1100symbol_iterator
1101ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const{
1102uint32_t symbolIdx;
1103const Elf_Shdr *sec = getRelSection(Rel);
1104if (sec->sh_type ==ELF::SHT_CREL)
1105 symbolIdx = getCrel(Rel).r_symidx;
1106elseif (sec->sh_type ==ELF::SHT_REL)
1107 symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL());
1108else
1109 symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL());
1110if (!symbolIdx)
1111return symbol_end();
1112
1113// FIXME: error check symbolIdx
1114DataRefImpl SymbolData;
1115 SymbolData.d.a = sec->sh_link;
1116 SymbolData.d.b = symbolIdx;
1117returnsymbol_iterator(SymbolRef(SymbolData,this));
1118}
1119
1120template <class ELFT>
1121uint64_tELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel) const{
1122const Elf_Shdr *sec = getRelSection(Rel);
1123if (sec->sh_type ==ELF::SHT_CREL)
1124return getCrel(Rel).r_offset;
1125if (sec->sh_type ==ELF::SHT_REL)
1126return getRel(Rel)->r_offset;
1127
1128return getRela(Rel)->r_offset;
1129}
1130
1131template <class ELFT>
1132uint64_tELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel) const{
1133const Elf_Shdr *sec = getRelSection(Rel);
1134if (sec->sh_type ==ELF::SHT_CREL)
1135return getCrel(Rel).r_type;
1136if (sec->sh_type ==ELF::SHT_REL)
1137return getRel(Rel)->getType(EF.isMips64EL());
1138else
1139return getRela(Rel)->getType(EF.isMips64EL());
1140}
1141
1142template <class ELFT>
1143StringRefELFObjectFile<ELFT>::getRelocationTypeName(uint32_tType) const{
1144returngetELFRelocationTypeName(EF.getHeader().e_machine,Type);
1145}
1146
1147template <class ELFT>
1148voidELFObjectFile<ELFT>::getRelocationTypeName(
1149DataRefImpl Rel,SmallVectorImpl<char> &Result) const{
1150uint32_t type = getRelocationType(Rel);
1151 EF.getRelocationTypeName(type, Result);
1152}
1153
1154template <class ELFT>
1155Expected<int64_t>
1156ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel) const{
1157if (getRelSection(Rel)->sh_type ==ELF::SHT_RELA)
1158return (int64_t)getRela(Rel)->r_addend;
1159if (getRelSection(Rel)->sh_type ==ELF::SHT_CREL)
1160return (int64_t)getCrel(Rel).r_addend;
1161returncreateError("Relocation section does not have addends");
1162}
1163
1164template <class ELFT>
1165consttypenameELFObjectFile<ELFT>::Elf_Rel *
1166ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const{
1167assert(getRelSection(Rel)->sh_type ==ELF::SHT_REL);
1168auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
1169if (!Ret)
1170report_fatal_error(Twine(errorToErrorCode(Ret.takeError()).message()));
1171return *Ret;
1172}
1173
1174template <class ELFT>
1175consttypenameELFObjectFile<ELFT>::Elf_Rela *
1176ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const{
1177assert(getRelSection(Rela)->sh_type ==ELF::SHT_RELA);
1178auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
1179if (!Ret)
1180report_fatal_error(Twine(errorToErrorCode(Ret.takeError()).message()));
1181return *Ret;
1182}
1183
1184template <class ELFT>
1185typenameELFObjectFile<ELFT>::Elf_Crel
1186ELFObjectFile<ELFT>::getCrel(DataRefImpl Crel) const{
1187assert(getRelSection(Crel)->sh_type ==ELF::SHT_CREL);
1188assert(Crel.d.a < Crels.size());
1189return Crels[Crel.d.a][Crel.d.b];
1190}
1191
1192template <class ELFT>
1193Expected<ELFObjectFile<ELFT>>
1194ELFObjectFile<ELFT>::create(MemoryBufferRef Object,bool InitContent) {
1195auto EFOrErr =ELFFile<ELFT>::create(Object.getBuffer());
1196if (ErrorE = EFOrErr.takeError())
1197return std::move(E);
1198
1199ELFObjectFile<ELFT> Obj = {Object, std::move(*EFOrErr),nullptr,nullptr,
1200nullptr};
1201if (InitContent)
1202if (ErrorE = Obj.initContent())
1203return std::move(E);
1204return std::move(Obj);
1205}
1206
1207template <class ELFT>
1208ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object,ELFFile<ELFT> EF,
1209const Elf_Shdr *DotDynSymSec,
1210const Elf_Shdr *DotSymtabSec,
1211const Elf_Shdr *DotSymtabShndx)
1212 :ELFObjectFileBase(getELFType(ELFT::Endianness ==llvm::endianness::little,
1213 ELFT::Is64Bits),
1214 Object),
1215 EF(EF), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec),
1216 DotSymtabShndxSec(DotSymtabShndx) {}
1217
1218template <class ELFT>
1219ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
1220 :ELFObjectFile(Other.Data,Other.EF,Other.DotDynSymSec,
1221Other.DotSymtabSec,Other.DotSymtabShndxSec) {}
1222
1223template <class ELFT>
1224basic_symbol_iteratorELFObjectFile<ELFT>::symbol_begin() const{
1225DataRefImplSym =
1226 toDRI(DotSymtabSec,
1227 DotSymtabSec && DotSymtabSec->sh_size >=sizeof(Elf_Sym) ? 1 : 0);
1228returnbasic_symbol_iterator(SymbolRef(Sym,this));
1229}
1230
1231template <class ELFT>
1232basic_symbol_iteratorELFObjectFile<ELFT>::symbol_end() const{
1233const Elf_Shdr *SymTab = DotSymtabSec;
1234if (!SymTab)
1235return symbol_begin();
1236DataRefImplSym = toDRI(SymTab, SymTab->sh_size /sizeof(Elf_Sym));
1237returnbasic_symbol_iterator(SymbolRef(Sym,this));
1238}
1239
1240template <class ELFT>
1241elf_symbol_iteratorELFObjectFile<ELFT>::dynamic_symbol_begin() const{
1242if (!DotDynSymSec || DotDynSymSec->sh_size <sizeof(Elf_Sym))
1243// Ignore errors here where the dynsym is empty or sh_size less than the
1244// size of one symbol. These should be handled elsewhere.
1245returnsymbol_iterator(SymbolRef(toDRI(DotDynSymSec, 0),this));
1246// Skip 0-index NULL symbol.
1247returnsymbol_iterator(SymbolRef(toDRI(DotDynSymSec, 1),this));
1248}
1249
1250template <class ELFT>
1251elf_symbol_iteratorELFObjectFile<ELFT>::dynamic_symbol_end() const{
1252const Elf_Shdr *SymTab = DotDynSymSec;
1253if (!SymTab)
1254return dynamic_symbol_begin();
1255DataRefImplSym = toDRI(SymTab, SymTab->sh_size /sizeof(Elf_Sym));
1256returnbasic_symbol_iterator(SymbolRef(Sym,this));
1257}
1258
1259template <class ELFT>
1260section_iteratorELFObjectFile<ELFT>::section_begin() const{
1261auto SectionsOrErr = EF.sections();
1262if (!SectionsOrErr)
1263returnsection_iterator(SectionRef());
1264returnsection_iterator(SectionRef(toDRI((*SectionsOrErr).begin()),this));
1265}
1266
1267template <class ELFT>
1268section_iteratorELFObjectFile<ELFT>::section_end() const{
1269auto SectionsOrErr = EF.sections();
1270if (!SectionsOrErr)
1271returnsection_iterator(SectionRef());
1272returnsection_iterator(SectionRef(toDRI((*SectionsOrErr).end()),this));
1273}
1274
1275template <class ELFT>
1276uint8_tELFObjectFile<ELFT>::getBytesInAddress() const{
1277return ELFT::Is64Bits ? 8 : 4;
1278}
1279
1280template <class ELFT>
1281StringRefELFObjectFile<ELFT>::getFileFormatName() const{
1282constexprbool IsLittleEndian = ELFT::Endianness ==llvm::endianness::little;
1283switch (EF.getHeader().e_ident[ELF::EI_CLASS]) {
1284caseELF::ELFCLASS32:
1285switch (EF.getHeader().e_machine) {
1286caseELF::EM_68K:
1287return"elf32-m68k";
1288caseELF::EM_386:
1289return"elf32-i386";
1290caseELF::EM_IAMCU:
1291return"elf32-iamcu";
1292caseELF::EM_X86_64:
1293return"elf32-x86-64";
1294caseELF::EM_ARM:
1295return (IsLittleEndian ?"elf32-littlearm" :"elf32-bigarm");
1296caseELF::EM_AVR:
1297return"elf32-avr";
1298caseELF::EM_HEXAGON:
1299return"elf32-hexagon";
1300caseELF::EM_LANAI:
1301return"elf32-lanai";
1302caseELF::EM_MIPS:
1303return"elf32-mips";
1304caseELF::EM_MSP430:
1305return"elf32-msp430";
1306caseELF::EM_PPC:
1307return (IsLittleEndian ?"elf32-powerpcle" :"elf32-powerpc");
1308caseELF::EM_RISCV:
1309return"elf32-littleriscv";
1310caseELF::EM_CSKY:
1311return"elf32-csky";
1312caseELF::EM_SPARC:
1313caseELF::EM_SPARC32PLUS:
1314return"elf32-sparc";
1315caseELF::EM_AMDGPU:
1316return"elf32-amdgpu";
1317caseELF::EM_LOONGARCH:
1318return"elf32-loongarch";
1319caseELF::EM_XTENSA:
1320return"elf32-xtensa";
1321default:
1322return"elf32-unknown";
1323 }
1324caseELF::ELFCLASS64:
1325switch (EF.getHeader().e_machine) {
1326caseELF::EM_386:
1327return"elf64-i386";
1328caseELF::EM_X86_64:
1329return"elf64-x86-64";
1330caseELF::EM_AARCH64:
1331return (IsLittleEndian ?"elf64-littleaarch64" :"elf64-bigaarch64");
1332caseELF::EM_PPC64:
1333return (IsLittleEndian ?"elf64-powerpcle" :"elf64-powerpc");
1334caseELF::EM_RISCV:
1335return"elf64-littleriscv";
1336caseELF::EM_S390:
1337return"elf64-s390";
1338caseELF::EM_SPARCV9:
1339return"elf64-sparc";
1340caseELF::EM_MIPS:
1341return"elf64-mips";
1342caseELF::EM_AMDGPU:
1343return"elf64-amdgpu";
1344caseELF::EM_BPF:
1345return"elf64-bpf";
1346caseELF::EM_VE:
1347return"elf64-ve";
1348caseELF::EM_LOONGARCH:
1349return"elf64-loongarch";
1350default:
1351return"elf64-unknown";
1352 }
1353default:
1354// FIXME: Proper error handling.
1355report_fatal_error("Invalid ELFCLASS!");
1356 }
1357}
1358
1359template <class ELFT>Triple::ArchTypeELFObjectFile<ELFT>::getArch() const{
1360bool IsLittleEndian = ELFT::Endianness ==llvm::endianness::little;
1361switch (EF.getHeader().e_machine) {
1362caseELF::EM_68K:
1363returnTriple::m68k;
1364caseELF::EM_386:
1365caseELF::EM_IAMCU:
1366returnTriple::x86;
1367caseELF::EM_X86_64:
1368returnTriple::x86_64;
1369caseELF::EM_AARCH64:
1370return IsLittleEndian ?Triple::aarch64 :Triple::aarch64_be;
1371caseELF::EM_ARM:
1372returnTriple::arm;
1373caseELF::EM_AVR:
1374returnTriple::avr;
1375caseELF::EM_HEXAGON:
1376returnTriple::hexagon;
1377caseELF::EM_LANAI:
1378returnTriple::lanai;
1379caseELF::EM_MIPS:
1380switch (EF.getHeader().e_ident[ELF::EI_CLASS]) {
1381caseELF::ELFCLASS32:
1382return IsLittleEndian ?Triple::mipsel :Triple::mips;
1383caseELF::ELFCLASS64:
1384return IsLittleEndian ?Triple::mips64el :Triple::mips64;
1385default:
1386report_fatal_error("Invalid ELFCLASS!");
1387 }
1388caseELF::EM_MSP430:
1389returnTriple::msp430;
1390caseELF::EM_PPC:
1391return IsLittleEndian ?Triple::ppcle :Triple::ppc;
1392caseELF::EM_PPC64:
1393return IsLittleEndian ?Triple::ppc64le :Triple::ppc64;
1394caseELF::EM_RISCV:
1395switch (EF.getHeader().e_ident[ELF::EI_CLASS]) {
1396caseELF::ELFCLASS32:
1397returnTriple::riscv32;
1398caseELF::ELFCLASS64:
1399returnTriple::riscv64;
1400default:
1401report_fatal_error("Invalid ELFCLASS!");
1402 }
1403caseELF::EM_S390:
1404returnTriple::systemz;
1405
1406caseELF::EM_SPARC:
1407caseELF::EM_SPARC32PLUS:
1408return IsLittleEndian ?Triple::sparcel :Triple::sparc;
1409caseELF::EM_SPARCV9:
1410returnTriple::sparcv9;
1411
1412caseELF::EM_AMDGPU: {
1413if (!IsLittleEndian)
1414returnTriple::UnknownArch;
1415
1416unsigned MACH = EF.getHeader().e_flags &ELF::EF_AMDGPU_MACH;
1417if (MACH >=ELF::EF_AMDGPU_MACH_R600_FIRST &&
1418 MACH <=ELF::EF_AMDGPU_MACH_R600_LAST)
1419returnTriple::r600;
1420if (MACH >=ELF::EF_AMDGPU_MACH_AMDGCN_FIRST &&
1421 MACH <=ELF::EF_AMDGPU_MACH_AMDGCN_LAST)
1422returnTriple::amdgcn;
1423
1424returnTriple::UnknownArch;
1425 }
1426
1427caseELF::EM_CUDA: {
1428if (EF.getHeader().e_ident[ELF::EI_CLASS] ==ELF::ELFCLASS32)
1429returnTriple::nvptx;
1430returnTriple::nvptx64;
1431 }
1432
1433caseELF::EM_BPF:
1434return IsLittleEndian ?Triple::bpfel :Triple::bpfeb;
1435
1436caseELF::EM_VE:
1437returnTriple::ve;
1438caseELF::EM_CSKY:
1439returnTriple::csky;
1440
1441caseELF::EM_LOONGARCH:
1442switch (EF.getHeader().e_ident[ELF::EI_CLASS]) {
1443caseELF::ELFCLASS32:
1444returnTriple::loongarch32;
1445caseELF::ELFCLASS64:
1446returnTriple::loongarch64;
1447default:
1448report_fatal_error("Invalid ELFCLASS!");
1449 }
1450
1451caseELF::EM_XTENSA:
1452returnTriple::xtensa;
1453
1454default:
1455returnTriple::UnknownArch;
1456 }
1457}
1458
1459template <class ELFT>Triple::OSTypeELFObjectFile<ELFT>::getOS() const{
1460switch (EF.getHeader().e_ident[ELF::EI_OSABI]) {
1461caseELF::ELFOSABI_NETBSD:
1462returnTriple::NetBSD;
1463caseELF::ELFOSABI_LINUX:
1464returnTriple::Linux;
1465caseELF::ELFOSABI_HURD:
1466returnTriple::Hurd;
1467caseELF::ELFOSABI_SOLARIS:
1468returnTriple::Solaris;
1469caseELF::ELFOSABI_AIX:
1470returnTriple::AIX;
1471caseELF::ELFOSABI_FREEBSD:
1472returnTriple::FreeBSD;
1473caseELF::ELFOSABI_OPENBSD:
1474returnTriple::OpenBSD;
1475caseELF::ELFOSABI_CUDA:
1476returnTriple::CUDA;
1477caseELF::ELFOSABI_AMDGPU_HSA:
1478returnTriple::AMDHSA;
1479caseELF::ELFOSABI_AMDGPU_PAL:
1480returnTriple::AMDPAL;
1481caseELF::ELFOSABI_AMDGPU_MESA3D:
1482returnTriple::Mesa3D;
1483default:
1484returnTriple::UnknownOS;
1485 }
1486}
1487
1488template <class ELFT>
1489Expected<uint64_t>ELFObjectFile<ELFT>::getStartAddress() const{
1490return EF.getHeader().e_entry;
1491}
1492
1493template <class ELFT>
1494ELFObjectFileBase::elf_symbol_iterator_range
1495ELFObjectFile<ELFT>::getDynamicSymbolIterators() const{
1496returnmake_range(dynamic_symbol_begin(), dynamic_symbol_end());
1497}
1498
1499template <class ELFT>boolELFObjectFile<ELFT>::isRelocatableObject() const{
1500return EF.getHeader().e_type ==ELF::ET_REL;
1501}
1502
1503template <class ELFT>
1504StringRefELFObjectFile<ELFT>::getCrelDecodeProblem(DataRefImpl Sec) const{
1505 uintptr_t SHT =reinterpret_cast<uintptr_t>(cantFail(EF.sections()).begin());
1506autoI = (Sec.p - SHT) / EF.getHeader().e_shentsize;
1507if (I < CrelDecodeProblems.size())
1508return CrelDecodeProblems[I];
1509return"";
1510}
1511
1512}// end namespace object
1513}// end namespace llvm
1514
1515#endif// LLVM_OBJECT_ELFOBJECTFILE_H
const
aarch64 promote const
Definition:AArch64PromoteConstant.cpp:230
Attributes
AMDGPU Kernel Attributes
Definition:AMDGPULowerKernelAttributes.cpp:370
ArrayRef.h
ELF.h
Binary.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Casting.h
getSymbolName
static StringRef getSymbolName(SymbolKind SymKind)
Definition:CodeViewDebug.cpp:3137
ELFAttributeParser.h
ELFAttributes.h
Content
T Content
Definition:ELFObjHandler.cpp:89
Name
std::string Name
Definition:ELFObjHandler.cpp:77
ELFTypes.h
LLVM_ELF_IMPORT_TYPES_ELFT
#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
Definition:ELFTypes.h:106
Sym
Symbol * Sym
Definition:ELF_riscv.cpp:479
LEB128.h
I
#define I(x, y, z)
Definition:MD5.cpp:58
MemoryBufferRef.h
ObjectFile.h
ELF.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
STLExtras.h
This file contains some templates that are useful if you are working with the STL at all.
ScopedPrinter.h
StringRef.h
SubtargetFeature.h
SymbolicFile.h
Triple.h
getSymbolValue
static uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAssembler &Asm)
Definition:WinCOFFObjectWriter.cpp:342
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ELFAttributeParser
Definition:ELFAttributeParser.h:24
llvm::ErrorInfoBase
Base class for error info classes.
Definition:Error.h:45
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:Error.h:160
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition:Error.h:337
llvm::Expected
Tagged union holding either a T or a Error.
Definition:Error.h:481
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition:Error.h:608
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition:Error.h:578
llvm::MemoryBufferRef
Definition:MemoryBufferRef.h:22
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition:SubtargetFeature.h:174
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::Triple::OSType
OSType
Definition:Triple.h:199
llvm::Triple::AMDHSA
@ AMDHSA
Definition:Triple.h:223
llvm::Triple::OpenBSD
@ OpenBSD
Definition:Triple.h:212
llvm::Triple::UnknownOS
@ UnknownOS
Definition:Triple.h:200
llvm::Triple::AIX
@ AIX
Definition:Triple.h:220
llvm::Triple::FreeBSD
@ FreeBSD
Definition:Triple.h:204
llvm::Triple::Linux
@ Linux
Definition:Triple.h:208
llvm::Triple::AMDPAL
@ AMDPAL
Definition:Triple.h:233
llvm::Triple::Mesa3D
@ Mesa3D
Definition:Triple.h:232
llvm::Triple::Solaris
@ Solaris
Definition:Triple.h:213
llvm::Triple::CUDA
@ CUDA
Definition:Triple.h:221
llvm::Triple::NetBSD
@ NetBSD
Definition:Triple.h:211
llvm::Triple::Hurd
@ Hurd
Definition:Triple.h:235
llvm::Triple::ArchType
ArchType
Definition:Triple.h:46
llvm::Triple::r600
@ r600
Definition:Triple.h:73
llvm::Triple::sparcel
@ sparcel
Definition:Triple.h:79
llvm::Triple::loongarch32
@ loongarch32
Definition:Triple.h:61
llvm::Triple::x86
@ x86
Definition:Triple.h:85
llvm::Triple::x86_64
@ x86_64
Definition:Triple.h:86
llvm::Triple::csky
@ csky
Definition:Triple.h:58
llvm::Triple::sparcv9
@ sparcv9
Definition:Triple.h:78
llvm::Triple::amdgcn
@ amdgcn
Definition:Triple.h:74
llvm::Triple::ve
@ ve
Definition:Triple.h:107
llvm::Triple::ppcle
@ ppcle
Definition:Triple.h:70
llvm::Triple::ppc64le
@ ppc64le
Definition:Triple.h:72
llvm::Triple::hexagon
@ hexagon
Definition:Triple.h:60
llvm::Triple::UnknownArch
@ UnknownArch
Definition:Triple.h:47
llvm::Triple::mipsel
@ mipsel
Definition:Triple.h:65
llvm::Triple::aarch64_be
@ aarch64_be
Definition:Triple.h:52
llvm::Triple::msp430
@ msp430
Definition:Triple.h:68
llvm::Triple::loongarch64
@ loongarch64
Definition:Triple.h:62
llvm::Triple::bpfel
@ bpfel
Definition:Triple.h:56
llvm::Triple::mips
@ mips
Definition:Triple.h:64
llvm::Triple::arm
@ arm
Definition:Triple.h:49
llvm::Triple::lanai
@ lanai
Definition:Triple.h:102
llvm::Triple::nvptx64
@ nvptx64
Definition:Triple.h:90
llvm::Triple::avr
@ avr
Definition:Triple.h:55
llvm::Triple::sparc
@ sparc
Definition:Triple.h:77
llvm::Triple::mips64
@ mips64
Definition:Triple.h:66
llvm::Triple::ppc64
@ ppc64
Definition:Triple.h:71
llvm::Triple::ppc
@ ppc
Definition:Triple.h:69
llvm::Triple::xtensa
@ xtensa
Definition:Triple.h:88
llvm::Triple::bpfeb
@ bpfeb
Definition:Triple.h:57
llvm::Triple::nvptx
@ nvptx
Definition:Triple.h:89
llvm::Triple::m68k
@ m68k
Definition:Triple.h:63
llvm::Triple::riscv64
@ riscv64
Definition:Triple.h:76
llvm::Triple::mips64el
@ mips64el
Definition:Triple.h:67
llvm::Triple::riscv32
@ riscv32
Definition:Triple.h:75
llvm::Triple::aarch64
@ aarch64
Definition:Triple.h:51
llvm::Triple::systemz
@ systemz
Definition:Triple.h:80
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition:iterator_range.h:42
llvm::object::BasicSymbolRef::getObject
const SymbolicFile * getObject() const
Definition:SymbolicFile.h:214
llvm::object::BasicSymbolRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition:SymbolicFile.h:210
llvm::object::BasicSymbolRef::SF_Global
@ SF_Global
Definition:SymbolicFile.h:111
llvm::object::BasicSymbolRef::SF_Hidden
@ SF_Hidden
Definition:SymbolicFile.h:120
llvm::object::BasicSymbolRef::SF_Exported
@ SF_Exported
Definition:SymbolicFile.h:116
llvm::object::BasicSymbolRef::SF_Thumb
@ SF_Thumb
Definition:SymbolicFile.h:119
llvm::object::BasicSymbolRef::SF_Common
@ SF_Common
Definition:SymbolicFile.h:114
llvm::object::BasicSymbolRef::SF_Indirect
@ SF_Indirect
Definition:SymbolicFile.h:115
llvm::object::BasicSymbolRef::SF_FormatSpecific
@ SF_FormatSpecific
Definition:SymbolicFile.h:117
llvm::object::BasicSymbolRef::SF_Weak
@ SF_Weak
Definition:SymbolicFile.h:112
llvm::object::BasicSymbolRef::SF_Absolute
@ SF_Absolute
Definition:SymbolicFile.h:113
llvm::object::BasicSymbolRef::SF_Undefined
@ SF_Undefined
Definition:SymbolicFile.h:110
llvm::object::BasicSymbolRef::SF_None
@ SF_None
Definition:SymbolicFile.h:109
llvm::object::Binary
Definition:Binary.h:32
llvm::object::Binary::getELFType
static unsigned int getELFType(bool isLE, bool is64Bits)
Definition:Binary.h:78
llvm::object::ELFFile
Definition:ELF.h:255
llvm::object::ELFFile::create
static Expected< ELFFile > create(StringRef Object)
Definition:ELF.h:888
llvm::object::ELFObjectFileBase
Definition:ELFObjectFile.h:57
llvm::object::ELFObjectFileBase::getSymbolSize
virtual uint64_t getSymbolSize(DataRefImpl Symb) const =0
llvm::object::ELFObjectFileBase::getEIdentABIVersion
virtual uint8_t getEIdentABIVersion() const =0
llvm::object::ELFObjectFileBase::getBuildAttributes
virtual Error getBuildAttributes(ELFAttributeParser &Attributes) const =0
llvm::object::ELFObjectFileBase::getSectionFlags
virtual uint64_t getSectionFlags(DataRefImpl Sec) const =0
llvm::object::ELFObjectFileBase::getEType
virtual uint16_t getEType() const =0
llvm::object::ELFObjectFileBase::getSymbolELFType
virtual uint8_t getSymbolELFType(DataRefImpl Symb) const =0
llvm::object::ELFObjectFileBase::readDynsymVersions
Expected< std::vector< VersionEntry > > readDynsymVersions() const
Returns a vector containing a symbol version for each dynamic symbol.
Definition:ELFObjectFile.cpp:1001
llvm::object::ELFObjectFileBase::getSymbolOther
virtual uint8_t getSymbolOther(DataRefImpl Symb) const =0
llvm::object::ELFObjectFileBase::getDynamicSymbolIterators
virtual elf_symbol_iterator_range getDynamicSymbolIterators() const =0
llvm::object::ELFObjectFileBase::getSectionType
virtual uint32_t getSectionType(DataRefImpl Sec) const =0
llvm::object::ELFObjectFileBase::ELFSymbolRef
friend class ELFSymbolRef
Definition:ELFObjectFile.h:60
llvm::object::ELFObjectFileBase::getCrelDecodeProblem
StringRef getCrelDecodeProblem(SectionRef Sec) const
Definition:ELFObjectFile.cpp:1026
llvm::object::ELFObjectFileBase::symbols
elf_symbol_iterator_range symbols() const
Definition:ELFObjectFile.h:261
llvm::object::ELFObjectFileBase::getRelocationAddend
virtual Expected< int64_t > getRelocationAddend(DataRefImpl Rel) const =0
llvm::object::ELFObjectFileBase::getPltEntries
std::vector< ELFPltEntry > getPltEntries() const
Definition:ELFObjectFile.cpp:785
llvm::object::ELFObjectFileBase::getFeatures
Expected< SubtargetFeatures > getFeatures() const override
Definition:ELFObjectFile.cpp:419
llvm::object::ELFObjectFileBase::getSymbolBinding
virtual uint8_t getSymbolBinding(DataRefImpl Symb) const =0
llvm::object::ELFObjectFileBase::tryGetCPUName
std::optional< StringRef > tryGetCPUName() const override
Definition:ELFObjectFile.cpp:436
llvm::object::ELFObjectFileBase::elf_symbol_iterator_range
iterator_range< elf_symbol_iterator > elf_symbol_iterator_range
Definition:ELFObjectFile.h:87
llvm::object::ELFObjectFileBase::getEMachine
virtual uint16_t getEMachine() const =0
llvm::object::ELFObjectFileBase::classof
static bool classof(const Binary *v)
Definition:ELFObjectFile.h:96
llvm::object::ELFObjectFileBase::getPlatformFlags
virtual unsigned getPlatformFlags() const =0
Returns platform-specific object flags, if any.
llvm::object::ELFObjectFileBase::setARMSubArch
void setARMSubArch(Triple &TheTriple) const override
Definition:ELFObjectFile.cpp:691
llvm::object::ELFObjectFileBase::getSectionOffset
virtual uint64_t getSectionOffset(DataRefImpl Sec) const =0
llvm::object::ELFObjectFileBase::readBBAddrMap
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.cpp:1013
llvm::object::ELFObjectFile
Definition:ELFObjectFile.h:265
llvm::object::ELFObjectFile::classof
static bool classof(const Binary *v)
Definition:ELFObjectFile.h:499
llvm::object::ELFObjectFile::getELFFile
const ELFFile< ELFT > & getELFFile() const
Definition:ELFObjectFile.h:496
llvm::object::ELFObjectFile::getSectionName
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:896
llvm::object::ELFObjectFile::dynamic_relocation_sections
std::vector< SectionRef > dynamic_relocation_sections() const override
Definition:ELFObjectFile.h:965
llvm::object::ELFObjectFile::getRelocationType
uint64_t getRelocationType(DataRefImpl Rel) const override
Definition:ELFObjectFile.h:1132
llvm::object::ELFObjectFile::isSectionText
bool isSectionText(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:945
llvm::object::ELFObjectFile::getSymbolELFType
uint8_t getSymbolELFType(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:717
llvm::object::ELFObjectFile::getSectionAlignment
uint64_t getSectionAlignment(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:935
llvm::object::ELFObjectFile::is64Bit
bool is64Bit() const override
Definition:ELFObjectFile.h:478
llvm::object::ELFObjectFile::toDRI
DataRefImpl toDRI(const Elf_Dyn *Dyn) const
Definition:ELFObjectFile.h:388
llvm::object::ELFObjectFile::isSectionVirtual
bool isSectionVirtual(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:993
llvm::object::ELFObjectFile::getOS
Triple::OSType getOS() const override
Definition:ELFObjectFile.h:1459
llvm::object::ELFObjectFile::isDyldELFObject
bool isDyldELFObject
Definition:ELFObjectFile.h:447
llvm::object::ELFObjectFile::toSectionRef
SectionRef toSectionRef(const Elf_Shdr *Sec) const
Definition:ELFObjectFile.h:274
llvm::object::ELFObjectFile::EF
ELFFile< ELFT > EF
Definition:ELFObjectFile.h:292
llvm::object::ELFObjectFile::IsContentValid
bool IsContentValid() const
Definition:ELFObjectFile.h:282
llvm::object::ELFObjectFile::getSectionType
uint32_t getSectionType(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:589
llvm::object::ELFObjectFile::getRelocationSymbol
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
Definition:ELFObjectFile.h:1101
llvm::object::ELFObjectFile::getDynamicSymbolIterators
elf_symbol_iterator_range getDynamicSymbolIterators() const override
Definition:ELFObjectFile.h:1495
llvm::object::ELFObjectFile::createFakeSections
void createFakeSections()
Definition:ELFObjectFile.h:509
llvm::object::ELFObjectFile::getSymbol
Expected< const Elf_Sym * > getSymbol(DataRefImpl Sym) const
Definition:ELFObjectFile.h:458
llvm::object::ELFObjectFile::getRel
const Elf_Rel * getRel(DataRefImpl Rel) const
Definition:ELFObjectFile.h:1166
llvm::object::ELFObjectFile::getCrel
Elf_Crel getCrel(DataRefImpl Crel) const
Definition:ELFObjectFile.h:1186
llvm::object::ELFObjectFile::getSymbolSection
Expected< section_iterator > getSymbolSection(const Elf_Sym *Symb, const Elf_Shdr *SymTab) const
Definition:ELFObjectFile.h:851
llvm::object::ELFObjectFile::isDyldType
bool isDyldType() const
Definition:ELFObjectFile.h:498
llvm::object::ELFObjectFile::getSymbolValueImpl
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:599
llvm::object::ELFObjectFile::symbol_begin
basic_symbol_iterator symbol_begin() const override
Definition:ELFObjectFile.h:1224
llvm::object::ELFObjectFile::getSymbolAddress
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:619
llvm::object::ELFObjectFile::toSymbolRef
ELFSymbolRef toSymbolRef(const Elf_Shdr *SymTable, unsigned SymbolNum) const
Definition:ELFObjectFile.h:278
llvm::object::ELFObjectFile::CrelDecodeProblems
SmallVector< std::string, 0 > CrelDecodeProblems
Definition:ELFObjectFile.h:300
llvm::object::ELFObjectFile::getRela
const Elf_Rela * getRela(DataRefImpl Rela) const
Definition:ELFObjectFile.h:1176
llvm::object::ELFObjectFile::create
static Expected< ELFObjectFile< ELFT > > create(MemoryBufferRef Object, bool InitContent=true)
Definition:ELFObjectFile.h:1194
llvm::object::ELFObjectFile::isExportedToOtherDSO
bool isExportedToOtherDSO(const Elf_Sym *ESym) const
Definition:ELFObjectFile.h:394
llvm::object::ELFObjectFile::getSectionAddress
uint64_t getSectionAddress(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:901
llvm::object::ELFObjectFile::getSectionContents
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:923
llvm::object::ELFObjectFile::getRelocationTypeName
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
Definition:ELFObjectFile.h:1148
llvm::object::ELFObjectFile::getSectionIndex
uint64_t getSectionIndex(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:906
llvm::object::ELFObjectFile::getSymbolFlags
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:750
llvm::object::ELFObjectFile::isSectionData
bool isSectionData(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:950
llvm::object::ELFObjectFile::DotSymtabSec
const Elf_Shdr * DotSymtabSec
Definition:ELFObjectFile.h:295
llvm::object::ELFObjectFile::DotDynSymSec
const Elf_Shdr * DotDynSymSec
Definition:ELFObjectFile.h:294
llvm::object::ELFObjectFile::getSymbolAlignment
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:665
llvm::object::ELFObjectFile::toELFShdrIter
const Elf_Shdr * toELFShdrIter(DataRefImpl Sec) const
Definition:ELFObjectFile.h:378
llvm::object::ELFObjectFile::getArch
Triple::ArchType getArch() const override
Definition:ELFObjectFile.h:1359
llvm::object::ELFObjectFile::getCommonSymbolSizeImpl
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:696
llvm::object::ELFObjectFile::getSectionSize
uint64_t getSectionSize(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:917
llvm::object::ELFObjectFile::isBerkeleyData
bool isBerkeleyData(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:1005
llvm::object::ELFObjectFile::getFileFormatName
StringRef getFileFormatName() const override
Definition:ELFObjectFile.h:1281
llvm::object::ELFObjectFile::isRelocatableObject
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
Definition:ELFObjectFile.h:1499
llvm::object::ELFObjectFile::moveSymbolNext
void moveSymbolNext(DataRefImpl &Symb) const override
Definition:ELFObjectFile.h:520
llvm::object::ELFObjectFile::getSymbolOther
uint8_t getSymbolOther(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:709
llvm::object::ELFObjectFile::section_end
section_iterator section_end() const override
Definition:ELFObjectFile.h:1268
llvm::object::ELFObjectFile::getRelSection
const Elf_Shdr * getRelSection(DataRefImpl Rel) const
Get the relocation section that contains Rel.
Definition:ELFObjectFile.h:463
llvm::object::ELFObjectFile::getRelocationAddend
Expected< int64_t > getRelocationAddend(DataRefImpl Rel) const override
Definition:ELFObjectFile.h:1156
llvm::object::ELFObjectFile::getRelocationOffset
uint64_t getRelocationOffset(DataRefImpl Rel) const override
Definition:ELFObjectFile.h:1121
llvm::object::ELFObjectFile::getRelocatedSection
Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:1081
llvm::object::ELFObjectFile::moveSectionNext
void moveSectionNext(DataRefImpl &Sec) const override
Definition:ELFObjectFile.h:890
llvm::object::ELFObjectFile::isSectionBSS
bool isSectionBSS(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:958
llvm::object::ELFObjectFile::getPlatformFlags
unsigned getPlatformFlags() const override
Returns platform-specific object flags, if any.
Definition:ELFObjectFile.h:494
llvm::object::ELFObjectFile::getSectionFlags
uint64_t getSectionFlags(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:584
llvm::object::ELFObjectFile::moveRelocationNext
void moveRelocationNext(DataRefImpl &Rel) const override
Definition:ELFObjectFile.h:1095
llvm::object::ELFObjectFile::section_rel_begin
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:1026
llvm::object::ELFObjectFile::getSymbolName
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:554
llvm::object::ELFObjectFile::initContent
Error initContent() override
Definition:ELFObjectFile.h:524
llvm::object::ELFObjectFile::symbol_end
basic_symbol_iterator symbol_end() const override
Definition:ELFObjectFile.h:1232
llvm::object::ELFObjectFile::getSymbolBinding
uint8_t getSymbolBinding(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:701
llvm::object::ELFObjectFile::getSectionOffset
uint64_t getSectionOffset(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:594
llvm::object::ELFObjectFile::section_rel_end
relocation_iterator section_rel_end(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:1057
llvm::object::ELFObjectFile::getSymbolType
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
Definition:ELFObjectFile.h:726
llvm::object::ELFObjectFile::getSection
const Elf_Shdr * getSection(DataRefImpl Sec) const
Definition:ELFObjectFile.h:471
llvm::object::ELFObjectFile::getBuildAttributes
Error getBuildAttributes(ELFAttributeParser &Attributes) const override
Definition:ELFObjectFile.h:407
llvm::object::ELFObjectFile::toDRI
DataRefImpl toDRI(const Elf_Shdr *Sec) const
Definition:ELFObjectFile.h:382
llvm::object::ELFObjectFile::dynamic_symbol_begin
elf_symbol_iterator dynamic_symbol_begin() const
Definition:ELFObjectFile.h:1241
llvm::object::ELFObjectFile::DotSymtabShndxSec
const Elf_Shdr * DotSymtabShndxSec
Definition:ELFObjectFile.h:296
llvm::object::ELFObjectFile::dynamic_symbol_end
elf_symbol_iterator dynamic_symbol_end() const
Definition:ELFObjectFile.h:1251
llvm::object::ELFObjectFile::toDRI
DataRefImpl toDRI(const Elf_Shdr *SymTable, unsigned SymbolNum) const
Definition:ELFObjectFile.h:353
llvm::object::ELFObjectFile::isDebugSection
bool isDebugSection(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:1012
llvm::object::ELFObjectFile::section_begin
section_iterator section_begin() const override
Definition:ELFObjectFile.h:1260
llvm::object::ELFObjectFile::isSectionCompressed
bool isSectionCompressed(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:940
llvm::object::ELFObjectFile::Crels
SmallVector< SmallVector< Elf_Crel, 0 >, 0 > Crels
Definition:ELFObjectFile.h:299
llvm::object::ELFObjectFile::isBerkeleyText
bool isBerkeleyText(DataRefImpl Sec) const override
Definition:ELFObjectFile.h:998
llvm::object::ELFObjectFile::getBytesInAddress
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
Definition:ELFObjectFile.h:1276
llvm::object::ELFObjectFile::getStartAddress
Expected< uint64_t > getStartAddress() const override
Definition:ELFObjectFile.h:1489
llvm::object::ELFObjectFile::getCrelDecodeProblem
StringRef getCrelDecodeProblem(DataRefImpl Sec) const
Definition:ELFObjectFile.h:1504
llvm::object::ELFRelocationRef
Definition:ELFObjectFile.h:228
llvm::object::ELFRelocationRef::getAddend
Expected< int64_t > getAddend() const
Definition:ELFObjectFile.h:238
llvm::object::ELFRelocationRef::getObject
const ELFObjectFileBase * getObject() const
Definition:ELFObjectFile.h:234
llvm::object::ELFRelocationRef::ELFRelocationRef
ELFRelocationRef(const RelocationRef &B)
Definition:ELFObjectFile.h:230
llvm::object::ELFSectionRef
Definition:ELFObjectFile.h:130
llvm::object::ELFSectionRef::getFlags
uint64_t getFlags() const
Definition:ELFObjectFile.h:144
llvm::object::ELFSectionRef::getObject
const ELFObjectFileBase * getObject() const
Definition:ELFObjectFile.h:136
llvm::object::ELFSectionRef::getOffset
uint64_t getOffset() const
Definition:ELFObjectFile.h:148
llvm::object::ELFSectionRef::ELFSectionRef
ELFSectionRef(const SectionRef &B)
Definition:ELFObjectFile.h:132
llvm::object::ELFSectionRef::getType
uint32_t getType() const
Definition:ELFObjectFile.h:140
llvm::object::ELFSymbolRef
Definition:ELFObjectFile.h:168
llvm::object::ELFSymbolRef::getOther
uint8_t getOther() const
Definition:ELFObjectFile.h:186
llvm::object::ELFSymbolRef::getObject
const ELFObjectFileBase * getObject() const
Definition:ELFObjectFile.h:174
llvm::object::ELFSymbolRef::getELFType
uint8_t getELFType() const
Definition:ELFObjectFile.h:190
llvm::object::ELFSymbolRef::ELFSymbolRef
ELFSymbolRef(const SymbolRef &B)
Definition:ELFObjectFile.h:170
llvm::object::ELFSymbolRef::getBinding
uint8_t getBinding() const
Definition:ELFObjectFile.h:182
llvm::object::ELFSymbolRef::getSize
uint64_t getSize() const
Definition:ELFObjectFile.h:178
llvm::object::ELFSymbolRef::getELFTypeName
StringRef getELFTypeName() const
Definition:ELFObjectFile.h:194
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition:ObjectFile.h:229
llvm::object::RelocationRef
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition:ObjectFile.h:52
llvm::object::RelocationRef::getObject
const ObjectFile * getObject() const
Definition:ObjectFile.h:640
llvm::object::RelocationRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition:ObjectFile.h:636
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition:ObjectFile.h:81
llvm::object::SectionRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition:ObjectFile.h:598
llvm::object::SectionRef::getObject
const ObjectFile * getObject() const
Definition:ObjectFile.h:602
llvm::object::SymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition:ObjectFile.h:168
llvm::object::SymbolRef::Type
Type
Definition:ObjectFile.h:172
llvm::object::SymbolRef::ST_Other
@ ST_Other
Definition:ObjectFile.h:174
llvm::object::SymbolRef::ST_Unknown
@ ST_Unknown
Definition:ObjectFile.h:173
llvm::object::SymbolRef::ST_Function
@ ST_Function
Definition:ObjectFile.h:178
llvm::object::SymbolRef::ST_File
@ ST_File
Definition:ObjectFile.h:177
llvm::object::SymbolRef::ST_Data
@ ST_Data
Definition:ObjectFile.h:175
llvm::object::SymbolRef::ST_Debug
@ ST_Debug
Definition:ObjectFile.h:176
llvm::object::SymbolRef::getObject
const ObjectFile * getObject() const
Definition:ObjectFile.h:488
llvm::object::SymbolicFile::symbol_begin
virtual basic_symbol_iterator symbol_begin() const =0
llvm::object::SymbolicFile::symbol_end
virtual basic_symbol_iterator symbol_end() const =0
llvm::object::content_iterator< SectionRef >
llvm::object::content_iterator< SectionRef >::operator*
const SectionRef & operator*() const
Definition:SymbolicFile.h:83
llvm::object::content_iterator< SectionRef >::operator->
const SectionRef * operator->() const
Definition:SymbolicFile.h:81
llvm::object::elf_relocation_iterator
Definition:ELFObjectFile.h:243
llvm::object::elf_relocation_iterator::operator*
const ELFRelocationRef & operator*() const
Definition:ELFObjectFile.h:254
llvm::object::elf_relocation_iterator::elf_relocation_iterator
elf_relocation_iterator(const relocation_iterator &B)
Definition:ELFObjectFile.h:245
llvm::object::elf_relocation_iterator::operator->
const ELFRelocationRef * operator->() const
Definition:ELFObjectFile.h:249
llvm::object::elf_section_iterator
Definition:ELFObjectFile.h:153
llvm::object::elf_section_iterator::elf_section_iterator
elf_section_iterator(const section_iterator &B)
Definition:ELFObjectFile.h:155
llvm::object::elf_section_iterator::operator->
const ELFSectionRef * operator->() const
Definition:ELFObjectFile.h:159
llvm::object::elf_section_iterator::operator*
const ELFSectionRef & operator*() const
Definition:ELFObjectFile.h:163
llvm::object::elf_symbol_iterator
Definition:ELFObjectFile.h:213
llvm::object::elf_symbol_iterator::operator*
const ELFSymbolRef & operator*() const
Definition:ELFObjectFile.h:223
llvm::object::elf_symbol_iterator::elf_symbol_iterator
elf_symbol_iterator(const basic_symbol_iterator &B)
Definition:ELFObjectFile.h:215
llvm::object::elf_symbol_iterator::operator->
const ELFSymbolRef * operator->() const
Definition:ELFObjectFile.h:219
llvm::object::symbol_iterator
Definition:ObjectFile.h:208
llvm::object::symbol_iterator::operator->
const SymbolRef * operator->() const
Definition:ObjectFile.h:215
llvm::object::symbol_iterator::operator*
const SymbolRef & operator*() const
Definition:ObjectFile.h:220
uint16_t
uint32_t
uint64_t
uint8_t
iterator_range.h
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
Error.h
ErrorHandling.h
Error.h
llvm::ELFAttrs::Format_Version
@ Format_Version
Definition:ELFAttributes.h:34
llvm::ELF::ELFOSABI_HURD
@ ELFOSABI_HURD
Definition:ELF.h:349
llvm::ELF::ELFOSABI_CUDA
@ ELFOSABI_CUDA
Definition:ELF.h:362
llvm::ELF::ELFOSABI_OPENBSD
@ ELFOSABI_OPENBSD
Definition:ELF.h:356
llvm::ELF::ELFOSABI_NETBSD
@ ELFOSABI_NETBSD
Definition:ELF.h:346
llvm::ELF::ELFOSABI_AMDGPU_HSA
@ ELFOSABI_AMDGPU_HSA
Definition:ELF.h:364
llvm::ELF::ELFOSABI_SOLARIS
@ ELFOSABI_SOLARIS
Definition:ELF.h:350
llvm::ELF::ELFOSABI_FREEBSD
@ ELFOSABI_FREEBSD
Definition:ELF.h:353
llvm::ELF::ELFOSABI_LINUX
@ ELFOSABI_LINUX
Definition:ELF.h:348
llvm::ELF::ELFOSABI_AIX
@ ELFOSABI_AIX
Definition:ELF.h:351
llvm::ELF::ELFOSABI_AMDGPU_MESA3D
@ ELFOSABI_AMDGPU_MESA3D
Definition:ELF.h:366
llvm::ELF::ELFOSABI_AMDGPU_PAL
@ ELFOSABI_AMDGPU_PAL
Definition:ELF.h:365
llvm::ELF::SHN_ABS
@ SHN_ABS
Definition:ELF.h:1089
llvm::ELF::SHN_COMMON
@ SHN_COMMON
Definition:ELF.h:1090
llvm::ELF::SHN_UNDEF
@ SHN_UNDEF
Definition:ELF.h:1083
llvm::ELF::ELFCLASS64
@ ELFCLASS64
Definition:ELF.h:332
llvm::ELF::ELFCLASS32
@ ELFCLASS32
Definition:ELF.h:331
llvm::ELF::EI_ABIVERSION
@ EI_ABIVERSION
Definition:ELF.h:57
llvm::ELF::EI_CLASS
@ EI_CLASS
Definition:ELF.h:53
llvm::ELF::EI_OSABI
@ EI_OSABI
Definition:ELF.h:56
llvm::ELF::EM_MSP430
@ EM_MSP430
Definition:ELF.h:225
llvm::ELF::EM_S390
@ EM_S390
Definition:ELF.h:153
llvm::ELF::EM_PPC64
@ EM_PPC64
Definition:ELF.h:152
llvm::ELF::EM_SPARC
@ EM_SPARC
Definition:ELF.h:138
llvm::ELF::EM_CSKY
@ EM_CSKY
Definition:ELF.h:324
llvm::ELF::EM_SPARC32PLUS
@ EM_SPARC32PLUS
Definition:ELF.h:149
llvm::ELF::EM_68K
@ EM_68K
Definition:ELF.h:140
llvm::ELF::EM_386
@ EM_386
Definition:ELF.h:139
llvm::ELF::EM_CUDA
@ EM_CUDA
Definition:ELF.h:289
llvm::ELF::EM_LOONGARCH
@ EM_LOONGARCH
Definition:ELF.h:325
llvm::ELF::EM_BPF
@ EM_BPF
Definition:ELF.h:322
llvm::ELF::EM_PPC
@ EM_PPC
Definition:ELF.h:151
llvm::ELF::EM_X86_64
@ EM_X86_64
Definition:ELF.h:181
llvm::ELF::EM_HEXAGON
@ EM_HEXAGON
Definition:ELF.h:260
llvm::ELF::EM_LANAI
@ EM_LANAI
Definition:ELF.h:321
llvm::ELF::EM_MIPS
@ EM_MIPS
Definition:ELF.h:144
llvm::ELF::EM_SPARCV9
@ EM_SPARCV9
Definition:ELF.h:162
llvm::ELF::EM_AARCH64
@ EM_AARCH64
Definition:ELF.h:283
llvm::ELF::EM_XTENSA
@ EM_XTENSA
Definition:ELF.h:214
llvm::ELF::EM_RISCV
@ EM_RISCV
Definition:ELF.h:320
llvm::ELF::EM_ARM
@ EM_ARM
Definition:ELF.h:159
llvm::ELF::EM_VE
@ EM_VE
Definition:ELF.h:323
llvm::ELF::EM_IAMCU
@ EM_IAMCU
Definition:ELF.h:142
llvm::ELF::EM_AMDGPU
@ EM_AMDGPU
Definition:ELF.h:319
llvm::ELF::EM_AVR
@ EM_AVR
Definition:ELF.h:202
llvm::ELF::SHT_REL
@ SHT_REL
Definition:ELF.h:1106
llvm::ELF::SHT_ARM_ATTRIBUTES
@ SHT_ARM_ATTRIBUTES
Definition:ELF.h:1158
llvm::ELF::SHT_NOBITS
@ SHT_NOBITS
Definition:ELF.h:1105
llvm::ELF::SHT_SYMTAB
@ SHT_SYMTAB
Definition:ELF.h:1099
llvm::ELF::SHT_HEXAGON_ATTRIBUTES
@ SHT_HEXAGON_ATTRIBUTES
Definition:ELF.h:1185
llvm::ELF::SHT_CREL
@ SHT_CREL
Definition:ELF.h:1119
llvm::ELF::SHT_DYNAMIC
@ SHT_DYNAMIC
Definition:ELF.h:1103
llvm::ELF::SHT_SYMTAB_SHNDX
@ SHT_SYMTAB_SHNDX
Definition:ELF.h:1113
llvm::ELF::SHT_RISCV_ATTRIBUTES
@ SHT_RISCV_ATTRIBUTES
Definition:ELF.h:1181
llvm::ELF::SHT_RELA
@ SHT_RELA
Definition:ELF.h:1101
llvm::ELF::SHT_DYNSYM
@ SHT_DYNSYM
Definition:ELF.h:1108
llvm::ELF::EF_AMDGPU_MACH_AMDGCN_LAST
@ EF_AMDGPU_MACH_AMDGCN_LAST
Definition:ELF.h:838
llvm::ELF::EF_AMDGPU_MACH_R600_LAST
@ EF_AMDGPU_MACH_R600_LAST
Definition:ELF.h:771
llvm::ELF::EF_AMDGPU_MACH_AMDGCN_FIRST
@ EF_AMDGPU_MACH_AMDGCN_FIRST
Definition:ELF.h:837
llvm::ELF::EF_AMDGPU_MACH
@ EF_AMDGPU_MACH
Definition:ELF.h:737
llvm::ELF::EF_AMDGPU_MACH_R600_FIRST
@ EF_AMDGPU_MACH_R600_FIRST
Definition:ELF.h:770
llvm::ELF::SHF_ALLOC
@ SHF_ALLOC
Definition:ELF.h:1198
llvm::ELF::SHF_COMPRESSED
@ SHF_COMPRESSED
Definition:ELF.h:1226
llvm::ELF::SHF_WRITE
@ SHF_WRITE
Definition:ELF.h:1195
llvm::ELF::SHF_EXECINSTR
@ SHF_EXECINSTR
Definition:ELF.h:1201
llvm::ELF::STB_GLOBAL
@ STB_GLOBAL
Definition:ELF.h:1352
llvm::ELF::STB_LOCAL
@ STB_LOCAL
Definition:ELF.h:1351
llvm::ELF::STB_GNU_UNIQUE
@ STB_GNU_UNIQUE
Definition:ELF.h:1354
llvm::ELF::STB_WEAK
@ STB_WEAK
Definition:ELF.h:1353
llvm::ELF::ET_REL
@ ET_REL
Definition:ELF.h:117
llvm::ELF::STT_FUNC
@ STT_FUNC
Definition:ELF.h:1365
llvm::ELF::STT_NOTYPE
@ STT_NOTYPE
Definition:ELF.h:1363
llvm::ELF::STT_SECTION
@ STT_SECTION
Definition:ELF.h:1366
llvm::ELF::STT_FILE
@ STT_FILE
Definition:ELF.h:1367
llvm::ELF::STT_COMMON
@ STT_COMMON
Definition:ELF.h:1368
llvm::ELF::STT_GNU_IFUNC
@ STT_GNU_IFUNC
Definition:ELF.h:1370
llvm::ELF::STT_OBJECT
@ STT_OBJECT
Definition:ELF.h:1364
llvm::ELF::STT_TLS
@ STT_TLS
Definition:ELF.h:1369
llvm::ELF::STV_HIDDEN
@ STV_HIDDEN
Definition:ELF.h:1383
llvm::ELF::STV_PROTECTED
@ STV_PROTECTED
Definition:ELF.h:1384
llvm::ELF::STV_DEFAULT
@ STV_DEFAULT
Definition:ELF.h:1381
llvm::dwarf_linker::getSectionName
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
Definition:DWARFLinkerBase.h:66
llvm::object::getObject
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
Definition:XCOFFObjectFile.cpp:34
llvm::object::getSection
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
Definition:ELF.h:534
llvm::object::operator<
bool operator<(const ELFSymbolRef &A, const ELFSymbolRef &B)
Definition:ELFObjectFile.h:205
llvm::object::createError
Error createError(const Twine &Err)
Definition:Error.h:84
llvm::object::getELFRelocationTypeName
StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type)
Definition:ELF.cpp:24
llvm::object::NumElfSymbolTypes
constexpr int NumElfSymbolTypes
Definition:ELFObjectFile.h:46
llvm::object::section_iterator
content_iterator< SectionRef > section_iterator
Definition:ObjectFile.h:47
llvm::object::relocation_iterator
content_iterator< RelocationRef > relocation_iterator
Definition:ObjectFile.h:77
llvm::object::basic_symbol_iterator
content_iterator< BasicSymbolRef > basic_symbol_iterator
Definition:SymbolicFile.h:143
llvm::object::ElfSymbolTypes
const llvm::EnumEntry< unsigned > ElfSymbolTypes[NumElfSymbolTypes]
Definition:ELFObjectFile.cpp:40
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::handleAllErrors
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition:Error.h:977
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition:iterator_range.h:77
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition:Error.cpp:167
llvm::IRMemLocation::Other
@ Other
Any other memory.
llvm::IRMemLocation::First
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition:Error.h:756
llvm::RoundingMode::Dynamic
@ Dynamic
Denotes mode unknown at compile time.
llvm::cast
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition:Casting.h:565
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition:STLExtras.h:1903
llvm::toString
const char * toString(DWARFSectionKind Kind)
Definition:DWARFUnitIndex.h:67
llvm::endianness
endianness
Definition:bit.h:70
llvm::endianness::little
@ little
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::errorToErrorCode
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
Definition:Error.cpp:117
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition:Error.h:1069
llvm::EnumEntry
Definition:ScopedPrinter.h:24
llvm::SectionName
Definition:DWARFSection.h:21
llvm::object::ELFPltEntry
Definition:ELFObjectFile.h:51
llvm::object::ELFPltEntry::Address
uint64_t Address
Definition:ELFObjectFile.h:54
llvm::object::ELFPltEntry::Symbol
std::optional< DataRefImpl > Symbol
Definition:ELFObjectFile.h:53
llvm::object::ELFPltEntry::Section
StringRef Section
Definition:ELFObjectFile.h:52
llvm::object::DataRefImpl
Definition:SymbolicFile.h:35
llvm::object::DataRefImpl::b
uint32_t b
Definition:SymbolicFile.h:39
llvm::object::DataRefImpl::p
uintptr_t p
Definition:SymbolicFile.h:41
llvm::object::DataRefImpl::d
struct llvm::object::DataRefImpl::@370 d
llvm::object::DataRefImpl::a
uint32_t a
Definition:SymbolicFile.h:39

Generated on Fri Jul 18 2025 09:30:07 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp