@@ -56,7 +56,6 @@ public struct Section {
5656 /// The parent sequence of this section.
5757 private let sectionIterator : LLVMSectionIteratorRef
5858
59-
6059 internal init ( fromIterator si: LLVMSectionIteratorRef ) {
6160 self . sectionIterator = si
6261 self . name = String ( cString: LLVMGetSectionName ( si) )
@@ -72,6 +71,12 @@ public struct Section {
7271 sectionIterator: self . sectionIterator
7372 )
7473 }
74+
75+ /// Returns whether a symbol matching the given `Symbol` can be found in
76+ /// this section.
77+ public func contains( symbol: Symbol ) -> Bool {
78+ return LLVMGetSectionContainsSymbol ( self . sectionIterator, symbol. symbolIterator) != 0
79+ }
7580}
7681
7782/// A sequence for iterating over the sections in an object file.
@@ -109,10 +114,14 @@ public struct Symbol {
109114 /// The address of the symbol in the object file.
110115 public let address : Int
111116
117+ /// The parent sequence of this symbol.
118+ fileprivate let symbolIterator : LLVMSymbolIteratorRef
119+
112120 internal init ( fromIterator si: LLVMSymbolIteratorRef ) {
113121 self . name = String ( cString: LLVMGetSymbolName ( si) )
114122 self . size = Int ( LLVMGetSymbolSize ( si) )
115123 self . address = Int ( LLVMGetSymbolAddress ( si) )
124+ self . symbolIterator = si
116125 }
117126}
118127
@@ -188,8 +197,6 @@ public class SymbolSequence: Sequence {
188197 return Symbol ( fromIterator: self . llvm)
189198 }
190199 }
191-
192-
193200
194201 deinit {
195202 LLVMDisposeSymbolIterator ( llvm)
0 commit comments