Class: Elf::GNU::SymbolVersionNeed

Inherits:
Section
  • Object
show all
Defined in:
lib/elf/gnu.rb

Constant Summary

Constants inherited from Section

Section::Abs, Section::Common, Section::FlagsToChars, Section::OsSpecific, Section::ProcSpecific, Section::Reserved, Section::SunW, Section::SunWIgnore, Section::Undef, Section::XIndex

Instance Attribute Summary

Attributes inherited from Section

#addr, #addralign, #entsize, #file, #index, #info, #offset, #size, #type

Instance Method Summary collapse

Methods inherited from Section

#==, #flags, #flags_i, #flags_s, #initialize, #link, #load, #name, read, #summary

Constructor Details

This class inherits a constructor from Elf::Section

Instance Method Details

#[](idx) ⇒ Object



159
160
161
162
163
# File 'lib/elf/gnu.rb', line 159

def [](idx)
  load unless @needed_versions

  @needed_versions[idx]
end

#countObject



153
154
155
156
157
# File 'lib/elf/gnu.rb', line 153

def count
  load unless @needed_versions

  @needed_versions.size
end

#each_version(&block) ⇒ Object

Allow to iterate over all the versions needed in the ELF file.



167
168
169
170
171
# File 'lib/elf/gnu.rb', line 167

def each_version(&block)
  load unless @needed_versions

  @needed_versions.each_value(&block)
end

#load_internalObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/elf/gnu.rb', line 116

def load_internal
  link.load # do this now for safety

  @needed_versions = {}
  loop do
    version = @file.read_half
    raise SymbolVersionUnknown.new(version) if version != 1
    aux_count = @file.read_half
    file = link[@file.read_word]
    # discard the next, it's used for non-sequential reading.
    @file.read_word
    # This one is interesting only when we need to stop the
    # read loop.
    more = @file.read_word != 0

    for i in 1..aux_count
      entry = {}
      
      entry[:file] = file
      entry[:hash] = @file.read_word
      entry[:flags] = @file.read_half

      tmp = @file.read_half # damn Drepper and overloaded values
      entry[:private] = !(tmp & (1 << 15) == 0)
      index = tmp & ~(1 << 15)

      entry[:name] = link[@file.read_word]

      @needed_versions[index] = entry

      break unless @file.read_word != 0
    end

    break unless more
  end
end