Object.h revision 4344b1ef9b3721a5ebc2e024f753772a1e4ddd92
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
25e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#ifdef __cplusplus
26e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#include "llvm/Object/ObjectFile.h"
27e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
28e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopherextern "C" {
29e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#endif
30e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
31e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
32e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophertypedef struct LLVMOpaqueObjectFile *LLVMObjectFileRef;
33e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
34e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophertypedef struct LLVMOpaqueSectionIterator *LLVMSectionIteratorRef;
35e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
36e243fd9e2be8897c9350650b724d7eda2f607f8fEric ChristopherLLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf);
37e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophervoid LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile);
38e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
39e243fd9e2be8897c9350650b724d7eda2f607f8fEric ChristopherLLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile);
40e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophervoid LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI);
41e243fd9e2be8897c9350650b724d7eda2f607f8fEric ChristopherLLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile,
42e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher                                LLVMSectionIteratorRef SI);
43e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophervoid LLVMMoveToNextSection(LLVMSectionIteratorRef SI);
44e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopherconst char *LLVMGetSectionName(LLVMSectionIteratorRef SI);
45e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopheruint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI);
46e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopherconst char *LLVMGetSectionContents(LLVMSectionIteratorRef SI);
47e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
48e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
49e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#ifdef __cplusplus
50e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher}
51e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
52e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christophernamespace llvm {
53e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher  namespace object {
54e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
55e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher      return reinterpret_cast<ObjectFile*>(OF);
56e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    }
57e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
58e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    inline LLVMObjectFileRef wrap(const ObjectFile *OF) {
59e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher      return reinterpret_cast<LLVMObjectFileRef>(const_cast<ObjectFile*>(OF));
60e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    }
61e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
624344b1ef9b3721a5ebc2e024f753772a1e4ddd92Michael J. Spencer    inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
634344b1ef9b3721a5ebc2e024f753772a1e4ddd92Michael J. Spencer      return reinterpret_cast<section_iterator*>(SI);
64e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    }
65e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
66e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    inline LLVMSectionIteratorRef
674344b1ef9b3721a5ebc2e024f753772a1e4ddd92Michael J. Spencer    wrap(const section_iterator *SI) {
68e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher      return reinterpret_cast<LLVMSectionIteratorRef>
694344b1ef9b3721a5ebc2e024f753772a1e4ddd92Michael J. Spencer        (const_cast<section_iterator*>(SI));
70e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher    }
71e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher  }
72e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher}
73e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
74e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#endif /* defined(__cplusplus) */
75e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
76e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher#endif
77e243fd9e2be8897c9350650b724d7eda2f607f8fEric Christopher
78