diff options
author | Owen Anderson <resistor@mac.com> | 2011-10-27 17:32:36 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2011-10-27 17:32:36 +0000 |
commit | 3529c53d2f07bb283e990d1678962f1b5eba9ba4 (patch) | |
tree | 60781d26b7a87e4c170156f2d1d061bc178aae00 /lib | |
parent | 036a67d670413f8116415b87457f22d256f314ae (diff) | |
download | external_llvm-3529c53d2f07bb283e990d1678962f1b5eba9ba4.zip external_llvm-3529c53d2f07bb283e990d1678962f1b5eba9ba4.tar.gz external_llvm-3529c53d2f07bb283e990d1678962f1b5eba9ba4.tar.bz2 |
Expose relocation accessors through the libObject C API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143109 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Object/Object.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp index a404cb3..719bf88 100644 --- a/lib/Object/Object.cpp +++ b/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; +} + |