Class: ELFTools::Dynamic::HashTable::SysV
- Inherits:
-
HashTable
- Object
- HashTable
- ELFTools::Dynamic::HashTable::SysV
- Defined in:
- lib/elftools/dynamic/hash_table.rb
Overview
The table DT_HASH points at, which the System V ABI defines.
A chain of it belongs to every symbol, so it is the one table that records how many there are.
Constant Summary collapse
Instance Method Summary collapse
-
#index_of(name) {|index| ... } ⇒ Integer?
The index a name sits at.
-
#num_symbols ⇒ Integer
How many symbols the table is built over, which it records outright.
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.
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/elftools/dynamic/hash_table.rb', line 78 def index_of(name) return if header.nbucket.to_i.zero? n = word_at(buckets + ((hash_of(name) % header.nbucket.to_i) * 4)) # Index zero is the undefined symbol, so it ends a chain instead of # belonging to one. while n.positive? && n < num_symbols return n if yield(n) n = word_at(chain + (n * 4)) end end |
#num_symbols ⇒ Integer
How many symbols the table is built over, which it records outright.
65 66 67 |
# File 'lib/elftools/dynamic/hash_table.rb', line 65 def num_symbols header.nchain.to_i end |