Class: Indis::Segment
- Inherits:
-
Object
- Object
- Indis::Segment
- Defined in:
- lib/indis-core/segment.rb
Overview
this class is heavily based on Mach-O
A segment describes one given segment contained in the target binary. Segment’s virtual size might be different from physical (stored in file), in this case the data is padded with zeroes
Instance Attribute Summary collapse
-
#bytes ⇒ String
readonly
The whole (zero-padded if required) bytes string for a segment.
-
#iooff ⇒ Fixnum
readonly
Offset from the beginning of of file to segment data.
-
#name ⇒ String
readonly
Segment name.
-
#sections ⇒ Array<Indis::Section>
readonly
Contains a list of current segment sections.
-
#target ⇒ Indis::Target
readonly
Owning target.
-
#vmaddr ⇒ Fixnum
readonly
Starting virtual address.
-
#vmsize ⇒ Fixnum
readonly
Segment size.
Instance Method Summary collapse
-
#initialize(target, name, vmaddr, vmsize, iooff, bytes) ⇒ Segment
constructor
A new instance of Segment.
-
#to_vmrange ⇒ Range
Constructs a Range of virtual addresses used by segment.
Constructor Details
#initialize(target, name, vmaddr, vmsize, iooff, bytes) ⇒ Segment
Returns a new instance of Segment.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/indis-core/segment.rb', line 51 def initialize(target, name, vmaddr, vmsize, iooff, bytes) @target = target @name = name @sections = [] @vmaddr = vmaddr @vmsize = vmsize @iooff = iooff @bytes = pad_bytes(bytes) end |
Instance Attribute Details
#bytes ⇒ String (readonly)
The whole (zero-padded if required) bytes string for a segment
41 42 43 |
# File 'lib/indis-core/segment.rb', line 41 def bytes @bytes end |
#iooff ⇒ Fixnum (readonly)
Returns offset from the beginning of of file to segment data.
43 44 45 |
# File 'lib/indis-core/segment.rb', line 43 def iooff @iooff end |
#name ⇒ String (readonly)
Returns segment name.
33 34 35 |
# File 'lib/indis-core/segment.rb', line 33 def name @name end |
#sections ⇒ Array<Indis::Section> (readonly)
Contains a list of current segment sections
29 30 31 |
# File 'lib/indis-core/segment.rb', line 29 def sections @sections end |
#target ⇒ Indis::Target (readonly)
Returns owning target.
31 32 33 |
# File 'lib/indis-core/segment.rb', line 31 def target @target end |
#vmaddr ⇒ Fixnum (readonly)
Returns starting virtual address.
35 36 37 |
# File 'lib/indis-core/segment.rb', line 35 def vmaddr @vmaddr end |
#vmsize ⇒ Fixnum (readonly)
Returns segment size.
37 38 39 |
# File 'lib/indis-core/segment.rb', line 37 def vmsize @vmsize end |
Instance Method Details
#to_vmrange ⇒ Range
Constructs a Range of virtual addresses used by segment
65 66 67 |
# File 'lib/indis-core/segment.rb', line 65 def to_vmrange @vmaddr...(@vmaddr+@vmsize) end |