Class: ElfUtils::Section::DebugStrOffsets

Inherits:
Base
  • Object
show all
Defined in:
lib/elf_utils/section/debug_str_offsets.rb

Instance Attribute Summary

Attributes inherited from Base

#header

Instance Method Summary collapse

Methods inherited from Base

#addr, #alloc?, #bytes, #flags, #initialize, #inspect, #load_segment, #name, #offset, #relocate, #relocation_offset, #size, #symbol, #symbols, #to_range

Constructor Details

This class inherits a constructor from ElfUtils::Section::Base

Instance Method Details

#get(base:, offset:, format:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/elf_utils/section/debug_str_offsets.rb', line 3

def get(base:, offset:, format:)
  type = case format
  when :dwarf32
    CTypes::UInt32.with_endian(@file.endian)
  when :dwarf64
    CTypes::UInt64.with_endian(@file.endian)
  else
    raise Error, "unsupported format: %p" % [format]
  end
  pos = base + offset * type.size
  type.unpack(bytes[pos..])
end