diff options
author | Robert Widmann <devteam.codafi@gmail.com> | 2019-04-09 21:53:31 +0000 |
---|---|---|
committer | Robert Widmann <devteam.codafi@gmail.com> | 2019-04-09 21:53:31 +0000 |
commit | d1ba3b13f83ebb7a76b62cacb1a97006c8d9f4b3 (patch) | |
tree | 35502407a8ddfdf11f7a70209c690f94d12f72df /llvm/lib/Object/Object.cpp | |
parent | 60f83544bb373debc0568cc001f26b82cf803e88 (diff) | |
download | bcm5719-llvm-d1ba3b13f83ebb7a76b62cacb1a97006c8d9f4b3.tar.gz bcm5719-llvm-d1ba3b13f83ebb7a76b62cacb1a97006c8d9f4b3.zip |
[LLVM-C] Add Section and Symbol Iterator Accessors for Object File Binaries
Summary: This brings us to full feature parity with the old API, so I've deprecated it and updated the tests. I'll do a follow-up patch to do some more cleanup and documentation work in this header.
Reviewers: whitequark, deadalnix
Reviewed By: whitequark
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60407
llvm-svn: 358037
Diffstat (limited to 'llvm/lib/Object/Object.cpp')
-rw-r--r-- | llvm/lib/Object/Object.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp index 3a88477cea6..77e27ec3e8f 100644 --- a/llvm/lib/Object/Object.cpp +++ b/llvm/lib/Object/Object.cpp @@ -131,6 +131,34 @@ LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR) { return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType(unwrap(BR)->getType()); } +LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator(LLVMBinaryRef BR) { + auto OF = cast<ObjectFile>(unwrap(BR)); + auto sections = OF->sections(); + if (sections.begin() == sections.end()) + return nullptr; + return wrap(new section_iterator(sections.begin())); +} + +LLVMBool LLVMObjectFileIsSectionIteratorAtEnd(LLVMBinaryRef BR, + LLVMSectionIteratorRef SI) { + auto OF = cast<ObjectFile>(unwrap(BR)); + return (*unwrap(SI) == OF->section_end()) ? 1 : 0; +} + +LLVMSymbolIteratorRef LLVMObjectFileCopySymbolIterator(LLVMBinaryRef BR) { + auto OF = cast<ObjectFile>(unwrap(BR)); + auto symbols = OF->symbols(); + if (symbols.begin() == symbols.end()) + return nullptr; + return wrap(new symbol_iterator(symbols.begin())); +} + +LLVMBool LLVMObjectFileIsSymbolIteratorAtEnd(LLVMBinaryRef BR, + LLVMSymbolIteratorRef SI) { + auto OF = cast<ObjectFile>(unwrap(BR)); + return (*unwrap(SI) == OF->symbol_end()) ? 1 : 0; +} + // ObjectFile creation LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) { std::unique_ptr<MemoryBuffer> Buf(unwrap(MemBuf)); |