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 llvm.c.object;
20 
21 public import llvm.c.types;
22 
23 extern(C) nothrow:
24 
25 /**
26  * @defgroup LLVMCObject Object file reading and writing
27  * @ingroup LLVMC
28  *
29  * @{
30  */
31 
32 // Opaque type wrappers
33 struct __LLVMOpaqueObjectFile {};
34 alias __LLVMOpaqueObjectFile *LLVMObjectFileRef;
35 struct __LLVMOpaqueSectionIterator {};
36 alias __LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
37 struct __LLVMOpaqueSymbolIterator {};
38 alias __LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
39 struct __LLVMOpaqueRelocationIterator {};
40 alias __LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
41 
42 // ObjectFile creation
43 LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
44 void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
45 
46 // ObjectFile Section iterators
47 LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
48 void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
49 LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
50                                 LLVMSectionIteratorRef SI);
51 void LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
52 void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
53                                  LLVMSymbolIteratorRef Sym);
54 
55 // ObjectFile Symbol iterators
56 LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile);
57 void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI);
58 LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile,
59                                 LLVMSymbolIteratorRef SI);
60 void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI);
61 
62 // SectionRef accessors
63 const(char)* LLVMGetSectionName(LLVMSectionIteratorRef SI);
64 ulong LLVMGetSectionSize(LLVMSectionIteratorRef SI);
65 const(char)* LLVMGetSectionContents(LLVMSectionIteratorRef SI);
66 ulong LLVMGetSectionAddress(LLVMSectionIteratorRef SI);
67 LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI,
68                                  LLVMSymbolIteratorRef Sym);
69 
70 // Section Relocation iterators
71 LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section);
72 void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI);
73 LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section,
74                                        LLVMRelocationIteratorRef RI);
75 void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI);
76 
77 
78 // SymbolRef accessors
79 const(char)* LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
80 ulong LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
81 ulong LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
82 
83 // RelocationRef accessors
84 ulong LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
85 LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
86 ulong LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
87 // NOTE: Caller takes ownership of returned string of the two
88 // following functions.
89 const(char)* LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);
90 const(char)* LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
91 
92 /**
93  * @}
94  */