Class: ELFTools::Dynamic::HashTable::Gnu
- Inherits:
-
HashTable
- Object
- HashTable
- ELFTools::Dynamic::HashTable::Gnu
- Defined in:
- lib/elftools/dynamic/hash_table.rb
Overview
The table DT_GNU_HASH points at.
It only indexes the defined symbols a file exports under a name, and the symbols before #symndx are by construction not among them, so a name it does not lead to may still be in the symbol table.
Constant Summary collapse
- HEADER =
The header the table starts with.
Structs::ELF_GnuHash
Instance Method Summary collapse
-
#index_of(name) {|index| ... } ⇒ Integer?
The index a name sits at.
-
#num_symbols ⇒ Integer
How far the table reaches, i.e.
Instance Method Details
#index_of(name) {|index| ... } ⇒ Integer?
The index a name sits at.
A bucket leads to a chain of the indices whose names hash alike, so the block is what tells them apart.
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/elftools/dynamic/hash_table.rb', line 146 def index_of(name, &block) return if header.nbuckets.to_i.zero? || header.maskwords.to_i.zero? h = hash_of(name) return unless may_index?(h) n = word_at(buckets + ((h % header.nbuckets.to_i) * 4)) return if n.zero? || n < symndx walk(n, h, &block) end |
#num_symbols ⇒ Integer
How far the table reaches, i.e. the highest index it indexes plus one.
128 129 130 131 132 133 134 135 |
# File 'lib/elftools/dynamic/hash_table.rb', line 128 def num_symbols last = Array.new(header.nbuckets.to_i) { |i| word_at(buckets + (i * 4)) }.max || 0 return symndx if last < symndx n = last - symndx n += 1 while word_at(chain + (n * 4)).even? symndx + n + 1 end |