Class: Indis::MachO::Symbol
- Inherits:
-
Object
- Object
- Indis::MachO::Symbol
- Defined in:
- lib/indis-macho/symbol.rb
Constant Summary collapse
- STAB_MASK =
0xe0- PEXT_MASK =
0x10- TYPE_MASK =
0x0e- EXT_MASK =
0x01- TYPE =
{ 0x0 => :UNDEF, 0x2 => :ABS, 0xe => :SECT, 0xc => :PBUD, 0xa => :INDR, }
- STAB =
{ 0x20 => :N_GSYM, 0x22 => :N_FNAME, 0x24 => :N_FUN, 0x26 => :N_STSYM, 0x28 => :N_LCSYM, 0x2e => :N_BNSYM, 0x3c => :N_OPT, 0x40 => :N_RSYM, 0x44 => :N_SLINE, 0x4e => :N_ENSYM, 0x60 => :N_SSYM, 0x64 => :N_SO, 0x66 => :N_OSO, 0x80 => :N_LSYM, 0x82 => :N_BINCL, 0x84 => :N_SOL, 0x86 => :N_PARAMS, 0x88 => :N_VERSION, 0x8A => :N_OLEVEL, 0xa0 => :N_PSYM, 0xa2 => :N_EINCL, 0xa4 => :N_ENTRY, 0xc0 => :N_LBRAC, 0xc2 => :N_EXCL, 0xe0 => :N_RBRAC, 0xe2 => :N_BCOMM, 0xe4 => :N_ECOMM, 0xe8 => :N_ECOML, 0xfe => :N_LENG, }
- REFERENCE_TYPE_MASK =
0xf- DESC_REFERENCE =
{ 0x0 => :REFERENCE_FLAG_UNDEFINED_NON_LAZY, 0x1 => :REFERENCE_FLAG_UNDEFINED_LAZY, 0x2 => :REFERENCE_FLAG_DEFINED, 0x3 => :REFERENCE_FLAG_PRIVATE_DEFINED, 0x4 => :REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY, 0x5 => :REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY, }
- DESC_ADDITIONAL =
{ 0x08 => :N_ARM_THUMB_DEF, 0x10 => :REFERENCED_DYNAMICALLY, 0x20 => :N_DESC_DISCARDED_OR_N_NO_DEAD_STRIP, # TODO: resolve mach file type 0x40 => :N_WEAK_REF, 0x80 => :N_WEAK_DEF, }
- LIBRARY_ORDINAL =
{ 0x0 => :SELF_LIBRARY_ORDINAL, 0xfe => :DYNAMIC_LOOKUP_ORDINAL, 0xff => :EXECUTABLE_ORDINAL, }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sect ⇒ Object
readonly
Returns the value of attribute sect.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #desc ⇒ Object
- #extern? ⇒ Boolean
-
#initialize(payload, strtab) ⇒ Symbol
constructor
A new instance of Symbol.
- #private_extern? ⇒ Boolean
- #stab ⇒ Object
- #stab? ⇒ Boolean
- #twolevel_library_ordinal ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(payload, strtab) ⇒ Symbol
Returns a new instance of Symbol.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/indis-macho/symbol.rb', line 89 def initialize(payload, strtab) name_idx, @type_val, @sect, @desc_val, @value = payload.read(12).unpack('VCCSV') if name_idx == 0 @name = '' else @name = strtab[name_idx..-1].split("\0", 2)[0] end #puts "#{printf('%08x', value)} #{@name} sect #{@sect} #{self.type ? self.type : 'UNK 0b'+@type_val.to_s(2)} #{self.stab? ? 'stab ' : ''} #{self.private_extern? ? 'pvt ' : ''} #{self.extern? ? 'extern' : ''}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
87 88 89 |
# File 'lib/indis-macho/symbol.rb', line 87 def name @name end |
#sect ⇒ Object (readonly)
Returns the value of attribute sect.
87 88 89 |
# File 'lib/indis-macho/symbol.rb', line 87 def sect @sect end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
87 88 89 |
# File 'lib/indis-macho/symbol.rb', line 87 def value @value end |
Instance Method Details
#desc ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/indis-macho/symbol.rb', line 128 def desc d = [DESC_REFERENCE[@desc_val & REFERENCE_TYPE_MASK]] DESC_ADDITIONAL.each_pair do |k, v| d << v if @desc_val & k == k end d end |
#extern? ⇒ Boolean
124 125 126 |
# File 'lib/indis-macho/symbol.rb', line 124 def extern? @type_val & EXT_MASK == EXT_MASK end |
#private_extern? ⇒ Boolean
120 121 122 |
# File 'lib/indis-macho/symbol.rb', line 120 def private_extern? @type_val & PEXT_MASK == PEXT_MASK end |
#stab ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/indis-macho/symbol.rb', line 112 def stab if stab? STAB[@type_val] else nil end end |
#stab? ⇒ Boolean
108 109 110 |
# File 'lib/indis-macho/symbol.rb', line 108 def stab? @type_val & STAB_MASK != 0 end |
#twolevel_library_ordinal ⇒ Object
136 137 138 139 |
# File 'lib/indis-macho/symbol.rb', line 136 def twolevel_library_ordinal lo = (@desc_val >> 8) & 0xff LIBRARY_ORDINAL[lo] || lo end |