13#ifndef LLVM_OBJECT_OBJECTFILE_H
14#define LLVM_OBJECT_OBJECTFILE_H
35class SubtargetFeatures;
154 return std::tie(
LHS.SectionIndex,
LHS.Address) <
155 std::tie(
RHS.SectionIndex,
RHS.Address);
160 return std::tie(
LHS.SectionIndex,
LHS.Address) ==
161 std::tie(
RHS.SectionIndex,
RHS.Address);
230 virtual void anchor();
309 if (!SymbolFlagsOrErr)
317 return std::vector<SectionRef>();
374 bool InitContent =
true);
381 return v->isObject();
396 size_t MachOFilesetEntryOffset = 0);
422 return Iterator !=
Other.Iterator;
426 void scanPredicate() {
427 while (Iterator != End && !Predicate(*Iterator)) {
441 : Predicate(
std::
move(Pred)), Object(Obj) {}
490 return cast<ObjectFile>(O);
496 : SectionPimpl(SectionP)
497 , OwningObject(Owner) {}
500 return OwningObject ==
Other.OwningObject &&
501 SectionPimpl ==
Other.SectionPimpl;
505 return !(*
this ==
Other);
510 return SectionPimpl <
Other.SectionPimpl;
538 return StringRef(
reinterpret_cast<const char *
>(Res->data()), Res->size());
609 : RelocationPimpl(RelocationP)
610 , OwningObject(Owner) {}
613 return RelocationPimpl ==
Other.RelocationPimpl;
637 return RelocationPimpl;
656 TS.
p = (uintptr_t)-1;
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
const char * getBufferStart() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
A range adaptor for a pair of iterators.
This is a value type class that represents a single symbol in the list of symbols in the object file.
const SymbolicFile * getObject() const
DataRefImpl getRawDataRefImpl() const
This class is the base class for all object file types.
virtual bool isBerkeleyText(DataRefImpl Sec) const
virtual Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
virtual bool isBerkeleyData(DataRefImpl Sec) const
virtual bool isSectionBSS(DataRefImpl Sec) const =0
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
virtual std::vector< SectionRef > dynamic_relocation_sections() const
static Expected< std::unique_ptr< MachOObjectFile > > createMachOObjectFile(MemoryBufferRef Object, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0, size_t MachOFilesetEntryOffset=0)
Create a MachOObjectFile instance from a given buffer.
static Expected< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
virtual section_iterator section_end() const =0
virtual llvm::binaryformat::Swift5ReflectionSectionKind mapReflectionSectionNameToEnumValue(StringRef SectionName) const
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
virtual Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const =0
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const =0
virtual Expected< SubtargetFeatures > getFeatures() const =0
virtual bool isSectionCompressed(DataRefImpl Sec) const =0
virtual uint64_t getSectionSize(DataRefImpl Sec) const =0
Triple makeTriple() const
Create a triple from the data in this object file.
virtual bool isSectionText(DataRefImpl Sec) const =0
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
section_iterator_range sections() const
virtual StringRef getFileFormatName() const =0
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const =0
virtual void moveSectionNext(DataRefImpl &Sec) const =0
virtual bool isDebugSection(DataRefImpl Sec) const
virtual void setARMSubArch(Triple &TheTriple) const
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
static Expected< std::unique_ptr< WasmObjectFile > > createWasmObjectFile(MemoryBufferRef Object)
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
ObjectFile(const ObjectFile &other)=delete
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
symbol_iterator_range symbols() const
virtual bool isSectionData(DataRefImpl Sec) const =0
Expected< uint64_t > getSymbolValue(DataRefImpl Symb) const
iterator_range< section_iterator > section_iterator_range
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
const uint8_t * base() const
virtual Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const =0
virtual bool isRelocatableObject() const =0
True if this is a relocatable object (.o/.obj).
virtual Triple::OSType getOS() const
bool isReflectionSectionStrippable(llvm::binaryformat::Swift5ReflectionSectionKind ReflectionSectionKind) const
True if the reflection section can be stripped by the linker.
virtual bool hasDebugInfo() const
static Expected< std::unique_ptr< ObjectFile > > createGOFFObjectFile(MemoryBufferRef Object)
static bool classof(const Binary *v)
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
virtual Expected< uint64_t > getStartAddress() const
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
virtual Triple::ArchType getArch() const =0
ObjectFile & operator=(const ObjectFile &other)=delete
virtual bool isSectionStripped(DataRefImpl Sec) const
virtual std::optional< StringRef > tryGetCPUName() const
virtual bool isSectionBitcode(DataRefImpl Sec) const
iterator_range< symbol_iterator > symbol_iterator_range
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
virtual section_iterator section_begin() const =0
This is a value type class that represents a single relocation in the list of relocations in the obje...
bool operator==(const RelocationRef &Other) const
uint64_t getOffset() const
symbol_iterator getSymbol() const
const ObjectFile * getObject() const
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
DataRefImpl getRawDataRefImpl() const
A filtered iterator for SectionRefs that skips sections based on some given predicate.
SectionFilterIterator & operator++()
const SectionRef & operator*() const
bool operator!=(const SectionFilterIterator &Other) const
SectionFilterIterator(SectionFilterPredicate Pred, const section_iterator &Begin, const section_iterator &End)
Creates an iterator range of SectionFilterIterators for a given Object and predicate.
SectionFilterIterator begin()
SectionFilter(SectionFilterPredicate Pred, const ObjectFile &Obj)
SectionFilterIterator end()
This is a value type class that represents a single section in the list of sections in the object fil...
uint64_t getIndex() const
bool operator<(const SectionRef &Other) const
DataRefImpl getRawDataRefImpl() const
bool operator!=(const SectionRef &Other) const
bool isDebugSection() const
Whether this section is a debug section.
iterator_range< relocation_iterator > relocations() const
bool isData() const
Whether this section contains data, not instructions.
Expected< StringRef > getContents() const
relocation_iterator relocation_end() const
bool isCompressed() const
bool isBSS() const
Whether this section contains BSS uninitialized data.
bool containsSymbol(SymbolRef S) const
bool operator==(const SectionRef &Other) const
uint64_t getAddress() const
bool isBerkeleyText() const
Whether this section will be placed in the text segment, according to the Berkeley size format.
bool isText() const
Whether this section contains instructions.
relocation_iterator relocation_begin() const
Align getAlignment() const
Get the alignment of this section.
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format.
const ObjectFile * getObject() const
Expected< StringRef > getName() const
Expected< section_iterator > getRelocatedSection() const
Returns the related section if this section contains relocations.
This is a value type class that represents a single symbol in the list of symbols in the object file.
Expected< SymbolRef::Type > getType() const
SymbolRef(const BasicSymbolRef &B)
Expected< StringRef > getName() const
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
const ObjectFile * getObject() const
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
Expected< uint64_t > getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address.
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
uint64_t getCommonSize() const
virtual basic_symbol_iterator symbol_begin() const =0
virtual basic_symbol_iterator symbol_end() const =0
virtual Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const =0
const content_type & operator*() const
const SymbolRef * operator->() const
symbol_iterator(const basic_symbol_iterator &B)
const SymbolRef & operator*() const
symbol_iterator(SymbolRef Sym)
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
bool operator<(const ELFSymbolRef &A, const ELFSymbolRef &B)
content_iterator< SectionRef > section_iterator
std::function< bool(const SectionRef &)> SectionFilterPredicate
raw_ostream & operator<<(raw_ostream &OS, const SectionedAddress &Addr)
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
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<X> - Return the argument parameter cast to the specified type.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static unsigned getHashValue(const object::SectionRef &Sec)
static object::SectionRef getEmptyKey()
static object::SectionRef getTombstoneKey()
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
An information struct used to provide DenseMap with the various necessary components for a given valu...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
@ unknown
Unrecognized file.
static const uint64_t UndefSection
struct llvm::object::DataRefImpl::@371 d