aboutsummaryrefslogtreecommitdiff
path: root/src/llvmext/Object.cpp
diff options
context:
space:
mode:
authorBrian Anderson <[email protected]>2011-03-13 19:40:25 -0400
committerBrian Anderson <[email protected]>2011-03-13 19:40:25 -0400
commitbbb6836da003be71744b6e6ea7af1fd4674f8291 (patch)
treefc7780f767666cced8406818806216bee3863c91 /src/llvmext/Object.cpp
parentRemove extra blocks from the translation of expr_block (diff)
parentAdd llvmext/include to the list of include directories to hopefully put out t... (diff)
downloadrust-bbb6836da003be71744b6e6ea7af1fd4674f8291.tar.xz
rust-bbb6836da003be71744b6e6ea7af1fd4674f8291.zip
Merge branch 'master' into recursive-elseif
Conflicts: src/comp/middle/typeck.rs
Diffstat (limited to 'src/llvmext/Object.cpp')
-rw-r--r--src/llvmext/Object.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/llvmext/Object.cpp b/src/llvmext/Object.cpp
new file mode 100644
index 00000000..f390870f
--- /dev/null
+++ b/src/llvmext/Object.cpp
@@ -0,0 +1,55 @@
+//===- Object.cpp - C bindings to the object file library--------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the C bindings to the file-format-independent object
+// library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Object/ObjectFile.h"
+#include "llvm-c/Object.h"
+
+using namespace llvm;
+using namespace object;
+
+LLVMObjectFileRef LLVMCreateObjectFile(const char *ObjectPath) {
+ StringRef SR(ObjectPath);
+ return wrap(ObjectFile::createObjectFile(SR));
+}
+
+void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile) {
+ delete unwrap(ObjectFile);
+}
+
+LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile) {
+ ObjectFile::section_iterator SI = unwrap(ObjectFile)->begin_sections();
+ return wrap(new ObjectFile::section_iterator(SI));
+}
+
+void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI) {
+ delete unwrap(SI);
+}
+
+void LLVMMoveToNextSection(LLVMSectionIteratorRef SI) {
+ ObjectFile::section_iterator UnwrappedSI = *unwrap(SI);
+ ++UnwrappedSI;
+}
+
+const char *LLVMGetSectionName(LLVMSectionIteratorRef SI) {
+ return (*unwrap(SI))->getName().data();
+}
+
+uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI) {
+ return (*unwrap(SI))->getSize();
+}
+
+const char *LLVMGetSectionContents(LLVMSectionIteratorRef SI) {
+ return (*unwrap(SI))->getContents().data();
+}
+