LLVM 20.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 > |
Public Types inherited from llvm::object::SymbolicFile | |
using | basic_symbol_iterator_range = iterator_range< basic_symbol_iterator > |
Friends | |
class | SymbolRef |
class | SectionRef |
class | RelocationRef |
Additional Inherited Members | |
Protected Types inherited from llvm::object::Binary | |
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_EndObjects } |
Static Protected Member Functions inherited from llvm::object::Binary | |
static unsigned int | getELFType (bool isLE, bool is64Bits) |
static unsigned int | getMachOType (bool isLE, bool is64Bits) |
Protected Attributes inherited from llvm::object::Binary | |
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 229 of file ObjectFile.h.
Definition at line 328 of file ObjectFile.h.
Definition at line 320 of file ObjectFile.h.
|
protected |
Definition at line 43 of file ObjectFile.cpp.
|
delete |
|
delete |
|
inlineprotected |
Definition at line 235 of file ObjectFile.h.
References llvm::object::Binary::Data, and llvm::MemoryBufferRef::getBufferStart().
Referenced by llvm::object::COFFObjectFile::getDOSHeader(), 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 380 of file ObjectFile.h.
|
static |
Definition at line 1873 of file COFFObjectFile.cpp.
References llvm::object::COFFObjectFile::create().
Referenced by llvm::jitlink::createLinkGraphFromCOFFObject_x86_64(), and createObjectFile().
|
static |
Definition at line 73 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_i386(), llvm::jitlink::createLinkGraphFromELFObject_loongarch(), llvm::jitlink::createLinkGraphFromELFObject_ppc64(), llvm::jitlink::createLinkGraphFromELFObject_riscv(), 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 5321 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 376 of file ObjectFile.h.
References createObjectFile(), and llvm::file_magic::unknown.
|
static |
Definition at line 149 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(), 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 209 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 createObjectFile(), llvm::object::SymbolicFile::createSymbolicFile(), llvm::NewArchiveMember::detectKindFromObject(), llvm::orc::RTDyldObjectLinkingLayer::emit(), llvm::object::extractOffloadBinaries(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::MCJIT::generateCodeForModule(), llvm::orc::getObjectFileInterface(), LLVMCreateObjectFile(), llvm::xray::loadInstrumentationMap(), llvm::orc::SimpleCompiler::operator()(), llvm::dwarf_linker::parallel::SectionDescriptor::setSizesForSectionCreatedByAsmPrinter(), llvm::write(), and llvm::yaml::yaml2ObjectFile().
|
static |
Definition at line 69 of file WasmObjectFile.cpp.
References llvm::Error::success().
Referenced by createObjectFile().
|
static |
Definition at line 1231 of file XCOFFObjectFile.cpp.
Referenced by createObjectFile().
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 316 of file ObjectFile.h.
|
pure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::symbolize::SymbolizableObjectFile::create(), llvm::DWARFContext::getArch(), 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::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 307 of file ObjectFile.h.
References assert(), getCommonSymbolSizeImpl(), llvm::object::SymbolicFile::getSymbolFlags(), llvm::report_fatal_error(), llvm::object::BasicSymbolRef::SF_Common, and llvm::Expected< T >::takeError().
Referenced by llvm::object::SymbolRef::getCommonSize(), and getSymbolValue().
|
protectedpure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by getCommonSymbolSize().
|
pure virtual |
|
pure virtual |
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 341 of file ObjectFile.h.
References llvm::Triple::UnknownOS.
Referenced by makeTriple().
|
protectedvirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 105 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 347 of file ObjectFile.h.
References llvm::errorCodeToError(), and llvm::object::parse_failed.
|
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 77 of file ObjectFile.cpp.
Referenced by llvm::object::SymbolRef::getAlignment().
|
protectedpure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::object::SymbolRef::getName(), and printSymbolName().
|
protectedpure virtual |
|
protectedpure virtual |
|
protected |
Definition at line 56 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::ELFObjectFile< ELFT >, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by getSymbolValue().
|
virtual |
Definition at line 99 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 93 of file ObjectFile.cpp.
References isSectionData().
Referenced by llvm::object::SectionRef::isBerkeleyData().
|
protectedvirtual |
Reimplemented in llvm::object::ELFObjectFile< ELFT >.
Definition at line 89 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 97 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 225 of file ObjectFile.cpp.
|
pure virtual |
True if this is a relocatable object (.o/.obj).
Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::GOFFObjectFile, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by llvm::InstrProfSymtab::create().
|
protectedvirtual |
Reimplemented in llvm::object::MachOObjectFile.
Definition at line 79 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 |
Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by isBerkeleyData(), and llvm::object::SectionRef::isData().
|
protectedvirtual |
Reimplemented in llvm::object::MachOObjectFile.
Definition at line 87 of file ObjectFile.cpp.
Referenced by llvm::object::SectionRef::isStripped().
|
protectedpure virtual |
Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, llvm::object::MachOObjectFile, llvm::object::WasmObjectFile, and llvm::object::XCOFFObjectFile.
Referenced by isBerkeleyText(), and llvm::object::SectionRef::isText().
|
protectedpure virtual |
Triple ObjectFile::makeTriple | ( | ) | const |
Create a triple from the data in this object file.
Definition at line 109 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 355 of file ObjectFile.h.
References Name.
|
inlineprotectedvirtual |
Reimplemented in llvm::object::MachOObjectFile.
Definition at line 296 of file ObjectFile.h.
References llvm::binaryformat::unknown.
|
protectedpure virtual |
|
protectedpure virtual |
|
delete |
|
overrideprotectedvirtual |
Implements llvm::object::SymbolicFile.
Definition at line 69 of file ObjectFile.cpp.
References getSymbolName(), Name, OS, and llvm::Error::success().
|
pure virtual |
Implemented in llvm::object::COFFObjectFile, 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(), llvm::RuntimeDyldImpl::loadObjectImpl(), and sections().
|
pure virtual |
Implemented in llvm::object::COFFObjectFile, 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(), llvm::RuntimeDyldELF::processRelocationRef(), and sections().
|
protectedpure virtual |
|
protectedpure virtual |
|
inline |
Definition at line 329 of file ObjectFile.h.
References section_begin(), and section_end().
Referenced by llvm::object::BindRebaseSegInfo::BindRebaseSegInfo(), llvm::objcopy::wasm::Reader::create(), llvm::symbolize::SymbolizableObjectFile::create(), 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(), lookupSections(), 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 346 of file ObjectFile.h.
Referenced by makeTriple().
|
inline |
Definition at line 321 of file ObjectFile.h.
References llvm::object::SymbolicFile::symbol_begin(), and llvm::object::SymbolicFile::symbol_end().
Referenced by accumulateLocs(), llvm::object::MachOObjectFile::checkSymbolTable(), llvm::gsym::ObjectFileTransformer::convert(), llvm::orc::getCOFFObjectFileSymbolInfo(), llvm::orc::getGenericObjectFileSymbolInfo(), llvm::orc::getMachOObjectFileSymbolInfo(), llvm::RuntimeDyldImpl::loadObjectImpl(), and readSymbols().
|
inlinevirtual |
Reimplemented in llvm::object::ELFObjectFileBase, and llvm::object::XCOFFObjectFile.
Definition at line 343 of file ObjectFile.h.
|
friend |
Definition at line 287 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 261 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 247 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().