aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/Object.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-10-27 17:32:36 +0000
committerOwen Anderson <resistor@mac.com>2011-10-27 17:32:36 +0000
commitf7a89d06ecec2fc80d29b3478d397d6285e00986 (patch)
tree4e170fc00ff89b5e9d1e3765d6f676f63e4615fa /llvm/lib/Object/Object.cpp
parentba7f90c7df7a5e58cfebb114418ab6a7d4847b33 (diff)
downloadllvm-f7a89d06ecec2fc80d29b3478d397d6285e00986.zip
llvm-f7a89d06ecec2fc80d29b3478d397d6285e00986.tar.gz
llvm-f7a89d06ecec2fc80d29b3478d397d6285e00986.tar.bz2
Expose relocation accessors through the libObject C API.
llvm-svn: 143109
Diffstat (limited to 'llvm/lib/Object/Object.cpp')
-rw-r--r--llvm/lib/Object/Object.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp
index a404cb3..719bf88 100644
--- a/llvm/lib/Object/Object.cpp
+++ b/llvm/lib/Object/Object.cpp
@@ -164,3 +164,48 @@ uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI) {
return ret;
}
+// RelocationRef accessors
+uint64_t LLVMGetRelocationAddress(LLVMRelocationIteratorRef RI) {
+ uint64_t ret;
+ if (error_code ec = (*unwrap(RI))->getAddress(ret))
+ report_fatal_error(ec.message());
+ return ret;
+}
+
+LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI) {
+ SymbolRef ret;
+ if (error_code ec = (*unwrap(RI))->getSymbol(ret))
+ report_fatal_error(ec.message());
+
+ return wrap(new symbol_iterator(ret));
+}
+
+uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI) {
+ uint64_t ret;
+ if (error_code ec = (*unwrap(RI))->getType(ret))
+ report_fatal_error(ec.message());
+ return ret;
+}
+
+// NOTE: Caller takes ownership of returned string.
+const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI) {
+ SmallVector<char, 0> ret;
+ if (error_code ec = (*unwrap(RI))->getTypeName(ret))
+ report_fatal_error(ec.message());
+
+ char *str = static_cast<char*>(malloc(ret.size()));
+ std::copy(ret.begin(), ret.end(), str);
+ return str;
+}
+
+// NOTE: Caller takes ownership of returned string.
+const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI) {
+ SmallVector<char, 0> ret;
+ if (error_code ec = (*unwrap(RI))->getValueString(ret))
+ report_fatal_error(ec.message());
+
+ char *str = static_cast<char*>(malloc(ret.size()));
+ std::copy(ret.begin(), ret.end(), str);
+ return str;
+}
+