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
-
#covers_every_symbol? ⇒ Boolean
Whether the table is built over every symbol rather than over a subset of them.
-
#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
#covers_every_symbol? ⇒ Boolean
Whether the table is built over every symbol rather than over a subset of them.
Two things follow where it is. How many symbols it is built over is how many there are, rather than how far it reaches. And a name it does not lead to is not one the file records, so nothing is left to search.
81 82 83 |
# File 'lib/elftools/dynamic/hash_table.rb', line 81 def covers_every_symbol? true end |
#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.
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/elftools/dynamic/hash_table.rb', line 94 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.
76 77 78 |
# File 'lib/elftools/dynamic/hash_table.rb', line 76 def num_symbols header.nchain.to_i end |