llvm::object::ObjectFile

Format-independent object file base class.

Synopsis

Declared in <llvm/Object/ObjectFile.h>

class ObjectFile
    : public SymbolicFile

Base Classes

NameDescription
SymbolicFileBinary that exposes a symbol table (object file, IR, COFF import, or TAPI).

Type Aliases

NameDescription
basic_symbol_iterator_range Iterator range over BasicSymbolRef symbols.
section_iterator_range Iterator range over this object's sections.
symbol_iterator_range Iterator range type over SymbolRef symbols in this object.

Member Functions

NameDescription
ObjectFile [constructor]Constructors
operator= [deleted]ObjectFile is not copy-assignable.
dynamic_relocation_sections [virtual]Sections that hold dynamic relocations (empty by default).
getArch [virtual]Target architecture of this object file.
getBytesInAddress [virtual]The number of bytes used to represent an address in this object file format.
getCommonSymbolSize Size of common symbol Symb in bytes.
getData Returns the binary's raw buffer contents.
getFeatures [virtual]Subtarget features described by this object file.
getFileFormatName [virtual]Human-readable name of this object file format.
getFileName Returns the file name (buffer identifier) for this binary.
getMemoryBufferRef Returns a MemoryBufferRef over the binary's data.
getOS [virtual]Operating system this object targets, or UnknownOS if unspecified.
getStartAddress [virtual]Entry point address, or an error if the format has none.
getSymbolFlags [virtual]Flags for symbol Symb (bitwise OR of BasicSymbolRef::Flags).
getTripleObjectFormat Maps this binary's type to a Triple::ObjectFormatType.
getType Return the discriminator type ID for this binary.
hasDebugInfo [virtual]True if this object contains debug information sections.
initContent [virtual]Perform format-specific initialization of the binary's content.
is64Bit [virtual]True if this file uses a 64-bit address size.
isArchive True if this is a static or dynamic archive.
isCOFF True if this is a COFF object file.
isCOFFImportFile True if this is a COFF import library member.
isDXContainer True if this is a DirectX container.
isELF True if this is an ELF object (any bitness/endianness).
isGOFF True if this is a GOFF object file.
isIR True if this is an LLVM IR bitcode file.
isLittleEndian True if this binary's object format is little-endian.
isMachO True if this is a Mach-O object (32- or 64-bit, either endianness).
isMachOUniversalBinary True if this is a Mach-O fat/universal binary.
isMinidump True if this is a Windows minidump.
isObject True if this is a concrete object-file format (ELF, COFF, Mach-O, etc.).
isOffloadFile True if this is an offloading binary file.
isReflectionSectionStrippable True if the reflection section can be stripped by the linker.
isRelocatableObject [virtual]True if this is a relocatable object (.o/.obj).
isSymbolic True if this binary exposes a symbol table (IR, object, COFF import, or TAPI).
isTapiFile True if this is a text-based stub (TAPI) file.
isTapiUniversal True if this is a text-based stub (TAPI) universal file.
isWasm True if this is a WebAssembly object file.
isWinRes True if this is a Windows resource (.res) file.
isXCOFF True if this is an AIX XCOFF object (32- or 64-bit).
makeTriple Create a triple from the data in this object file.
mapDebugSectionName [virtual]Maps a debug section name to a standard DWARF section name.
moveSymbolNext [virtual]Advances Symb to the next symbol.
printSymbolName [virtual]Print the name of symbol Symb to OS.
section_begin [virtual]Iterator to the first section in this object.
section_end [virtual]Past-the-end iterator for sections in this object.
sections Range over all sections in this object file.
setARMSubArch [virtual]Set ARM sub-architecture fields on TheTriple from this object.
symbol_begin [virtual]Iterator to the first symbol in this file.
symbol_end [virtual]Past-the-end iterator for symbols in this file.
symbols Range over all symbols in this object file.
tryGetCPUName [virtual]CPU name encoded in the object, if the format provides one.

Static Member Functions

NameDescription
checkOffset Check that Addr..Addr+Size lies within buffer M.
classof True if v is an ObjectFile (type ID between StartObjects and EndObjects).
createCOFFObjectFile Create a COFF ObjectFile from Object.
createDXContainerObjectFile Create a DirectX container ObjectFile from Object.
createELFObjectFile Create an ELF ObjectFile from Object.
createGOFFObjectFile Create a GOFF ObjectFile from Object.
createMachOObjectFile Create a Mach-O ObjectFile from Object.
createObjectFile createObjectFile overloads
createSymbolicFile createSymbolicFile overloads
createWasmObjectFile Create a WebAssembly ObjectFile from Object.
createXCOFFObjectFile Create an XCOFF ObjectFile from Object of the given FileType.
isSymbolicFile True if Type identifies a symbolic file format (optionally using Context for IR).

Protected Enums

NameDescription
Unnamed enum Discriminators for concrete Binary subclasses.

Protected Member Functions

NameDescription
ObjectFile [constructor]Construct an ObjectFile of Type backed by Source.
base Pointer to the start of this object's memory-mapped contents.
getCommonSymbolSizeImpl [virtual]Size of common symbol Symb (format-specific implementation).
getRelocatedSection [virtual]Section that relocations in Sec apply to, if any.
getRelocationOffset [virtual]Byte offset of relocation Rel within its section.
getRelocationSymbol [virtual]Symbol referenced by relocation Rel.
getRelocationType [virtual]Format-specific type encoding of relocation Rel.
getRelocationTypeName [virtual]Append a display name for relocation Rel's type to Result.
getSectionAddress [virtual]Virtual load address of section Sec.
getSectionAlignment [virtual]Alignment of section Sec in bytes.
getSectionContents [virtual]Raw contents of section Sec.
getSectionIndex [virtual]Index of section Sec within this object.
getSectionName [virtual]Name of section Sec.
getSectionSize [virtual]Size in bytes of section Sec.
getSymbolAddress [virtual]Virtual address of symbol Symb.
getSymbolAlignment [virtual]Alignment of symbol Symb as the actual value (not log 2).
getSymbolName [virtual]Name of symbol Symb.
getSymbolSection [virtual]Section defining symbol Symb, or section_end() if undefined/absolute.
getSymbolType [virtual]Classify symbol Symb (data, function, file, etc.).
getSymbolValue Return the format-specific value of symbol Symb.
getSymbolValueImpl [virtual]Format-specific symbol value (address or offset) for Symb.
isBerkeleyData [virtual]True if section Sec counts as Berkeley data (allocatable data, not text).
isBerkeleyText [virtual]True if section Sec counts as Berkeley text (allocatable code/rodata).
isDebugSection [virtual]True if section Sec is a debug info section.
isSectionBSS [virtual]True if section Sec is BSS (zero-initialized, no file contents).
isSectionBitcode [virtual]True if section Sec holds LLVM IR bitcode.
isSectionCompressed [virtual]True if section Sec is compressed.
isSectionData [virtual]True if the section contains initialized data (not text).
isSectionStripped [virtual]True if section Sec's contents were stripped.
isSectionText [virtual]True if section Sec contains executable code.
isSectionVirtual [virtual]True if section Sec's contents are absent from the object image.
mapReflectionSectionNameToEnumValue [virtual]Map a Swift reflection section name to its reflection section kind.
moveRelocationNext [virtual]Advance Rel to the next relocation.
moveSectionNext [virtual]Advance Sec to the next section in this object.
printSymbolName [virtual]Print the name of symbol Symb to OS.
section_rel_begin [virtual]Iterator to the first relocation in section Sec.
section_rel_end [virtual]Past-the-end iterator for relocations in section Sec.

Protected Static Member Functions

NameDescription
getELFType Map ELF endianness and bitness to the matching type ID.
getMachOType Map Mach-O endianness and bitness to the matching type ID.

Protected Data Members

NameDescription
Data Underlying file contents for this binary.

Friends

NameDescription
llvm::object::RelocationRefThis is a value type class that represents a single relocation in the list of relocations in the object file.
llvm::object::SectionRefThis is a value type class that represents a single section in the list of sections in the object file.
llvm::object::SymbolRefThis is a value type class that represents a single symbol in the list of symbols in the object file.

Non-Member Functions

NameDescription
computeSymbolSizesCompute the size of each symbol in O.
extractCodeObjectExtract code object memory from the given Source object file at Offset and of Size, and copy into OutputFileName.
extractOffloadBundleFatBinaryExtracts fat binary in binary clang-offload-bundler format from object Obj and return it in Bundles.
getBuildIDReturns the build ID, if any, contained in the given object file.
getRelocationResolverReturns format-specific support and resolve callbacks for Obj's relocations.
wrapConvert a Binary pointer to an LLVMBinaryRef opaque handle.
::llvm::objcopy::getObjectFormatNameReturns the format name of B if it is an ObjectFile, or "" otherwise.
::llvm::remarks::getRemarksSectionContentsReturns a buffer with the contents of the remarks section depending on the format of the file. If the section doesn't exist, this returns an empty optional.
::llvm::yaml::yaml2ObjectFileConvenience function for tests.

Derived Classes

NameDescription
COFFObjectFile COFF object file.
DXContainerObjectFile DirectX container object file.
ELFObjectFileBase Common base class for ELF object files of any address size or endianness.
GOFFObjectFile ObjectFile implementation for GOFF (Generalized Object File Format) binaries.
MachOObjectFile Mach-O object file.
WasmObjectFile WebAssembly object file.
XCOFFObjectFile ObjectFile implementation for 32- and 64-bit XCOFF binaries.