29#include <system_error>
32using namespace object;
37 OS <<
", " <<
Addr.SectionIndex;
41void ObjectFile::anchor() {}
53 return *
this == **SymSec;
72 return Name.takeError();
82 return *NameOrErr ==
".llvm.lto";
129 const auto COFFObj = cast<COFFObjectFile>(
this);
141 }
else if (TheTriple.
isNVPTX()) {
212 if (std::error_code EC = FileOrErr.
getError())
214 std::unique_ptr<MemoryBuffer> Buffer = std::move(FileOrErr.
get());
219 return std::move(Err);
220 std::unique_ptr<ObjectFile> Obj = std::move(ObjOrErr.
get());
229 return ReflectionSectionKind == Swift5ReflectionSectionKind::fieldmd ||
230 ReflectionSectionKind == Swift5ReflectionSectionKind::reflstr ||
231 ReflectionSectionKind == Swift5ReflectionSectionKind::assocty;
Provides ErrorOr<T> smart pointer.
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
void setObjectFormat(ObjectFormatType Kind)
Set the object file format.
void setTriple(const Twine &Str)
Set all components to the new triple Str.
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
void setOS(OSType Kind)
Set the operating system (third) component of the triple to a known type.
void setArch(ArchType Kind, SubArchType SubArch=NoSubArch)
Set the architecture (first) component of the triple to a known type.
void setVendor(VendorType Kind)
Set the vendor (second) component of the triple to a known type.
The instances of the Type class are immutable: once they are created, they are never changed.
virtual bool isBerkeleyText(DataRefImpl Sec) const
virtual Expected< section_iterator > getRelocatedSection(DataRefImpl Sec) const
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
virtual Expected< StringRef > getSectionName(DataRefImpl Sec) const =0
virtual bool isBerkeleyData(DataRefImpl Sec) const
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
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)
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
Triple makeTriple() const
Create a triple from the data in this object file.
virtual bool isSectionText(DataRefImpl Sec) const =0
section_iterator_range sections() const
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const =0
virtual bool isDebugSection(DataRefImpl Sec) const
virtual void setARMSubArch(Triple &TheTriple) const
static Expected< std::unique_ptr< WasmObjectFile > > createWasmObjectFile(MemoryBufferRef Object)
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
virtual bool isSectionData(DataRefImpl Sec) const =0
Expected< uint64_t > getSymbolValue(DataRefImpl Symb) const
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 > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
virtual Triple::ArchType getArch() const =0
virtual bool isSectionStripped(DataRefImpl Sec) const
virtual bool isSectionBitcode(DataRefImpl Sec) const
This is a value type class that represents a single section in the list of sections in the object fil...
bool isDebugSection() const
Whether this section is a debug section.
bool containsSymbol(SymbolRef S) const
This is a value type class that represents a single symbol in the list of symbols in the object file.
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
virtual Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const =0
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
content_iterator< SectionRef > section_iterator
raw_ostream & operator<<(raw_ostream &OS, const SectionedAddress &Addr)
This is an optimization pass for GlobalISel generic memory operations.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
@ Ref
The access may reference the value stored in memory.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
@ coff_import_library
COFF import library.
@ pdb
Windows PDB debug info file.
@ spirv_object
A binary SPIR-V file.
@ elf_relocatable
ELF Relocatable object file.
@ archive
ar style archive file
@ elf_shared_object
ELF dynamically linked shared lib.
@ goff_object
GOFF object file.
@ minidump
Windows minidump file.
@ macho_dynamically_linked_shared_lib
Mach-O dynlinked shared lib.
@ xcoff_object_64
64-bit XCOFF object file
@ elf_executable
ELF Executable image.
@ macho_dynamically_linked_shared_lib_stub
Mach-O Shared lib stub.
@ macho_preload_executable
Mach-O Preloaded Executable.
@ offload_bundle
Clang offload bundle file.
@ offload_bundle_compressed
Compressed clang offload bundle file.
@ macho_file_set
Mach-O file set binary.
@ dxcontainer_object
DirectX container file.
@ macho_kext_bundle
Mach-O kext bundle file.
@ pecoff_executable
PECOFF executable file.
@ offload_binary
LLVM offload object file.
@ macho_universal_binary
Mach-O universal binary.
@ macho_core
Mach-O Core File.
@ wasm_object
WebAssembly Object file.
@ xcoff_object_32
32-bit XCOFF object file
@ windows_resource
Windows compiled resource file (.res)
@ clang_ast
Clang PCH or PCM.
@ elf_core
ELF core image.
@ macho_object
Mach-O Object file.
@ coff_object
COFF object file.
@ macho_bundle
Mach-O Bundle file.
@ coff_cl_gl_object
Microsoft cl.exe's intermediate code file.
@ cuda_fatbinary
CUDA Fatbinary object file.
@ macho_executable
Mach-O Executable.
@ macho_dsym_companion
Mach-O dSYM companion file.
@ unknown
Unrecognized file.
@ macho_fixed_virtual_memory_shared_lib
Mach-O Shared Lib, FVM.
@ macho_dynamic_linker
The Mach-O dynamic linker.
@ tapi_file
Text-based Dynamic Library Stub file.
static const uint64_t UndefSection