Class: OdinFlex::MachO::LC_SYMTAB

Inherits:
Command
  • Object
show all
Defined in:
lib/odinflex/mach-o.rb

Defined Under Namespace

Classes: NList

Constant Summary collapse

VALUE =
0x2
SIZE =

symoff

4 + # symoff
4 + # nsyms
4 + # stroff
4

Instance Attribute Summary collapse

Attributes inherited from Command

#cmd, #size

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#command?, from_offset

Methods included from SectionTypes

#command?, #dysymtab?, #section?, #segment?

Constructor Details

#initialize(cmd, size, symoff, nsyms, stroff, strsize, nlist) ⇒ LC_SYMTAB

Returns a new instance of LC_SYMTAB.



322
323
324
325
326
327
328
329
# File 'lib/odinflex/mach-o.rb', line 322

def initialize cmd, size, symoff, nsyms, stroff, strsize, nlist
  super(cmd, size)
  @symoff  = symoff
  @nsyms   = nsyms
  @stroff  = stroff
  @strsize = strsize
  @nlist   = nlist
end

Instance Attribute Details

#nlistObject (readonly)

Returns the value of attribute nlist.



320
321
322
# File 'lib/odinflex/mach-o.rb', line 320

def nlist
  @nlist
end

#nsymsObject (readonly)

Returns the value of attribute nsyms.



320
321
322
# File 'lib/odinflex/mach-o.rb', line 320

def nsyms
  @nsyms
end

#stroffObject (readonly)

Returns the value of attribute stroff.



320
321
322
# File 'lib/odinflex/mach-o.rb', line 320

def stroff
  @stroff
end

#strsizeObject (readonly)

Returns the value of attribute strsize.



320
321
322
# File 'lib/odinflex/mach-o.rb', line 320

def strsize
  @strsize
end

#symoffObject (readonly)

Returns the value of attribute symoff.



320
321
322
# File 'lib/odinflex/mach-o.rb', line 320

def symoff
  @symoff
end

Class Method Details

.from_io(cmd, size, offset, io) ⇒ Object



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/odinflex/mach-o.rb', line 297

def self.from_io cmd, size, offset, io
  current = io.pos
  symoff, nsyms, stroff, strsize = *io.read(SIZE).unpack('L4')

  io.seek stroff, IO::SEEK_SET
  stable = io.read(strsize)

  io.seek symoff, IO::SEEK_SET

  nlist = nsyms.times.map do |i|
    index = io.read(4).unpack1 'L'
    x = stable.byteslice(index, stable.bytesize)
    unless x
      return new(cmd, size, symoff, nsyms, stroff, strsize, [])
    end
    name = x.unpack1 "Z*"
    NList.new(name, index, *io.read(1 + 1 + 2 + 8).unpack('CCsQ'))
  end
  new(cmd, size, symoff, nsyms, stroff, strsize, nlist)
ensure
  io.seek current, IO::SEEK_SET
end

Instance Method Details

#symtab?Boolean

Returns:

  • (Boolean)


331
# File 'lib/odinflex/mach-o.rb', line 331

def symtab?; true; end