blob: a2980e89fe3dff8202aab4a5383c3e19327938e9 [file] [log] [blame]
Eric Christophere243fd92011-04-03 22:34:07 +00001/*===-- 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 Christophercca8dbe2015-12-18 01:46:52 +000022#include "llvm-c/Types.h"
Eric Christophere243fd92011-04-03 22:34:07 +000023#include "llvm/Config/llvm-config.h"
24
Evan Cheng7d2166a2013-04-03 23:12:39 +000025#ifdef __cplusplus
Eric Christophere243fd92011-04-03 22:34:07 +000026extern "C" {
27#endif
28
Gregory Szorc6244b512012-03-21 03:54:29 +000029/**
30 * @defgroup LLVMCObject Object file reading and writing
31 * @ingroup LLVMC
32 *
33 * @{
34 */
35
Owen Anderson3cb05672011-10-21 17:50:59 +000036// Opaque type wrappers
Eric Christophere243fd92011-04-03 22:34:07 +000037typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
Eric Christophere243fd92011-04-03 22:34:07 +000038typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
Owen Anderson65f73ab2011-10-21 20:28:19 +000039typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
Owen Andersond8b0b912011-10-27 17:15:47 +000040typedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
Eric Christophere243fd92011-04-03 22:34:07 +000041
Owen Anderson3cb05672011-10-21 17:50:59 +000042// ObjectFile creation
Eric Christophere243fd92011-04-03 22:34:07 +000043LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
44void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
45
Owen Anderson3cb05672011-10-21 17:50:59 +000046// ObjectFile Section iterators
Eric Christophere243fd92011-04-03 22:34:07 +000047LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
48void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
49LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
50 LLVMSectionIteratorRef SI);
51void LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
Owen Andersone2fa64e2011-10-21 18:21:22 +000052void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
53 LLVMSymbolIteratorRef Sym);
Owen Anderson3cb05672011-10-21 17:50:59 +000054
55// ObjectFile Symbol iterators
56LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile);
57void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI);
58LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile,
59 LLVMSymbolIteratorRef SI);
60void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI);
61
62// SectionRef accessors
Eric Christophere243fd92011-04-03 22:34:07 +000063const char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
64uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
65const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
Owen Anderson3cb05672011-10-21 17:50:59 +000066uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI);
Owen Andersonca7eb3e2011-10-21 20:35:58 +000067LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI,
Owen Anderson3cb05672011-10-21 17:50:59 +000068 LLVMSymbolIteratorRef Sym);
Eric Christophere243fd92011-04-03 22:34:07 +000069
Owen Andersond8b0b912011-10-27 17:15:47 +000070// Section Relocation iterators
71LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section);
72void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI);
73LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section,
74 LLVMRelocationIteratorRef RI);
75void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI);
76
77
Owen Anderson3cb05672011-10-21 17:50:59 +000078// SymbolRef accessors
79const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
80uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
Owen Anderson3cb05672011-10-21 17:50:59 +000081uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
Eric Christophere243fd92011-04-03 22:34:07 +000082
Owen Anderson3529c532011-10-27 17:32:36 +000083// RelocationRef accessors
Danil Malyshevb0436a72011-11-29 17:40:10 +000084uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
Owen Anderson3529c532011-10-27 17:32:36 +000085LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
86uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
87// NOTE: Caller takes ownership of returned string of the two
88// following functions.
89const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);
90const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
91
Gregory Szorc6244b512012-03-21 03:54:29 +000092/**
93 * @}
94 */
Owen Anderson3529c532011-10-27 17:32:36 +000095
Eric Christophere243fd92011-04-03 22:34:07 +000096#ifdef __cplusplus
97}
Evan Cheng9313da52013-04-04 17:40:53 +000098#endif /* defined(__cplusplus) */
Eric Christophere243fd92011-04-03 22:34:07 +000099
100#endif