Module: ElfUtils::Section

Defined in:
lib/elf_utils/section.rb

Defined Under Namespace

Classes: Base, DebugAbbrev, DebugAddr, DebugArange, DebugInfo, DebugLine, DebugRanges, DebugStrOffsets, Dynsym, Strtab, Symtab

Class Method Summary collapse

Class Method Details

.from_header(elf_file, header) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/elf_utils/section.rb', line 3

def self.from_header(elf_file, header)
  case header.sh_type
  when :strtab
    return Section::Strtab.new(elf_file, header)
  when :symtab
    return Section::Symtab.new(elf_file, header)
  when :dynsym
    return Section::Dynsym.new(elf_file, header)
  end

  name = elf_file.shstrtab[header.sh_name]
  case name
  when ".debug_info"
    Section::DebugInfo.new(elf_file, header)
  when ".debug_abbrev"
    Section::DebugAbbrev.new(elf_file, header)
  when ".debug_str"
    Section::Strtab.new(elf_file, header)
  when ".debug_str_offsets"
    Section::DebugStrOffsets.new(elf_file, header)
  when ".debug_aranges"
    Section::DebugArange.new(elf_file, header)
  when ".debug_line"
    Section::DebugLine.new(elf_file, header)
  when ".debug_line_str"
    Section::Strtab.new(elf_file, header)
  when ".debug_addr"
    Section::DebugAddr.new(elf_file, header)
  when ".debug_ranges"
    Section::DebugRanges.new(elf_file, header)
  else
    Section::Base.new(elf_file, header)
  end
end