Class: ElfUtils::Section::Base
- Inherits:
-
Object
- Object
- ElfUtils::Section::Base
show all
- Defined in:
- lib/elf_utils/section/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(file, header) ⇒ Base
Returns a new instance of Base.
3
4
5
6
7
|
# File 'lib/elf_utils/section/base.rb', line 3
def initialize(file, )
@file = file
@header =
@offset = 0
end
|
Instance Attribute Details
Returns the value of attribute header.
8
9
10
|
# File 'lib/elf_utils/section/base.rb', line 8
def
@header
end
|
Instance Method Details
#addr ⇒ Object
22
23
24
|
# File 'lib/elf_utils/section/base.rb', line 22
def addr
@header.sh_addr + @offset
end
|
#alloc? ⇒ Boolean
38
39
40
|
# File 'lib/elf_utils/section/base.rb', line 38
def alloc?
flags.include?(:alloc)
end
|
#bytes ⇒ Object
18
19
20
|
# File 'lib/elf_utils/section/base.rb', line 18
def bytes
@file.pread(@header.sh_size, @header.sh_offset)
end
|
#flags ⇒ Object
30
31
32
|
# File 'lib/elf_utils/section/base.rb', line 30
def flags
@header.sh_flags
end
|
#inspect ⇒ Object
14
15
16
|
# File 'lib/elf_utils/section/base.rb', line 14
def inspect
"<%p %s %p 0x%08x %p>" % [self.class, name, @header.sh_type, addr, flags]
end
|
#load_segment ⇒ Object
get the load_segment this section belongs to
73
74
75
|
# File 'lib/elf_utils/section/base.rb', line 73
def load_segment
@file.load_segments.find { |s| s.sections.include?(self) }
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/elf_utils/section/base.rb', line 10
def name
@file.shstrtab[@header.sh_name]
end
|
#offset ⇒ Object
34
35
36
|
# File 'lib/elf_utils/section/base.rb', line 34
def offset
@header.sh_offset
end
|
#relocate(addr, relative: false) ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/elf_utils/section/base.rb', line 57
def relocate(addr, relative: false)
@offset = if addr.nil?
0
elsif relative
addr
else
addr - @header.sh_addr
end
end
|
#relocation_offset ⇒ Object
return the relocation offset for this section
68
69
70
|
# File 'lib/elf_utils/section/base.rb', line 68
def relocation_offset
@offset
end
|
#size ⇒ Object
26
27
28
|
# File 'lib/elf_utils/section/base.rb', line 26
def size
@header.sh_size
end
|
#symbol(name) ⇒ Object
50
51
52
|
# File 'lib/elf_utils/section/base.rb', line 50
def symbol(name)
@file.symtab.symbols.find { |s| s.section == self && s.name == name }
end
|
#symbols ⇒ Object
46
47
48
|
# File 'lib/elf_utils/section/base.rb', line 46
def symbols
@file.symtab.symbols.select { |s| s.section == self }
end
|
#to_range ⇒ Object
42
43
44
|
# File 'lib/elf_utils/section/base.rb', line 42
def to_range
(addr...addr + size)
end
|