Class: ELFTools::Dynamic::StringTable

Inherits:
Object
  • Object
show all
Defined in:
lib/elftools/dynamic/string_table.rb

Overview

The names a file records, which the tags point at rather than a section.

Answers what Sections::StrTabSection answers, so that what is read from the tags names itself the way what is read from the sections does.

Instance Method Summary collapse

Constructor Details

#initialize(stream, offset) ⇒ StringTable

Instantiate a ELFTools::Dynamic::StringTable object.

Parameters:

  • stream (#pos=, #read)

    Streaming object.

  • offset (Method)

    Call this method to get the file offset the table starts at.



17
18
19
20
# File 'lib/elftools/dynamic/string_table.rb', line 17

def initialize(stream, offset)
  @stream = stream
  @offset = offset
end

Instance Method Details

#name_at(offset) ⇒ String

Return the name recorded at an offset into the table.

Parameters:

  • offset (Integer)

    Usually from tag.d_val or sym.st_name.

Returns:

  • (String)

    The name without null bytes.



25
26
27
# File 'lib/elftools/dynamic/string_table.rb', line 25

def name_at(offset)
  Util.cstring(@stream, @offset.call + offset)
end