LLVM API Documentation

Object.h
Go to the documentation of this file.
00001 /*===-- llvm-c/Object.h - Object Lib C Iface --------------------*- C++ -*-===*/
00002 /*                                                                            */
00003 /*                     The LLVM Compiler Infrastructure                       */
00004 /*                                                                            */
00005 /* This file is distributed under the University of Illinois Open Source      */
00006 /* License. See LICENSE.TXT for details.                                      */
00007 /*                                                                            */
00008 /*===----------------------------------------------------------------------===*/
00009 /*                                                                            */
00010 /* This header declares the C interface to libLLVMObject.a, which             */
00011 /* implements object file reading and writing.                                */
00012 /*                                                                            */
00013 /* Many exotic languages can interoperate with C code but have a harder time  */
00014 /* with C++ due to name mangling. So in addition to C, this interface enables */
00015 /* tools written in such languages.                                           */
00016 /*                                                                            */
00017 /*===----------------------------------------------------------------------===*/
00018 
00019 #ifndef LLVM_C_OBJECT_H
00020 #define LLVM_C_OBJECT_H
00021 
00022 #include "llvm-c/Core.h"
00023 #include "llvm/Config/llvm-config.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /**
00030  * @defgroup LLVMCObject Object file reading and writing
00031  * @ingroup LLVMC
00032  *
00033  * @{
00034  */
00035 
00036 // Opaque type wrappers
00037 typedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
00038 typedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
00039 typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
00040 typedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
00041 
00042 // ObjectFile creation
00043 LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
00044 void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
00045 
00046 // ObjectFile Section iterators
00047 LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
00048 void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
00049 LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
00050                                 LLVMSectionIteratorRef SI);
00051 void LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
00052 void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect,
00053                                  LLVMSymbolIteratorRef Sym);
00054 
00055 // ObjectFile Symbol iterators
00056 LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile);
00057 void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI);
00058 LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile,
00059                                 LLVMSymbolIteratorRef SI);
00060 void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI);
00061 
00062 // SectionRef accessors
00063 const char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
00064 uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
00065 const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
00066 uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI);
00067 LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI,
00068                                  LLVMSymbolIteratorRef Sym);
00069 
00070 // Section Relocation iterators
00071 LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section);
00072 void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef RI);
00073 LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section,
00074                                        LLVMRelocationIteratorRef RI);
00075 void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef RI);
00076 
00077 
00078 // SymbolRef accessors
00079 const char *LLVMGetSymbolName(LLVMSymbolIteratorRef SI);
00080 uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI);
00081 uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI);
00082 
00083 // RelocationRef accessors
00084 uint64_t LLVMGetRelocationAddress(LLVMRelocationIteratorRef RI);
00085 uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI);
00086 LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI);
00087 uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI);
00088 // NOTE: Caller takes ownership of returned string of the two
00089 // following functions.
00090 const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI);
00091 const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
00092 
00093 /**
00094  * @}
00095  */
00096 
00097 #ifdef __cplusplus
00098 }
00099 #endif /* defined(__cplusplus) */
00100 
00101 #endif