Class: Nxo::Dynamic::DynamicSection

Inherits:
Object
  • Object
show all
Defined in:
lib/nxo/dynamic.rb

Constant Summary collapse

SYMBOL_SIZE =
0x18

Instance Method Summary collapse

Constructor Details

#initialize(nxo, offset) ⇒ DynamicSection

Returns a new instance of DynamicSection.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/nxo/dynamic.rb', line 59

def initialize(nxo, offset)
  @nxo = nxo
  @offset = offset
  @entries = []
  
  lc = offset
  while((entry = Entry.new(self, *@nxo[lc, 0x10].unpack("Q<Q<"))).tag != DT::NULL) do
    @entries.push(entry)
    lc+= 0x10
  end
end

Instance Method Details

#[](tag) ⇒ Object



71
72
73
74
75
# File 'lib/nxo/dynamic.rb', line 71

def [](tag)
  return @entries.find do |entry|
    entry.tag == tag
  end
end

#nchainObject



77
78
79
# File 'lib/nxo/dynamic.rb', line 77

def nchain
  return @nxo[self[DT::HASH].value + 4, 4].unpack("L<")[0]
end

#string(i) ⇒ Object



81
82
83
# File 'lib/nxo/dynamic.rb', line 81

def string(i)
  @nxo[self[DT::STRTAB].value + i, 1024].unpack("Z1024")[0]
end

#symbol(i) ⇒ Object



87
88
89
90
91
# File 'lib/nxo/dynamic.rb', line 87

def symbol(i)
  pack = @nxo[self[DT::SYMTAB].value + i * SYMBOL_SIZE, SYMBOL_SIZE]
  name, info, other, shndx, value, size = pack.unpack("L<CCS<Q<Q<")
  return Symbol.new(string(name), info, other, shndx, value, size)
end