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, # global symbol 0x22 => :N_FNAME, # procedure name (f77 kludge) 0x24 => :N_FUN, # procedure name 0x26 => :N_STSYM, # static symbol 0x28 => :N_LCSYM, # .lcomm symbol 0x2e => :N_BNSYM, # begin nsect symbol 0x3c => :N_OPT, # emitted with gcc2_compiled and in gcc source 0x40 => :N_RSYM, # register symbol 0x44 => :N_SLINE, # src line 0x4e => :N_ENSYM, # end nsect symbol 0x60 => :N_SSYM, # structure elt 0x64 => :N_SO, # source file name 0x66 => :N_OSO, # object file name 0x80 => :N_LSYM, # local symbol 0x82 => :N_BINCL, # include file beginning 0x84 => :N_SOL, # #included file name 0x86 => :N_PARAMS, # compiler parameters 0x88 => :N_VERSION, # compiler version 0x8A => :N_OLEVEL, # compiler -O level 0xa0 => :N_PSYM, # parameter 0xa2 => :N_EINCL, # include file end 0xa4 => :N_ENTRY, # alternate entry 0xc0 => :N_LBRAC, # left bracket 0xc2 => :N_EXCL, # deleted include file 0xe0 => :N_RBRAC, # right bracket 0xe2 => :N_BCOMM, # begin common 0xe4 => :N_ECOMM, # end common 0xe8 => :N_ECOML, # end common (local name) 0xfe => :N_LENG, # second stab entry with length information }
- REFERENCE_TYPE_MASK =
second stab entry with length information
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 99 100 101 102 |
# 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 # 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 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
132 133 134 135 136 137 138 |
# File 'lib/indis-macho/symbol.rb', line 132 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
128 129 130 |
# File 'lib/indis-macho/symbol.rb', line 128 def extern? @type_val & EXT_MASK == EXT_MASK end |
#private_extern? ⇒ Boolean
124 125 126 |
# File 'lib/indis-macho/symbol.rb', line 124 def private_extern? @type_val & PEXT_MASK == PEXT_MASK end |
#stab ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/indis-macho/symbol.rb', line 116 def stab if stab? STAB[@type_val] else nil end end |
#stab? ⇒ Boolean
112 113 114 |
# File 'lib/indis-macho/symbol.rb', line 112 def stab? @type_val & STAB_MASK != 0 end |
#twolevel_library_ordinal ⇒ Object
140 141 142 143 |
# File 'lib/indis-macho/symbol.rb', line 140 def twolevel_library_ordinal lo = (@desc_val >> 8) & 0xff LIBRARY_ORDINAL[lo] || lo end |