Permalink
Browse files

MachO::Symbol is now a subclass of Indis::Symbol

  • Loading branch information...
1 parent c1f2f6f commit d9aa02b1892d56c58d995ce3b78f6b5994f29435 @farcaller farcaller committed Apr 18, 2012
Showing with 12 additions and 20 deletions.
  1. +5 −12 lib/indis-macho.rb
  2. +7 −8 lib/indis-macho/symbol.rb
View
17 lib/indis-macho.rb
@@ -228,22 +228,15 @@ def build_symbols
symtabcommand.symbols.each do |sym|
next if sym.stab?
- sec = if sym.sect > 0
- @indexed_sections[sym.sect]
- else
- nil
- end
+ sym.section = @indexed_sections[sym.macho_section_index] if sym.macho_section_index > 0
- dy = if self.flags.include? :MH_TWOLEVEL
+ sym.image = if self.flags.include? :MH_TWOLEVEL
l2 = sym.twolevel_library_ordinal
- @indexed_dylibs[l2] if l2.is_a? Fixnum
- else
- nil
+ @indexed_dylibs[l2] if l2.is_a?(Fixnum)
end
- s = Indis::Symbol.new(sym.name, sec, dy, sym.value, sym)
- @target.symbols << s
- @target.publish_event(:target_symbol_processed, s)
+ @target.symbols << sym
+ @target.publish_event(:target_symbol_processed, sym)
end
end
View
15 lib/indis-macho/symbol.rb
@@ -16,10 +16,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
+require 'indis-core/symbol'
+
module Indis
module MachO
- class Symbol
+ class Symbol < Indis::Symbol
STAB_MASK = 0xe0
PEXT_MASK = 0x10
TYPE_MASK = 0x0e
@@ -84,21 +86,18 @@ class Symbol
0xff => :EXECUTABLE_ORDINAL,
}
- attr_reader :name, :sect, :value
+ attr_writer :image, :section, :image # image will be set later on by macho parser
+ attr_reader :macho_section_index
def initialize(payload, strtab)
- name_idx, @type_val, @sect, @desc_val, @value = payload.read(12).unpack('VCCSV')
+ name_idx, @type_val, @macho_section_index, @desc_val, @value = payload.read(12).unpack('VCCSV')
if name_idx == 0
@name = ''
else
@name = strtab[name_idx..-1].split("\0", 2)[0]
end
- # if stab?
- # puts ".stabs \"#{@name}\", #{STAB[@type_val]}, #{@sect}, #{self.desc}, #{@value}"
- # else
- # puts "SYM \"#{@name}\", #{TYPE[@type_val & TYPE_MASK]}, #{@sect}, #{self.desc}, #{@value}"
- # end
+ super(@name, nil, nil, @value)
end
def type

0 comments on commit d9aa02b

Please sign in to comment.