LLVM  8.0.1
Object.h
Go to the documentation of this file.
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 #ifndef LLVM_C_OBJECT_H
20 #define LLVM_C_OBJECT_H
21 
22 #include "llvm-c/Types.h"
23 #include "llvm/Config/llvm-config.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /**
30  * @defgroup LLVMCObject Object file reading and writing
31  * @ingroup LLVMC
32  *
33  * @{
34  */
35 
36 // Opaque type wrappers
37 typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
38 typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
39 typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
40 typedef struct 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 uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
65 const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
66 uint64_t 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 uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
81 uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
82 
83 // RelocationRef accessors
84 uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
85 LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
86 uint64_t 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  */
95 
96 #ifdef __cplusplus
97 }
98 #endif /* defined(__cplusplus) */
99 
100 #endif
uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI)
Definition: Object.cpp:155
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition: Types.h:49
LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI, LLVMSymbolIteratorRef Sym)
Definition: Object.cpp:159
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf)
Definition: Object.cpp:62
const char * LLVMGetSectionContents(LLVMSectionIteratorRef SI)
Definition: Object.cpp:148
LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section, LLVMRelocationIteratorRef RI)
Definition: Object.cpp:174
void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI)
Definition: Object.cpp:122
void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, LLVMSymbolIteratorRef Sym)
Definition: Object.cpp:102
struct LLVMOpaqueSectionIterator * LLVMSectionIteratorRef
Definition: Object.h:38
void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI)
Definition: Object.cpp:88
void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:179
LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:218
uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI)
Definition: Object.cpp:144
struct LLVMOpaqueSymbolIterator * LLVMSymbolIteratorRef
Definition: Object.h:39
struct LLVMOpaqueObjectFile * LLVMObjectFileRef
Definition: Object.h:37
LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile, LLVMSectionIteratorRef SI)
Definition: Object.cpp:92
int LLVMBool
Definition: Types.h:29
LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile)
Definition: Object.cpp:116
LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section)
Definition: Object.cpp:165
const char * LLVMGetSectionName(LLVMSectionIteratorRef SI)
Definition: Object.cpp:137
const char * LLVMGetSymbolName(LLVMSymbolIteratorRef SI)
Definition: Object.cpp:185
void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:170
LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile)
Definition: Object.cpp:82
void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI)
Definition: Object.cpp:132
uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI)
Definition: Object.cpp:197
const char * LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:228
struct LLVMOpaqueRelocationIterator * LLVMRelocationIteratorRef
Definition: Object.h:40
uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:214
uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:223
void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile)
Definition: Object.cpp:77
LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile, LLVMSymbolIteratorRef SI)
Definition: Object.cpp:126
uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI)
Definition: Object.cpp:209
const char * LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI)
Definition: Object.cpp:237
void LLVMMoveToNextSection(LLVMSectionIteratorRef SI)
Definition: Object.cpp:98