13 #ifndef LLVM_OBJECT_OBJECTFILE_H 14 #define LLVM_OBJECT_OBJECTFILE_H 32 #include <system_error> 36 class ARMAttributeParser;
41 class MachOObjectFile;
45 class symbol_iterator;
98 uint64_t getAddress()
const;
99 uint64_t getIndex()
const;
100 uint64_t getSize()
const;
106 bool isCompressed()
const;
113 bool isVirtual()
const;
115 bool isStripped()
const;
120 bool isBerkeleyText()
const;
124 bool isBerkeleyData()
const;
131 return make_range(relocation_begin(), relocation_end());
143 uint64_t SectionIndex = UndefSection;
188 uint64_t getValue()
const;
192 uint64_t getCommonSize()
const;
224 virtual void anchor();
230 return reinterpret_cast<const uint8_t *
>(
Data.getBufferStart());
247 virtual uint64_t getSymbolValueImpl(
DataRefImpl Symb)
const = 0;
249 virtual uint64_t getCommonSymbolSizeImpl(
DataRefImpl Symb)
const = 0;
257 virtual void moveSectionNext(
DataRefImpl &Sec)
const = 0;
259 virtual uint64_t getSectionAddress(
DataRefImpl Sec)
const = 0;
260 virtual uint64_t getSectionIndex(
DataRefImpl Sec)
const = 0;
261 virtual uint64_t getSectionSize(
DataRefImpl Sec)
const = 0;
264 virtual uint64_t getSectionAlignment(
DataRefImpl Sec)
const = 0;
265 virtual bool isSectionCompressed(
DataRefImpl Sec)
const = 0;
266 virtual bool isSectionText(
DataRefImpl Sec)
const = 0;
267 virtual bool isSectionData(
DataRefImpl Sec)
const = 0;
268 virtual bool isSectionBSS(
DataRefImpl Sec)
const = 0;
270 virtual bool isSectionVirtual(
DataRefImpl Sec)
const = 0;
271 virtual bool isSectionBitcode(
DataRefImpl Sec)
const;
272 virtual bool isSectionStripped(
DataRefImpl Sec)
const;
273 virtual bool isBerkeleyText(
DataRefImpl Sec)
const;
274 virtual bool isBerkeleyData(
DataRefImpl Sec)
const;
281 virtual void moveRelocationNext(
DataRefImpl &Rel)
const = 0;
282 virtual uint64_t getRelocationOffset(
DataRefImpl Rel)
const = 0;
284 virtual uint64_t getRelocationType(
DataRefImpl Rel)
const = 0;
285 virtual void getRelocationTypeName(
DataRefImpl Rel,
296 return getCommonSymbolSizeImpl(Symb);
300 return std::vector<SectionRef>();
318 virtual uint8_t getBytesInAddress()
const = 0;
320 virtual StringRef getFileFormatName()
const = 0;
329 Triple makeTriple()
const;
335 virtual bool isRelocatableObject()
const = 0;
407 return cast<ObjectFile>(
O);
413 : SectionPimpl(SectionP)
414 , OwningObject(Owner) {}
417 return OwningObject == Other.OwningObject &&
418 SectionPimpl == Other.SectionPimpl;
422 return !(*
this ==
Other);
426 assert(OwningObject == Other.OwningObject);
427 return SectionPimpl < Other.SectionPimpl;
455 return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
521 : RelocationPimpl(RelocationP)
522 , OwningObject(Owner) {}
525 return RelocationPimpl == Other.RelocationPimpl;
549 return RelocationPimpl;
568 TS.
p = (uintptr_t)-1;
579 #endif // LLVM_OBJECT_OBJECTFILE_H raw_ostream & operator<<(raw_ostream &OS, const SectionedAddress &Addr)
const content_type & operator*() const
static uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAsmLayout &Layout)
virtual bool isBerkeleyData(DataRefImpl Sec) const
This class represents lattice values for constants.
Expected< StringRef > getName() const
uint64_t getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address...
uint64_t getOffset() const
bool operator!=(const SectionRef &Other) const
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
virtual Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Optional< std::vector< StOtherPiece > > Other
Expected< section_iterator > getRelocatedSection() const
virtual bool isSectionBSS(DataRefImpl Sec) const =0
This class is the base class for all object file types.
bool operator==(const RelocationRef &Other) const
Expected< StringRef > getContents() const
virtual Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const =0
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
const uint8_t * base() const
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
Error takeError()
Take ownership of the stored error.
const ObjectFile * getObject() const
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual bool isSectionStripped(DataRefImpl Sec) const
relocation_iterator relocation_end() const
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
static uint32_t getAlignment(const MCSectionCOFF &Sec)
uint64_t getAddress() const
DataRefImpl getRawDataRefImpl() const
static StringRef getSymbolName(SymbolKind SymKind)
This is a value type class that represents a single relocation in the list of relocations in the obje...
bool operator==(const SectionRef &Other) const
static StringRef getName(Value *V)
bool isText() const
Whether this section contains instructions.
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
Tagged union holding either a T or a Error.
bool operator!=(const DataRefImpl &a, const DataRefImpl &b)
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
uint64_t getIndex() const
bool isCompressed() const
uint64_t getCommonSize() const
bool operator<(const SectionedAddress &LHS, const SectionedAddress &RHS)
const ObjectFile * getObject() const
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
section_iterator_range sections() const
virtual Expected< uint64_t > getStartAddress() const
static unsigned getHashValue(const object::SectionRef &Sec)
virtual bool isSectionBitcode(DataRefImpl Sec) const
const ObjectFile * getObject() const
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
struct llvm::object::DataRefImpl::@292 d
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
static object::SectionRef getEmptyKey()
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static FeatureBitset getFeatures(StringRef CPU, StringRef FS, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
The instances of the Type class are immutable: once they are created, they are never changed...
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
symbol_iterator(const basic_symbol_iterator &B)
virtual std::vector< SectionRef > dynamic_relocation_sections() const
static bool isEqual(const object::SectionRef &A, const object::SectionRef &B)
relocation_iterator relocation_begin() const
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
bool operator<(const SectionRef &Other) const
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
DataRefImpl getRawDataRefImpl() const
bool isData() const
Whether this section contains data, not instructions.
Triple - Helper class for working with autoconf configuration names.
SymbolRef(const BasicSymbolRef &B)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool isBerkeleyText() const
Whether this section will be placed in the text segment, according to the Berkeley size format...
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
FileType
Defines the file type this file represents.
bool isBSS() const
Whether this section contains BSS uninitialized data.
Expected< SymbolRef::Type > getType() const
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcode - Return true if the given bytes are the magic bytes for LLVM IR bitcode, either with or without a wrapper.
const SymbolicFile * getObject() const
virtual void setARMSubArch(Triple &TheTriple) const
const SymbolRef & operator*() const
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
uint64_t getSymbolValue(DataRefImpl Symb) const
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
Expected< StringRef > getName() const
A range adaptor for a pair of iterators.
Manages the enabling and disabling of subtarget specific features.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
virtual bool isSectionText(DataRefImpl Sec) const =0
This is a value type class that represents a single symbol in the list of symbols in the object file...
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
static bool classof(const Binary *v)
symbol_iterator getSymbol() const
symbol_iterator_range symbols() const
virtual void moveSectionNext(DataRefImpl &Sec) const =0
iterator_range< relocation_iterator > relocations() const
virtual bool isBerkeleyText(DataRefImpl Sec) const
virtual bool isSectionData(DataRefImpl Sec) const =0
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
This is a value type class that represents a single symbol in the list of symbols in the object file...
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
const SymbolRef * operator->() const
virtual bool isSectionCompressed(DataRefImpl Sec) const =0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const =0
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
virtual uint64_t getSectionSize(DataRefImpl Sec) const =0
Lightweight error class with error context and mandatory checking.
virtual void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
symbol_iterator(SymbolRef Sym)
This class implements an extremely fast bulk output stream that can only output to a stream...
static object::SectionRef getTombstoneKey()
StringRef - Represent a constant reference to a string, i.e.
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format...
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
DataRefImpl getRawDataRefImpl() const
This is a value type class that represents a single section in the list of sections in the object fil...
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...