class SectionTable
Constants
- LUT_SHN
- LUT_SH_FLAGS
- LUT_SH_TYPE
- SH
Attributes
addresses[R]
index[R]
Public Class Methods
new(_fh)
click to toggle source
Calls superclass method
Base::new
# File lib/elfcat/sectiontable.rb, line 101 def initialize _fh super() @index = Hash.new @addresses = Hash.new parse _fh end
Public Instance Methods
debug()
click to toggle source
# File lib/elfcat/sectiontable.rb, line 124 def debug @data.each_with_index do |(k, d), i| print_debug_header(d.sh_real_name) if i % 64 == 0 index_s = sprintf("%4d", k) sh_name_index_s = d.sh_real_name ? sprintf("%-16.16s", d.sh_real_name) : sprintf("%4X", d.sh_name) sh_type_enum_s = sprintf("%-8.8s", LUT_SH_TYPE[d.sh_type] || d.sh_type) sh_flag_enum_s = sprintf("%-8.8s", LUT_SH_FLAGS[d.sh_flags] || d.sh_flags) sh_mem_address_s = CuteHex.x d.sh_addr sh_elf_address_s = CuteHex.x d.sh_offset sh_size_s = sprintf("%8d", d.sh_size) puts "#{index_s} | #{sh_name_index_s} #{sh_type_enum_s} #{sh_flag_enum_s} | #{sh_mem_address_s} #{sh_elf_address_s} #{sh_size_s}" end end
get_by_index(_n)
click to toggle source
# File lib/elfcat/sectiontable.rb, line 120 def get_by_index _n return @data[@index[_n]] end
populate(_sn)
click to toggle source
# File lib/elfcat/sectiontable.rb, line 109 def populate _sn @data.each do |k, d| @data[k][:sh_real_name] = _sn[k] @index[_sn[k]] = k @addresses[d.sh_addr] = _sn[k] @addresses[d.sh_offset] = _sn[k] end return self end
Private Instance Methods
parse(_fh)
click to toggle source
# File lib/elfcat/sectiontable.rb, line 153 def parse _fh base_elf_address = _fh.e_shoff struct_element_size = _fh.e_shentsize struct_count = _fh.e_shnum section_table_length = struct_element_size * struct_count x = $resource.slice_with_index(base_elf_address, section_table_length) parse_struct(SH, x, struct_count, struct_element_size) end
print_debug_header(_has_real_name = false)
click to toggle source
# File lib/elfcat/sectiontable.rb, line 140 def print_debug_header _has_real_name = false case _has_real_name when false puts "----------------------------------------------------------------" puts " IDX | nidx type flag | mem_addr elf_addr size (B)" puts "----------------------------------------------------------------" else puts "----------------------------------------------------------------------------" puts " IDX | name type flag | mem_addr elf_addr size (B)" puts "----------------------------------------------------------------------------" end end