1 //===- Object.cpp - C bindings to the object file library--------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the C bindings to the file-format-independent object
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Object/ObjectFile.h"
16 #include "llvm-c/Object.h"
19 using namespace object
;
21 LLVMObjectFileRef
LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf
) {
22 return wrap(ObjectFile::createObjectFile(unwrap(MemBuf
)));
25 void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile
) {
26 delete unwrap(ObjectFile
);
29 LLVMSectionIteratorRef
LLVMGetSections(LLVMObjectFileRef ObjectFile
) {
30 ObjectFile::section_iterator SI
= unwrap(ObjectFile
)->begin_sections();
31 return wrap(new ObjectFile::section_iterator(SI
));
34 void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI
) {
38 LLVMBool
LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile
,
39 LLVMSectionIteratorRef SI
) {
40 return (*unwrap(SI
) == unwrap(ObjectFile
)->end_sections()) ? 1 : 0;
43 void LLVMMoveToNextSection(LLVMSectionIteratorRef SI
) {
45 unwrap(SI
)->increment(ec
);
46 if (ec
) report_fatal_error("LLVMMoveToNextSection failed: " + ec
.message());
49 const char *LLVMGetSectionName(LLVMSectionIteratorRef SI
) {
51 if (error_code ec
= (*unwrap(SI
))->getName(ret
))
52 report_fatal_error(ec
.message());
56 uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI
) {
58 if (error_code ec
= (*unwrap(SI
))->getSize(ret
))
59 report_fatal_error(ec
.message());
63 const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI
) {
65 if (error_code ec
= (*unwrap(SI
))->getContents(ret
))
66 report_fatal_error(ec
.message());