1e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*===-- llvm-c/Object.h - Object Lib C Iface --------------------*- C++ -*-===*/
2e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                                                                            */
3e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                     The LLVM Compiler Infrastructure                       */
4e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                                                                            */
5e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* This file is distributed under the University of Illinois Open Source      */
6e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* License. See LICENSE.TXT for details.                                      */
7e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                                                                            */
8e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*===----------------------------------------------------------------------===*/
9e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                                                                            */
10e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* This header declares the C interface to libLLVMObject.a, which             */
11e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* implements object file reading and writing.                                */
12e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                                                                            */
13e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* Many exotic languages can interoperate with C code but have a harder time  */
14e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* with C++ due to name mangling. So in addition to C, this interface enables */
15e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/* tools written in such languages.                                           */
16e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*                                                                            */
17e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher/*===----------------------------------------------------------------------===*/
18e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
19e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#ifndef LLVM_C_OBJECT_H
20e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#define LLVM_C_OBJECT_H
21e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
22e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#include "llvm-c/Core.h"
23e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#include "llvm/Config/llvm-config.h"
24e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
259313da5a90838c7242101dae250e86dcfc708e6aEvan Cheng#ifdef __cplusplus
26e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopherextern "C" {
27e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#endif
28e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
296244b518880842f2c15200ee041e06799e4cc779Gregory Szorc/**
306244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @defgroup LLVMCObject Object file reading and writing
316244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @ingroup LLVMC
326244b518880842f2c15200ee041e06799e4cc779Gregory Szorc *
336244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @{
346244b518880842f2c15200ee041e06799e4cc779Gregory Szorc */
356244b518880842f2c15200ee041e06799e4cc779Gregory Szorc
363cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson// Opaque type wrappers
37e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophertypedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
38e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophertypedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
3965f73abf079d3e9a5ccce8091f2058f6eced4720Owen Andersontypedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
40d8b0b915c5a94806596c381660c548aabef447b2Owen Andersontypedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
41e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
423cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson// ObjectFile creation
43e243fd9e2be8897c9350650b724d7eda2f607f8fEric ChristopherLLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
44e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophervoid LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
45e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
463cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson// ObjectFile Section iterators
47e243fd9e2be8897c9350650b724d7eda2f607f8fEric ChristopherLLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
48e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophervoid LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
49e243fd9e2be8897c9350650b724d7eda2f607f8fEric ChristopherLLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
50e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher                                LLVMSectionIteratorRef SI);
51e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophervoid LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
52e2fa64ef22321c5771667a8f00dca737ecb0799cOwen Andersonvoid LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
53e2fa64ef22321c5771667a8f00dca737ecb0799cOwen Anderson                                 LLVMSymbolIteratorRef Sym);
543cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson
553cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson// ObjectFile Symbol iterators
563cb056797b17785cfd2429ce8232143d5aeb5e42Owen AndersonLLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile);
573cb056797b17785cfd2429ce8232143d5aeb5e42Owen Andersonvoid LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI);
583cb056797b17785cfd2429ce8232143d5aeb5e42Owen AndersonLLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile,
593cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson                                LLVMSymbolIteratorRef SI);
603cb056797b17785cfd2429ce8232143d5aeb5e42Owen Andersonvoid LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI);
613cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson
623cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson// SectionRef accessors
63e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopherconst char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
64e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopheruint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
65e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopherconst char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
663cb056797b17785cfd2429ce8232143d5aeb5e42Owen Andersonuint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI);
67ca7eb3e171f63de3cfc1020d86375ce11d356194Owen AndersonLLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI,
683cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson                                 LLVMSymbolIteratorRef Sym);
69e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
70d8b0b915c5a94806596c381660c548aabef447b2Owen Anderson// Section Relocation iterators
71d8b0b915c5a94806596c381660c548aabef447b2Owen AndersonLLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section);
72d8b0b915c5a94806596c381660c548aabef447b2Owen Andersonvoid LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI);
73d8b0b915c5a94806596c381660c548aabef447b2Owen AndersonLLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section,
74d8b0b915c5a94806596c381660c548aabef447b2Owen Anderson                                       LLVMRelocationIteratorRef RI);
75d8b0b915c5a94806596c381660c548aabef447b2Owen Andersonvoid LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI);
76d8b0b915c5a94806596c381660c548aabef447b2Owen Anderson
77d8b0b915c5a94806596c381660c548aabef447b2Owen Anderson
783cb056797b17785cfd2429ce8232143d5aeb5e42Owen Anderson// SymbolRef accessors
793cb056797b17785cfd2429ce8232143d5aeb5e42Owen Andersonconst char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
803cb056797b17785cfd2429ce8232143d5aeb5e42Owen Andersonuint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
813cb056797b17785cfd2429ce8232143d5aeb5e42Owen Andersonuint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
82e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
833529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Anderson// RelocationRef accessors
843529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Andersonuint64_t LLVMGetRelocationAddress(LLVMRelocationIteratorRef RI);
85b0436a73054fe676b216a0cf872d1fc433125c62Danil Malyshevuint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
863529c53d2f07bb283e990d1678962f1b5eba9ba4Owen AndersonLLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
873529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Andersonuint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
883529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Anderson// NOTE: Caller takes ownership of returned string of the two
893529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Anderson// following functions.
903529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Andersonconst char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);
913529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Andersonconst char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
923529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Anderson
936244b518880842f2c15200ee041e06799e4cc779Gregory Szorc/**
946244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @}
956244b518880842f2c15200ee041e06799e4cc779Gregory Szorc */
963529c53d2f07bb283e990d1678962f1b5eba9ba4Owen Anderson
97e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#ifdef __cplusplus
98e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher}
999313da5a90838c7242101dae250e86dcfc708e6aEvan Cheng#endif /* defined(__cplusplus) */
100e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
101e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#endif
102