Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 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 | |
Eric Christopher | cca8dbe | 2015-12-18 01:46:52 +0000 | [diff] [blame] | 22 | #include "llvm-c/Types.h" |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 23 | #include "llvm/Config/llvm-config.h" |
| 24 | |
Evan Cheng | 7d2166a | 2013-04-03 23:12:39 +0000 | [diff] [blame] | 25 | #ifdef __cplusplus |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 26 | extern "C" { |
| 27 | #endif |
| 28 | |
Gregory Szorc | 6244b51 | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 29 | /** |
| 30 | * @defgroup LLVMCObject Object file reading and writing |
| 31 | * @ingroup LLVMC |
| 32 | * |
| 33 | * @{ |
| 34 | */ |
| 35 | |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 36 | // Opaque type wrappers |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 37 | typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef; |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 38 | typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef; |
Owen Anderson | 65f73ab | 2011-10-21 20:28:19 +0000 | [diff] [blame] | 39 | typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef; |
Owen Anderson | d8b0b91 | 2011-10-27 17:15:47 +0000 | [diff] [blame] | 40 | typedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef; |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 41 | |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 42 | // ObjectFile creation |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 43 | LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf); |
| 44 | void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile); |
| 45 | |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 46 | // ObjectFile Section iterators |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 47 | LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile); |
| 48 | void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI); |
| 49 | LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile, |
| 50 | LLVMSectionIteratorRef SI); |
| 51 | void LLVMMoveToNextSection(LLVMSectionIteratorRef SI); |
Owen Anderson | e2fa64e | 2011-10-21 18:21:22 +0000 | [diff] [blame] | 52 | void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, |
| 53 | LLVMSymbolIteratorRef Sym); |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 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 |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 63 | const char *LLVMGetSectionName(LLVMSectionIteratorRef SI); |
| 64 | uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI); |
| 65 | const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI); |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 66 | uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI); |
Owen Anderson | ca7eb3e | 2011-10-21 20:35:58 +0000 | [diff] [blame] | 67 | LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI, |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 68 | LLVMSymbolIteratorRef Sym); |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 69 | |
Owen Anderson | d8b0b91 | 2011-10-27 17:15:47 +0000 | [diff] [blame] | 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 | |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 78 | // SymbolRef accessors |
| 79 | const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI); |
| 80 | uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI); |
Owen Anderson | 3cb0567 | 2011-10-21 17:50:59 +0000 | [diff] [blame] | 81 | uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI); |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 82 | |
Owen Anderson | 3529c53 | 2011-10-27 17:32:36 +0000 | [diff] [blame] | 83 | // RelocationRef accessors |
Danil Malyshev | b0436a7 | 2011-11-29 17:40:10 +0000 | [diff] [blame] | 84 | uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI); |
Owen Anderson | 3529c53 | 2011-10-27 17:32:36 +0000 | [diff] [blame] | 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 | |
Gregory Szorc | 6244b51 | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 92 | /** |
| 93 | * @} |
| 94 | */ |
Owen Anderson | 3529c53 | 2011-10-27 17:32:36 +0000 | [diff] [blame] | 95 | |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 96 | #ifdef __cplusplus |
| 97 | } |
Evan Cheng | 9313da5 | 2013-04-04 17:40:53 +0000 | [diff] [blame] | 98 | #endif /* defined(__cplusplus) */ |
Eric Christopher | e243fd9 | 2011-04-03 22:34:07 +0000 | [diff] [blame] | 99 | |
| 100 | #endif |