Class: Elf::StringTable

Inherits:
Section show all
Defined in:
lib/elf/stringtable.rb

Defined Under Namespace

Classes: InvalidIndex

Constant Summary

Constants inherited from Section

Elf::Section::Abs, Elf::Section::Common, Elf::Section::FlagsToChars, Elf::Section::OsSpecific, Elf::Section::ProcSpecific, Elf::Section::Reserved, Elf::Section::SunW, Elf::Section::SunWIgnore, Elf::Section::Undef, Elf::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

Raises:



38
39
40
41
42
43
44
45
46
47
# File 'lib/elf/stringtable.rb', line 38

def [](idx)
  load unless @rawtable

  raise InvalidIndex.new(idx, @rawtable.size) if
    idx >= @rawtable.size

  endidx = @rawtable.index("\x00", idx)

  return @rawtable[idx..endidx].chomp("\x00")
end

#load_internalObject



28
29
30
# File 'lib/elf/stringtable.rb', line 28

def load_internal
  @rawtable = @file.readexactly(@size)
end