diff --git a/llvm/include/llvm-c/Object.h b/llvm/include/llvm-c/Object.h index 3e6e1e3ffce0..6acad85c55a1 100644 --- a/llvm/include/llvm-c/Object.h +++ b/llvm/include/llvm-c/Object.h @@ -43,6 +43,8 @@ void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI); LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef ObjectFile, LLVMSectionIteratorRef SI); void LLVMMoveToNextSection(LLVMSectionIteratorRef SI); +void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, + LLVMSymbolIteratorRef Sym); // ObjectFile Symbol iterators LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile); diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp index 2ce98d7f9ca9..638105b56b37 100644 --- a/llvm/lib/Object/Object.cpp +++ b/llvm/lib/Object/Object.cpp @@ -48,6 +48,12 @@ void LLVMMoveToNextSection(LLVMSectionIteratorRef SI) { if (ec) report_fatal_error("LLVMMoveToNextSection failed: " + ec.message()); } +void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, + LLVMSymbolIteratorRef Sym) { + if (error_code ec = (*unwrap(Sym))->getSection(*unwrap(Sect))) + report_fatal_error(ec.message()); +} + // ObjectFile Symbol iterators LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef ObjectFile) { symbol_iterator SI = unwrap(ObjectFile)->begin_symbols();