LLVM 22.0.0git
Typedefs | Enumerations | Functions
Object file reading and writing
Collaboration diagram for Object file reading and writing:

Typedefs

typedef struct LLVMOpaqueSectionIterator * LLVMSectionIteratorRef
 
typedef struct LLVMOpaqueSymbolIterator * LLVMSymbolIteratorRef
 
typedef struct LLVMOpaqueRelocationIterator * LLVMRelocationIteratorRef
 
typedef struct LLVMOpaqueObjectFile * LLVMObjectFileRef
 Deprecated: Use LLVMBinaryRef instead.
 

Enumerations

enum  LLVMBinaryType {
  LLVMBinaryTypeArchive , LLVMBinaryTypeMachOUniversalBinary , LLVMBinaryTypeCOFFImportFile , LLVMBinaryTypeIR ,
  LLVMBinaryTypeWinRes , LLVMBinaryTypeCOFF , LLVMBinaryTypeELF32L , LLVMBinaryTypeELF32B ,
  LLVMBinaryTypeELF64L , LLVMBinaryTypeELF64B , LLVMBinaryTypeMachO32L , LLVMBinaryTypeMachO32B ,
  LLVMBinaryTypeMachO64L , LLVMBinaryTypeMachO64B , LLVMBinaryTypeWasm , LLVMBinaryTypeOffload ,
  LLVMBinaryTypeDXcontainer
}
 

Functions

LLVM_C_ABI LLVMBinaryRef LLVMCreateBinary (LLVMMemoryBufferRef MemBuf, LLVMContextRef Context, char **ErrorMessage)
 Create a binary file from the given memory buffer.
 
LLVM_C_ABI void LLVMDisposeBinary (LLVMBinaryRef BR)
 Dispose of a binary file.
 
LLVM_C_ABI LLVMMemoryBufferRef LLVMBinaryCopyMemoryBuffer (LLVMBinaryRef BR)
 Retrieves a copy of the memory buffer associated with this object file.
 
LLVM_C_ABI LLVMBinaryType LLVMBinaryGetType (LLVMBinaryRef BR)
 Retrieve the specific type of a binary.
 
LLVM_C_ABI LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch (LLVMBinaryRef BR, const char *Arch, size_t ArchLen, char **ErrorMessage)
 
LLVM_C_ABI LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator (LLVMBinaryRef BR)
 Retrieve a copy of the section iterator for this object file.
 
LLVM_C_ABI LLVMBool LLVMObjectFileIsSectionIteratorAtEnd (LLVMBinaryRef BR, LLVMSectionIteratorRef SI)
 Returns whether the given section iterator is at the end.
 
LLVM_C_ABI LLVMSymbolIteratorRef LLVMObjectFileCopySymbolIterator (LLVMBinaryRef BR)
 Retrieve a copy of the symbol iterator for this object file.
 
LLVM_C_ABI LLVMBool LLVMObjectFileIsSymbolIteratorAtEnd (LLVMBinaryRef BR, LLVMSymbolIteratorRef SI)
 Returns whether the given symbol iterator is at the end.
 
LLVM_C_ABI void LLVMDisposeSectionIterator (LLVMSectionIteratorRef SI)
 
LLVM_C_ABI void LLVMMoveToNextSection (LLVMSectionIteratorRef SI)
 
LLVM_C_ABI void LLVMMoveToContainingSection (LLVMSectionIteratorRef Sect, LLVMSymbolIteratorRef Sym)
 
LLVM_C_ABI void LLVMDisposeSymbolIterator (LLVMSymbolIteratorRef SI)
 
LLVM_C_ABI void LLVMMoveToNextSymbol (LLVMSymbolIteratorRef SI)
 
LLVM_C_ABI const charLLVMGetSectionName (LLVMSectionIteratorRef SI)
 
LLVM_C_ABI uint64_t LLVMGetSectionSize (LLVMSectionIteratorRef SI)
 
LLVM_C_ABI const charLLVMGetSectionContents (LLVMSectionIteratorRef SI)
 
LLVM_C_ABI uint64_t LLVMGetSectionAddress (LLVMSectionIteratorRef SI)
 
LLVM_C_ABI LLVMBool LLVMGetSectionContainsSymbol (LLVMSectionIteratorRef SI, LLVMSymbolIteratorRef Sym)
 
LLVM_C_ABI LLVMRelocationIteratorRef LLVMGetRelocations (LLVMSectionIteratorRef Section)
 
LLVM_C_ABI void LLVMDisposeRelocationIterator (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI LLVMBool LLVMIsRelocationIteratorAtEnd (LLVMSectionIteratorRef Section, LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI void LLVMMoveToNextRelocation (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI const charLLVMGetSymbolName (LLVMSymbolIteratorRef SI)
 
LLVM_C_ABI uint64_t LLVMGetSymbolAddress (LLVMSymbolIteratorRef SI)
 
LLVM_C_ABI uint64_t LLVMGetSymbolSize (LLVMSymbolIteratorRef SI)
 
LLVM_C_ABI uint64_t LLVMGetRelocationOffset (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI LLVMSymbolIteratorRef LLVMGetRelocationSymbol (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI uint64_t LLVMGetRelocationType (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI const charLLVMGetRelocationTypeName (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI const charLLVMGetRelocationValueString (LLVMRelocationIteratorRef RI)
 
LLVM_C_ABI LLVMObjectFileRef LLVMCreateObjectFile (LLVMMemoryBufferRef MemBuf)
 Deprecated: Use LLVMCreateBinary instead.
 
LLVM_C_ABI void LLVMDisposeObjectFile (LLVMObjectFileRef ObjectFile)
 Deprecated: Use LLVMDisposeBinary instead.
 
LLVM_C_ABI LLVMSectionIteratorRef LLVMGetSections (LLVMObjectFileRef ObjectFile)
 Deprecated: Use LLVMObjectFileCopySectionIterator instead.
 
LLVM_C_ABI LLVMBool LLVMIsSectionIteratorAtEnd (LLVMObjectFileRef ObjectFile, LLVMSectionIteratorRef SI)
 Deprecated: Use LLVMObjectFileIsSectionIteratorAtEnd instead.
 
LLVM_C_ABI LLVMSymbolIteratorRef LLVMGetSymbols (LLVMObjectFileRef ObjectFile)
 Deprecated: Use LLVMObjectFileCopySymbolIterator instead.
 
LLVM_C_ABI LLVMBool LLVMIsSymbolIteratorAtEnd (LLVMObjectFileRef ObjectFile, LLVMSymbolIteratorRef SI)
 Deprecated: Use LLVMObjectFileIsSymbolIteratorAtEnd instead.
 

Detailed Description

Typedef Documentation

◆ LLVMObjectFileRef

typedef struct LLVMOpaqueObjectFile* LLVMObjectFileRef

Deprecated: Use LLVMBinaryRef instead.

Definition at line 209 of file Object.h.

◆ LLVMRelocationIteratorRef

typedef struct LLVMOpaqueRelocationIterator* LLVMRelocationIteratorRef

Definition at line 39 of file Object.h.

◆ LLVMSectionIteratorRef

typedef struct LLVMOpaqueSectionIterator* LLVMSectionIteratorRef

Definition at line 37 of file Object.h.

◆ LLVMSymbolIteratorRef

typedef struct LLVMOpaqueSymbolIterator* LLVMSymbolIteratorRef

Definition at line 38 of file Object.h.

Enumeration Type Documentation

◆ LLVMBinaryType

Enumerator
LLVMBinaryTypeArchive 

Archive file.

LLVMBinaryTypeMachOUniversalBinary 

Mach-O Universal Binary file.

LLVMBinaryTypeCOFFImportFile 

COFF Import file.

LLVMBinaryTypeIR 

LLVM IR.

LLVMBinaryTypeWinRes 

Windows resource (.res) file.

LLVMBinaryTypeCOFF 

COFF Object file.

LLVMBinaryTypeELF32L 

ELF 32-bit, little endian.

LLVMBinaryTypeELF32B 

ELF 32-bit, big endian.

LLVMBinaryTypeELF64L 

ELF 64-bit, little endian.

LLVMBinaryTypeELF64B 

ELF 64-bit, big endian.

LLVMBinaryTypeMachO32L 

MachO 32-bit, little endian.

LLVMBinaryTypeMachO32B 

MachO 32-bit, big endian.

LLVMBinaryTypeMachO64L 

MachO 64-bit, little endian.

LLVMBinaryTypeMachO64B 

MachO 64-bit, big endian.

LLVMBinaryTypeWasm 

Web Assembly.

LLVMBinaryTypeOffload 

Offloading fatbinary.

LLVMBinaryTypeDXcontainer 

DirectX Binary Container.

Definition at line 41 of file Object.h.

Function Documentation

◆ LLVMBinaryCopyMemoryBuffer()

LLVM_C_ABI LLVMMemoryBufferRef LLVMBinaryCopyMemoryBuffer ( LLVMBinaryRef  BR)

Retrieves a copy of the memory buffer associated with this object file.

The returned buffer is merely a shallow copy and does not own the actual backing buffer of the binary. Nevertheless, it is the responsibility of the caller to free it with LLVMDisposeMemoryBuffer.

See also
llvm::object::getMemoryBufferRef

Definition at line 79 of file Object.cpp.

References llvm::MemoryBuffer::getMemBuffer(), unwrap(), and wrap().

◆ LLVMBinaryGetType()

LLVM_C_ABI LLVMBinaryType LLVMBinaryGetType ( LLVMBinaryRef  BR)

◆ LLVMCreateBinary()

LLVM_C_ABI LLVMBinaryRef LLVMCreateBinary ( LLVMMemoryBufferRef  MemBuf,
LLVMContextRef  Context,
char **  ErrorMessage 
)

Create a binary file from the given memory buffer.

The exact type of the binary file will be inferred automatically, and the appropriate implementation selected. The context may be NULL except if the resulting file is an LLVM IR file.

The memory buffer is not consumed by this function. It is the responsibilty of the caller to free it with LLVMDisposeMemoryBuffer.

If NULL is returned, the ErrorMessage parameter is populated with the error's description. It is then the caller's responsibility to free this message by calling LLVMDisposeMessage.

See also
llvm::object::createBinary

Definition at line 65 of file Object.cpp.

References Context, llvm::object::createBinary(), llvm::Expected< T >::get(), llvm::Expected< T >::takeError(), llvm::toString(), unwrap(), and wrap().

◆ LLVMCreateObjectFile()

LLVM_C_ABI LLVMObjectFileRef LLVMCreateObjectFile ( LLVMMemoryBufferRef  MemBuf)

Deprecated: Use LLVMCreateBinary instead.

Definition at line 183 of file Object.cpp.

References llvm::consumeError(), llvm::object::ObjectFile::createObjectFile(), llvm::Expected< T >::get(), llvm::Expected< T >::takeError(), unwrap(), and wrap().

◆ LLVMDisposeBinary()

LLVM_C_ABI void LLVMDisposeBinary ( LLVMBinaryRef  BR)

Dispose of a binary file.

The binary file does not own its backing buffer. It is the responsibilty of the caller to free it with LLVMDisposeMemoryBuffer.

Definition at line 86 of file Object.cpp.

References unwrap().

◆ LLVMDisposeObjectFile()

LLVM_C_ABI void LLVMDisposeObjectFile ( LLVMObjectFileRef  ObjectFile)

Deprecated: Use LLVMDisposeBinary instead.

Definition at line 197 of file Object.cpp.

References unwrap().

◆ LLVMDisposeRelocationIterator()

LLVM_C_ABI void LLVMDisposeRelocationIterator ( LLVMRelocationIteratorRef  RI)

Definition at line 289 of file Object.cpp.

References unwrap().

◆ LLVMDisposeSectionIterator()

LLVM_C_ABI void LLVMDisposeSectionIterator ( LLVMSectionIteratorRef  SI)

Definition at line 208 of file Object.cpp.

References unwrap().

◆ LLVMDisposeSymbolIterator()

LLVM_C_ABI void LLVMDisposeSymbolIterator ( LLVMSymbolIteratorRef  SI)

Definition at line 241 of file Object.cpp.

References unwrap().

◆ LLVMGetRelocationOffset()

LLVM_C_ABI uint64_t LLVMGetRelocationOffset ( LLVMRelocationIteratorRef  RI)

Definition at line 331 of file Object.cpp.

References unwrap().

◆ LLVMGetRelocations()

Definition at line 284 of file Object.cpp.

References unwrap(), and wrap().

◆ LLVMGetRelocationSymbol()

Definition at line 335 of file Object.cpp.

References unwrap(), and wrap().

◆ LLVMGetRelocationType()

LLVM_C_ABI uint64_t LLVMGetRelocationType ( LLVMRelocationIteratorRef  RI)

Definition at line 340 of file Object.cpp.

References unwrap().

◆ LLVMGetRelocationTypeName()

LLVM_C_ABI const char * LLVMGetRelocationTypeName ( LLVMRelocationIteratorRef  RI)

◆ LLVMGetRelocationValueString()

LLVM_C_ABI const char * LLVMGetRelocationValueString ( LLVMRelocationIteratorRef  RI)

Definition at line 354 of file Object.cpp.

◆ LLVMGetSectionAddress()

LLVM_C_ABI uint64_t LLVMGetSectionAddress ( LLVMSectionIteratorRef  SI)

Definition at line 274 of file Object.cpp.

References unwrap().

◆ LLVMGetSectionContainsSymbol()

LLVM_C_ABI LLVMBool LLVMGetSectionContainsSymbol ( LLVMSectionIteratorRef  SI,
LLVMSymbolIteratorRef  Sym 
)

Definition at line 278 of file Object.cpp.

References Sym, and unwrap().

◆ LLVMGetSectionContents()

LLVM_C_ABI const char * LLVMGetSectionContents ( LLVMSectionIteratorRef  SI)

Definition at line 267 of file Object.cpp.

References llvm::report_fatal_error(), and unwrap().

◆ LLVMGetSectionName()

LLVM_C_ABI const char * LLVMGetSectionName ( LLVMSectionIteratorRef  SI)

Definition at line 256 of file Object.cpp.

References getName(), llvm::report_fatal_error(), and unwrap().

◆ LLVMGetSections()

LLVM_C_ABI LLVMSectionIteratorRef LLVMGetSections ( LLVMObjectFileRef  ObjectFile)

Deprecated: Use LLVMObjectFileCopySectionIterator instead.

Definition at line 202 of file Object.cpp.

References unwrap(), and wrap().

◆ LLVMGetSectionSize()

LLVM_C_ABI uint64_t LLVMGetSectionSize ( LLVMSectionIteratorRef  SI)

Definition at line 263 of file Object.cpp.

References unwrap().

◆ LLVMGetSymbolAddress()

LLVM_C_ABI uint64_t LLVMGetSymbolAddress ( LLVMSymbolIteratorRef  SI)

Definition at line 315 of file Object.cpp.

References llvm::logAllUnhandledErrors(), OS, llvm::report_fatal_error(), and unwrap().

◆ LLVMGetSymbolName()

LLVM_C_ABI const char * LLVMGetSymbolName ( LLVMSymbolIteratorRef  SI)

◆ LLVMGetSymbols()

LLVM_C_ABI LLVMSymbolIteratorRef LLVMGetSymbols ( LLVMObjectFileRef  ObjectFile)

Deprecated: Use LLVMObjectFileCopySymbolIterator instead.

Definition at line 235 of file Object.cpp.

References unwrap(), and wrap().

◆ LLVMGetSymbolSize()

LLVM_C_ABI uint64_t LLVMGetSymbolSize ( LLVMSymbolIteratorRef  SI)

Definition at line 326 of file Object.cpp.

References unwrap().

◆ LLVMIsRelocationIteratorAtEnd()

LLVM_C_ABI LLVMBool LLVMIsRelocationIteratorAtEnd ( LLVMSectionIteratorRef  Section,
LLVMRelocationIteratorRef  RI 
)

Definition at line 293 of file Object.cpp.

References unwrap().

◆ LLVMIsSectionIteratorAtEnd()

LLVM_C_ABI LLVMBool LLVMIsSectionIteratorAtEnd ( LLVMObjectFileRef  ObjectFile,
LLVMSectionIteratorRef  SI 
)

Deprecated: Use LLVMObjectFileIsSectionIteratorAtEnd instead.

Definition at line 212 of file Object.cpp.

References unwrap().

◆ LLVMIsSymbolIteratorAtEnd()

LLVM_C_ABI LLVMBool LLVMIsSymbolIteratorAtEnd ( LLVMObjectFileRef  ObjectFile,
LLVMSymbolIteratorRef  SI 
)

Deprecated: Use LLVMObjectFileIsSymbolIteratorAtEnd instead.

Definition at line 245 of file Object.cpp.

References unwrap().

◆ LLVMMachOUniversalBinaryCopyObjectForArch()

LLVM_C_ABI LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch ( LLVMBinaryRef  BR,
const char Arch,
size_t  ArchLen,
char **  ErrorMessage 
)

◆ LLVMMoveToContainingSection()

LLVM_C_ABI void LLVMMoveToContainingSection ( LLVMSectionIteratorRef  Sect,
LLVMSymbolIteratorRef  Sym 
)

◆ LLVMMoveToNextRelocation()

LLVM_C_ABI void LLVMMoveToNextRelocation ( LLVMRelocationIteratorRef  RI)

Definition at line 298 of file Object.cpp.

References unwrap().

◆ LLVMMoveToNextSection()

LLVM_C_ABI void LLVMMoveToNextSection ( LLVMSectionIteratorRef  SI)

Definition at line 218 of file Object.cpp.

References unwrap().

◆ LLVMMoveToNextSymbol()

LLVM_C_ABI void LLVMMoveToNextSymbol ( LLVMSymbolIteratorRef  SI)

Definition at line 251 of file Object.cpp.

References unwrap().

◆ LLVMObjectFileCopySectionIterator()

LLVM_C_ABI LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator ( LLVMBinaryRef  BR)

Retrieve a copy of the section iterator for this object file.

If there are no sections, the result is NULL.

The returned iterator is merely a shallow copy. Nevertheless, it is the responsibility of the caller to free it with LLVMDisposeSectionIterator.

See also
llvm::object::sections()

Definition at line 154 of file Object.cpp.

References sections, unwrap(), and wrap().

◆ LLVMObjectFileCopySymbolIterator()

LLVM_C_ABI LLVMSymbolIteratorRef LLVMObjectFileCopySymbolIterator ( LLVMBinaryRef  BR)

Retrieve a copy of the symbol iterator for this object file.

If there are no symbols, the result is NULL.

The returned iterator is merely a shallow copy. Nevertheless, it is the responsibility of the caller to free it with LLVMDisposeSymbolIterator.

See also
llvm::object::symbols()

Definition at line 168 of file Object.cpp.

References unwrap(), and wrap().

◆ LLVMObjectFileIsSectionIteratorAtEnd()

LLVM_C_ABI LLVMBool LLVMObjectFileIsSectionIteratorAtEnd ( LLVMBinaryRef  BR,
LLVMSectionIteratorRef  SI 
)

Returns whether the given section iterator is at the end.

See also
llvm::object::section_end

Definition at line 162 of file Object.cpp.

References unwrap().

◆ LLVMObjectFileIsSymbolIteratorAtEnd()

LLVM_C_ABI LLVMBool LLVMObjectFileIsSymbolIteratorAtEnd ( LLVMBinaryRef  BR,
LLVMSymbolIteratorRef  SI 
)

Returns whether the given symbol iterator is at the end.

See also
llvm::object::symbol_end

Definition at line 176 of file Object.cpp.

References unwrap().