LLVM 22.0.0git
|
This class is the base class for all object file types. More...
#include "llvm/Object/ObjectFile.h"
Public Types | |
using | symbol_iterator_range = iterator_range< symbol_iterator > |
using | section_iterator_range = iterator_range< section_iterator > |
![]() | |
using | basic_symbol_iterator_range = iterator_range< basic_symbol_iterator > |
Friends | |
class | SymbolRef |
class | SectionRef |
class | RelocationRef |
Additional Inherited Members | |
![]() | |
enum | { ID_Archive , ID_MachOUniversalBinary , ID_COFFImportFile , ID_IR , ID_TapiUniversal , ID_TapiFile , ID_Minidump , ID_WinRes , ID_Offload , ID_StartObjects , ID_COFF , ID_XCOFF32 , ID_XCOFF64 , ID_ELF32L , ID_ELF32B , ID_ELF64L , ID_ELF64B , ID_MachO32L , ID_MachO32B , ID_MachO64L , ID_MachO64B , ID_GOFF , ID_Wasm , ID_DXContainer , ID_EndObjects } |
![]() | |
static unsigned int | getELFType (bool isLE, bool is64Bits) |
static unsigned int | getMachOType (bool isLE, bool is64Bits) |
![]() | |
MemoryBufferRef | Data |
This class is the base class for all object file types.
Concrete instances of this object are created by createObjectFile, which figures out which type to create.
Definition at line 231 of file ObjectFile.h.
Definition at line 330 of file ObjectFile.h.
Definition at line 322 of file ObjectFile.h.
|
protected |
Definition at line 44 of file ObjectFile.cpp.
|
delete |
|
delete |
Definition at line 237 of file ObjectFile.h.
Referenced by llvm::object::COFFObjectFile::getHybridObjectView(), llvm::object::COFFObjectFile::getRelocations(), llvm::object::COFFObjectFile::getRvaAndSizeAsBytes(), llvm::object::COFFObjectFile::getRvaPtr(), llvm::object::COFFObjectFile::getSectionContents(), llvm::object::XCOFFObjectFile::getSectionContents(), llvm::object::XCOFFObjectFile::getSectionFileOffsetToRawData(), llvm::object::COFFObjectFile::getSymbolAuxData(), llvm::object::GOFFObjectFile::GOFFObjectFile(), llvm::object::COFFObjectFile::section_rel_begin(), and llvm::object::COFFObjectFile::section_rel_end().
Definition at line 382 of file ObjectFile.h.
|
static |
Definition at line 1896 of file COFFObjectFile.cpp.
References llvm::object::COFFObjectFile::create().
Referenced by llvm::jitlink::createLinkGraphFromCOFFObject_x86_64(), and createObjectFile().
|
static |
Definition at line 692 of file DXContainer.cpp.
References llvm::object::DXContainer::create().
Referenced by createObjectFile().
|
static |
Definition at line 72 of file ELFObjectFile.cpp.
References llvm::countr_zero(), llvm::object::createError(), llvm::ELF::ELFCLASS32, llvm::ELF::ELFCLASS64, llvm::ELF::ELFDATA2LSB, llvm::ELF::ELFDATA2MSB, llvm::MemoryBufferRef::getBuffer(), llvm::MemoryBufferRef::getBufferStart(), and llvm::object::getElfArchType().
Referenced by llvm::jitlink::createLinkGraphFromELFObject_aarch32(), llvm::jitlink::createLinkGraphFromELFObject_aarch64(), llvm::jitlink::createLinkGraphFromELFObject_loongarch(), llvm::jitlink::createLinkGraphFromELFObject_ppc64(), llvm::jitlink::createLinkGraphFromELFObject_riscv(), llvm::jitlink::createLinkGraphFromELFObject_x86(), llvm::jitlink::createLinkGraphFromELFObject_x86_64(), and createObjectFile().
|
static |
Definition at line 28 of file GOFFObjectFile.cpp.
References llvm::Error::success().
|
static |
Create a MachOObjectFile instance from a given buffer.
Buffer | Memory buffer containing the MachO binary data. |
UniversalCputype | CPU type when the MachO part of a universal binary. |
UniversalIndex | Index of the MachO within a universal binary. |
MachOFilesetEntryOffset | Offset of the MachO entry in a fileset MachO. |
Definition at line 5320 of file MachOObjectFile.cpp.
References llvm::object::MachOObjectFile::create(), llvm::MemoryBufferRef::getBuffer(), llvm::object::invalid_file_type, and llvm::StringRef::slice().
Referenced by llvm::jitlink::createLinkGraphFromMachOObject_arm64(), llvm::jitlink::createLinkGraphFromMachOObject_x86_64(), createObjectFile(), and llvm::object::MachOUniversalBinary::ObjectForArch::getAsObjectFile().
|
inlinestatic |
Definition at line 378 of file ObjectFile.h.
References llvm::file_magic::unknown.
|
static |
Definition at line 150 of file ObjectFile.cpp.
References llvm::file_magic::archive, llvm::file_magic::bitcode, llvm::file_magic::clang_ast, llvm::file_magic::coff_cl_gl_object, llvm::file_magic::coff_import_library, llvm::file_magic::coff_object, createCOFFObjectFile(), createDXContainerObjectFile(), createELFObjectFile(), createMachOObjectFile(), createWasmObjectFile(), createXCOFFObjectFile(), llvm::file_magic::cuda_fatbinary, llvm::object::Binary::Data, llvm::file_magic::dxcontainer_object, llvm::file_magic::elf, llvm::file_magic::elf_core, llvm::file_magic::elf_executable, llvm::file_magic::elf_relocatable, llvm::file_magic::elf_shared_object, llvm::errorCodeToError(), llvm::file_magic::goff_object, llvm::object::Binary::ID_XCOFF32, llvm::object::Binary::ID_XCOFF64, llvm::identify_magic(), llvm::object::invalid_file_type, llvm_unreachable, llvm::file_magic::macho_bundle, llvm::file_magic::macho_core, llvm::file_magic::macho_dsym_companion, llvm::file_magic::macho_dynamic_linker, llvm::file_magic::macho_dynamically_linked_shared_lib, llvm::file_magic::macho_dynamically_linked_shared_lib_stub, llvm::file_magic::macho_executable, llvm::file_magic::macho_file_set, llvm::file_magic::macho_fixed_virtual_memory_shared_lib, llvm::file_magic::macho_kext_bundle, llvm::file_magic::macho_object, llvm::file_magic::macho_preload_executable, llvm::file_magic::macho_universal_binary, llvm::file_magic::minidump, llvm::file_magic::offload_binary, llvm::file_magic::offload_bundle, llvm::file_magic::offload_bundle_compressed, llvm::file_magic::pdb, llvm::file_magic::pecoff_executable, llvm::file_magic::spirv_object, llvm::file_magic::tapi_file, llvm::file_magic::unknown, llvm::file_magic::wasm_object, llvm::file_magic::windows_resource, llvm::file_magic::xcoff_object_32, and llvm::file_magic::xcoff_object_64.
|
static |
ObjectPath | The path to the object file. ObjectPath.isObject must return true. Create ObjectFile from path. |
Definition at line 211 of file ObjectFile.cpp.
References createObjectFile(), llvm::errorCodeToError(), llvm::Expected< T >::get(), llvm::ErrorOr< T >::get(), llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFile(), and llvm::Expected< T >::takeError().
Referenced by llvm::jitlink::createLinkGraphFromXCOFFObject_ppc64(), createObjectFile(), llvm::object::SymbolicFile::createSymbolicFile(), llvm::NewArchiveMember::detectKindFromObject(), llvm::orc::RTDyldObjectLinkingLayer::emit(), llvm::object::extractOffloadBinaries(), llvm::object::extractOffloadBundleByURI(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::MCJIT::generateCodeForModule(), llvm::orc::getObjectFileInterface(), LLVMCreateObjectFile(), llvm::xray::loadInstrumentationMap(), llvm::cgdata::mergeCodeGenData(), llvm::orc::SimpleCompiler::operator()(), llvm::orc::ForceLoadMachOArchiveMembers::operator()(), llvm::dwarf_linker::parallel::SectionDescriptor::setSizesForSectionCreatedByAsmPrinter(), llvm::write(), and llvm::yaml::yaml2ObjectFile().
|
static |
Definition at line 66 of file WasmObjectFile.cpp.
References llvm::Error::success().
Referenced by createObjectFile().
|
static |
Definition at line 1236 of file XCOFFObjectFile.cpp.
Referenced by createObjectFile().
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 318 of file ObjectFile.h.
|
pure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::DXContainerObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::symbolize::SymbolizableObjectFile::create(), llvm::object::getRelocationResolver(), llvm::RuntimeDyld::loadObject(), llvm::RuntimeDyldImpl::loadObjectImpl(), and makeTriple().
|
pure virtual |
The number of bytes used to represent an address in this object file format.
Implemented in llvm::object::COFFObjectFile, llvm::object::DXContainerObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::symbolize::SymbolizableObjectFile::create(), llvm::object::getRelocationResolver(), and llvm::BTFParser::ParseContext::makeExtractor().
|
inline |
Definition at line 309 of file ObjectFile.h.
References assert(), llvm::report_fatal_error(), and llvm::Expected< T >::takeError().
Referenced by llvm::object::SymbolRef::getCommonSize(), and getSymbolValue().
|
protectedpure virtual |
|
pure virtual |
|
pure virtual |
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 343 of file ObjectFile.h.
Referenced by makeTriple().
|
protectedvirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 106 of file ObjectFile.cpp.
References SectionRef.
Referenced by llvm::object::SectionRef::getRelocatedSection().
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
Reimplemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, and llvm::object::XCOFFObjectFile.
Definition at line 349 of file ObjectFile.h.
References llvm::errorCodeToError().
|
protectedpure virtual |
|
protectedvirtual |
Reimplemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Definition at line 78 of file ObjectFile.cpp.
Referenced by llvm::object::SymbolRef::getAlignment().
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protected |
Definition at line 57 of file ObjectFile.cpp.
References getCommonSymbolSize(), llvm::object::SymbolicFile::getSymbolFlags(), getSymbolValueImpl(), llvm::Ref, llvm::object::BasicSymbolRef::SF_Common, and llvm::object::BasicSymbolRef::SF_Undefined.
Referenced by llvm::object::COFFObjectFile::getSymbolAddress(), llvm::object::MachOObjectFile::getSymbolAddress(), llvm::object::WasmObjectFile::getSymbolAddress(), and llvm::object::SymbolRef::getValue().
|
protectedpure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::DXContainerObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by getSymbolValue().
|
virtual |
Definition at line 100 of file ObjectFile.cpp.
References llvm::any_of(), llvm::object::SectionRef::isDebugSection(), and sections().
Referenced by llvm::symbolize::useBTFContext().
|
protectedvirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 94 of file ObjectFile.cpp.
References isSectionData().
Referenced by llvm::object::SectionRef::isBerkeleyData().
|
protectedvirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 90 of file ObjectFile.cpp.
References isSectionText().
Referenced by llvm::object::SectionRef::isBerkeleyText().
|
protectedvirtual |
Reimplemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::MachOObjectFile, and llvm::object::XCOFFObjectFile.
Definition at line 98 of file ObjectFile.cpp.
Referenced by llvm::object::SectionRef::isDebugSection().
bool ObjectFile::isReflectionSectionStrippable | ( | llvm::binaryformat::Swift5ReflectionSectionKind | ReflectionSectionKind | ) | const |
True if the reflection section can be stripped by the linker.
Definition at line 227 of file ObjectFile.cpp.
|
pure virtual |
True if this is a relocatable object (.o/.obj).
Implemented in llvm::object::COFFObjectFile, llvm::object::DXContainerObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by shouldSkipSectionFirstByte().
|
protectedvirtual |
Reimplemented in llvm::object::MachOObjectFile.
Definition at line 80 of file ObjectFile.cpp.
References llvm::consumeError(), getSectionName(), and llvm::Expected< T >::takeError().
Referenced by llvm::object::SectionRef::isBitcode().
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedvirtual |
Reimplemented in llvm::object::MachOObjectFile.
Definition at line 88 of file ObjectFile.cpp.
Referenced by llvm::object::SectionRef::isStripped().
|
protectedpure virtual |
|
protectedpure virtual |
Triple ObjectFile::makeTriple | ( | ) | const |
Create a triple from the data in this object file.
Definition at line 110 of file ObjectFile.cpp.
References llvm::Triple::AIX, llvm::Triple::AMD, llvm::Triple::arm, llvm::Triple::armeb, getArch(), getOS(), llvm::Triple::GOFF, llvm::Triple::isAMDGPU(), llvm::object::Binary::isCOFF(), llvm::object::Binary::isGOFF(), llvm::object::Binary::isMachO(), llvm::Triple::isNVPTX(), llvm::object::Binary::isXCOFF(), llvm::Triple::MachO, llvm::Triple::NVIDIA, OS, llvm::Triple::setArch(), setARMSubArch(), llvm::Triple::setObjectFormat(), llvm::Triple::setOS(), llvm::Triple::setTriple(), llvm::Triple::setVendor(), llvm::Triple::thumb, llvm::Triple::UnknownOS, llvm::Triple::XCOFF, and llvm::Triple::ZOS.
Referenced by llvm::object::ELFObjectFileBase::getPltEntries(), getUUID(), llvm::CodeGenDataReader::mergeFromObjectFile(), and llvm::symbolize::useBTFContext().
|
inlinevirtual |
Maps a debug section name to a standard DWARF section name.
Reimplemented in llvm::object::COFFObjectFile, llvm::object::MachOObjectFile, and llvm::object::XCOFFObjectFile.
Definition at line 357 of file ObjectFile.h.
References Name.
|
inlineprotectedvirtual |
Reimplemented in llvm::object::MachOObjectFile.
Definition at line 298 of file ObjectFile.h.
References llvm::binaryformat::unknown.
|
protectedpure virtual |
|
protectedpure virtual |
|
delete |
|
overrideprotectedvirtual |
Implements llvm::object::SymbolicFile.
Definition at line 70 of file ObjectFile.cpp.
References getSymbolName(), Name, OS, and llvm::Error::success().
|
pure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::DXContainerObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::object::SectionFilter::begin(), llvm::RuntimeDyldImpl::computeGOTSize(), llvm::RuntimeDyldImpl::computeSectionStubBufSize(), llvm::RuntimeDyldImpl::computeTotalAllocSize(), llvm::RuntimeDyldELF::finalizeLoad(), and llvm::RuntimeDyldImpl::loadObjectImpl().
|
pure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::DXContainerObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::object::SectionFilter::begin(), llvm::RuntimeDyldImpl::computeGOTSize(), llvm::RuntimeDyldImpl::computeSectionStubBufSize(), llvm::RuntimeDyldImpl::computeTotalAllocSize(), llvm::object::SectionFilter::end(), llvm::RuntimeDyldELF::finalizeLoad(), getSymbolInfo(), llvm::RuntimeDyldImpl::loadObjectImpl(), llvm::RuntimeDyldCOFFAArch64::processRelocationRef(), llvm::RuntimeDyldCOFFI386::processRelocationRef(), llvm::RuntimeDyldCOFFThumb::processRelocationRef(), llvm::RuntimeDyldCOFFX86_64::processRelocationRef(), and llvm::RuntimeDyldELF::processRelocationRef().
|
protectedpure virtual |
|
protectedpure virtual |
|
inline |
Definition at line 331 of file ObjectFile.h.
Referenced by llvm::object::BindRebaseSegInfo::BindRebaseSegInfo(), llvm::objcopy::dxbc::DXContainerReader::create(), llvm::objcopy::wasm::Reader::create(), llvm::symbolize::SymbolizableObjectFile::create(), llvm::object::extractOffloadBundleFatBinary(), llvm::RuntimeDyldMachOCRTPBase< Impl >::finalizeLoad(), llvm::object::IRObjectFile::findBitcodeInObject(), llvm::orc::getCOFFObjectFileSymbolInfo(), llvm::object::ResourceSectionRef::getContents(), llvm::orc::getELFObjectFileSymbolInfo(), getInstrProfSection(), llvm::orc::getMachOObjectFileSymbolInfo(), llvm::object::ELFObjectFileBase::getPltEntries(), llvm::remarks::getRemarksSectionContents(), llvm::object::COFFObjectFile::getRvaAndSizeAsBytes(), llvm::object::COFFObjectFile::getRvaPtr(), llvm::object::MachOObjectFile::getSection(), getUUID(), llvm::BTFParser::hasBTFSections(), hasDebugInfo(), llvm::logicalview::LVBinaryReader::mapVirtualAddress(), llvm::CodeGenDataReader::mergeFromObjectFile(), llvm::BTFParser::parse(), readMachOHeader(), and llvm::jitlink::COFFLinkGraphBuilder::sections().
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFileBase.
Definition at line 348 of file ObjectFile.h.
Referenced by makeTriple().
|
inline |
Definition at line 323 of file ObjectFile.h.
Referenced by accumulateLocs(), llvm::object::MachOObjectFile::checkSymbolTable(), llvm::gsym::ObjectFileTransformer::convert(), llvm::orc::getCOFFObjectFileSymbolInfo(), llvm::orc::getGenericObjectFileSymbolInfo(), llvm::orc::getMachOObjectFileSymbolInfo(), llvm::orc::getXCOFFObjectFileSymbolInfo(), llvm::RuntimeDyldImpl::loadObjectImpl(), and readSymbols().
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFileBase, and llvm::object::XCOFFObjectFile.
Definition at line 345 of file ObjectFile.h.
|
friend |
Definition at line 289 of file ObjectFile.h.
Referenced by llvm::object::MachOObjectFile::extrel_begin(), llvm::object::MachOObjectFile::extrel_end(), llvm::object::XCOFFRelocation< llvm::support::ubig32_t >::getRelocatedLength(), llvm::object::MachOObjectFile::locrel_begin(), llvm::object::MachOObjectFile::locrel_end(), llvm::object::COFFObjectFile::section_rel_begin(), llvm::object::MachOObjectFile::section_rel_begin(), llvm::object::WasmObjectFile::section_rel_begin(), llvm::object::COFFObjectFile::section_rel_end(), llvm::object::MachOObjectFile::section_rel_end(), llvm::object::WasmObjectFile::section_rel_end(), and llvm::object::XCOFFObjectFile::section_rel_end().
|
friend |
Definition at line 263 of file ObjectFile.h.
Referenced by llvm::object::MachOObjectFile::getAnyRelocationSection(), getRelocatedSection(), llvm::object::MachOObjectFile::getRelocationRelocatedSection(), llvm::object::MachOObjectFile::getSection(), llvm::object::COFFObjectFile::getSymbolSection(), llvm::object::MachOObjectFile::getSymbolSection(), llvm::object::WasmObjectFile::getSymbolSection(), llvm::object::XCOFFObjectFile::getSymbolSection(), llvm::object::COFFObjectFile::section_begin(), llvm::object::GOFFObjectFile::section_begin(), llvm::object::MachOObjectFile::section_begin(), llvm::object::WasmObjectFile::section_begin(), llvm::object::XCOFFObjectFile::section_begin(), llvm::object::COFFObjectFile::section_end(), llvm::object::GOFFObjectFile::section_end(), llvm::object::MachOObjectFile::section_end(), llvm::object::WasmObjectFile::section_end(), and llvm::object::XCOFFObjectFile::section_end().
|
friend |
Definition at line 249 of file ObjectFile.h.
Referenced by llvm::object::COFFObjectFile::getRelocationSymbol(), llvm::object::MachOObjectFile::getRelocationSymbol(), llvm::object::WasmObjectFile::getRelocationSymbol(), llvm::object::XCOFFObjectFile::getRelocationSymbol(), llvm::object::MachOObjectFile::getSymbolByIndex(), llvm::object::COFFObjectFile::symbol_begin(), llvm::object::GOFFObjectFile::symbol_begin(), llvm::object::MachOObjectFile::symbol_begin(), llvm::object::XCOFFObjectFile::symbol_begin(), llvm::object::COFFObjectFile::symbol_end(), llvm::object::GOFFObjectFile::symbol_end(), llvm::object::MachOObjectFile::symbol_end(), and llvm::object::XCOFFObjectFile::symbol_end().