1 /*===-- llvm-c/Object.h - Object Lib C Iface --------------------*- C++ -*-===*/ 2 /* */ 3 /* The LLVM Compiler Infrastructure */ 4 /* */ 5 /* This file is distributed under the University of Illinois Open Source */ 6 /* License. See LICENSE.TXT for details. */ 7 /* */ 8 /*===----------------------------------------------------------------------===*/ 9 /* */ 10 /* This header declares the C interface to libLLVMObject.a, which */ 11 /* implements object file reading and writing. */ 12 /* */ 13 /* Many exotic languages can interoperate with C code but have a harder time */ 14 /* with C++ due to name mangling. So in addition to C, this interface enables */ 15 /* tools written in such languages. */ 16 /* */ 17 /*===----------------------------------------------------------------------===*/ 18 19 module deimos.llvm.c.object; 20 21 import core.stdc.stdint : uint64_t; 22 import deimos.llvm.c.core; 23 import deimos.llvm.config.llvm_config; 24 25 extern(C) nothrow: 26 27 /** 28 * @defgroup LLVMCObject Object file reading and writing 29 * @ingroup LLVMC 30 * 31 * @{ 32 */ 33 34 // Opaque type wrappers 35 struct __LLVMOpaqueObjectFile {}; 36 alias __LLVMOpaqueObjectFile *LLVMObjectFileRef; 37 struct __LLVMOpaqueSectionIterator {}; 38 alias __LLVMOpaqueSectionIterator *LLVMSectionIteratorRef; 39 struct __LLVMOpaqueSymbolIterator {}; 40 alias __LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef; 41 struct __LLVMOpaqueRelocationIterator {}; 42 alias __LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef; 43 44 // ObjectFile creation 45 LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf); 46 void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile); 47 48 // ObjectFile Section iterators 49 LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile); 50 void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI); 51 LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile, 52 LLVMSectionIteratorRef SI); 53 void LLVMMoveToNextSection(LLVMSectionIteratorRef SI); 54 void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, 55 LLVMSymbolIteratorRef Sym); 56 57 // ObjectFile Symbol iterators 58 LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile); 59 void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI); 60 LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile, 61 LLVMSymbolIteratorRef SI); 62 void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI); 63 64 // SectionRef accessors 65 const(char) *LLVMGetSectionName(LLVMSectionIteratorRef SI); 66 uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI); 67 const(char) *LLVMGetSectionContents(LLVMSectionIteratorRef SI); 68 uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI); 69 LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI, 70 LLVMSymbolIteratorRef Sym); 71 72 // Section Relocation iterators 73 LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section); 74 void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI); 75 LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section, 76 LLVMRelocationIteratorRef RI); 77 void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI); 78 79 80 // SymbolRef accessors 81 const(char) *LLVMGetSymbolName(LLVMSymbolIteratorRef SI); 82 uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI); 83 uint64_t LLVMGetSymbolFileOffset(LLVMSymbolIteratorRef SI); 84 uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI); 85 86 // RelocationRef accessors 87 uint64_t LLVMGetRelocationAddress(LLVMRelocationIteratorRef RI); 88 uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI); 89 LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI); 90 uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI); 91 // NOTE: Caller takes ownership of returned string of the two 92 // following functions. 93 const(char) *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI); 94 const(char) *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI); 95 96 /** 97 * @} 98 */