Class: MachO::Sections::Section
- Inherits:
-
MachOStructure
- Object
- MachOStructure
- MachO::Sections::Section
- Defined in:
- lib/macho/sections.rb
Overview
Represents a section of a segment for 32-bit architectures.
Direct Known Subclasses
Constant Summary collapse
- FORMAT =
"Z16Z16L=9".freeze
- SIZEOF =
68
Instance Attribute Summary collapse
-
#addr ⇒ Integer
readonly
The memory address of the section.
-
#align ⇒ Integer
readonly
The section alignment (power of 2) of the section.
-
#flags ⇒ Integer
readonly
Flags for type and attributes of the section.
-
#nreloc ⇒ Integer
readonly
The number of relocation entries.
-
#offset ⇒ Integer
readonly
The file offset of the section.
-
#reloff ⇒ Integer
readonly
The file offset of the section's relocation entries.
-
#reserved1 ⇒ void
readonly
Reserved (for offset or index).
-
#reserved2 ⇒ void
readonly
Reserved (for count or sizeof).
-
#sectname ⇒ String
readonly
The name of the section, including null pad bytes.
-
#segname ⇒ String
readonly
The name of the segment's section, including null pad bytes.
-
#size ⇒ Integer
readonly
The size, in bytes, of the section.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether the section is empty (i.e, #size is 0).
-
#flag?(flag) ⇒ Boolean
Whether the flag is present in the section's #flags.
-
#initialize(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2) ⇒ Section
constructor
private
A new instance of Section.
-
#section_name ⇒ String
The section's name.
-
#segment_name ⇒ String
The parent segment's name.
-
#to_h ⇒ Hash
A hash representation of this Section.
Methods inherited from MachOStructure
Constructor Details
#initialize(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2) ⇒ Section
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Section.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/macho/sections.rb', line 117 def initialize(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2) @sectname = sectname @segname = segname @addr = addr @size = size @offset = offset @align = align @reloff = reloff @nreloc = nreloc @flags = flags @reserved1 = reserved1 @reserved2 = reserved2 end |
Instance Attribute Details
#addr ⇒ Integer (readonly)
Returns the memory address of the section.
84 85 86 |
# File 'lib/macho/sections.rb', line 84 def addr @addr end |
#align ⇒ Integer (readonly)
Returns the section alignment (power of 2) of the section.
93 94 95 |
# File 'lib/macho/sections.rb', line 93 def align @align end |
#flags ⇒ Integer (readonly)
Returns flags for type and attributes of the section.
102 103 104 |
# File 'lib/macho/sections.rb', line 102 def flags @flags end |
#nreloc ⇒ Integer (readonly)
Returns the number of relocation entries.
99 100 101 |
# File 'lib/macho/sections.rb', line 99 def nreloc @nreloc end |
#offset ⇒ Integer (readonly)
Returns the file offset of the section.
90 91 92 |
# File 'lib/macho/sections.rb', line 90 def offset @offset end |
#reloff ⇒ Integer (readonly)
Returns the file offset of the section's relocation entries.
96 97 98 |
# File 'lib/macho/sections.rb', line 96 def reloff @reloff end |
#reserved1 ⇒ void (readonly)
This method returns an undefined value.
Returns reserved (for offset or index).
105 106 107 |
# File 'lib/macho/sections.rb', line 105 def reserved1 @reserved1 end |
#reserved2 ⇒ void (readonly)
This method returns an undefined value.
Returns reserved (for count or sizeof).
108 109 110 |
# File 'lib/macho/sections.rb', line 108 def reserved2 @reserved2 end |
#sectname ⇒ String (readonly)
Returns the name of the section, including null pad bytes.
77 78 79 |
# File 'lib/macho/sections.rb', line 77 def sectname @sectname end |
#segname ⇒ String (readonly)
Returns the name of the segment's section, including null pad bytes.
81 82 83 |
# File 'lib/macho/sections.rb', line 81 def segname @segname end |
#size ⇒ Integer (readonly)
Returns the size, in bytes, of the section.
87 88 89 |
# File 'lib/macho/sections.rb', line 87 def size @size end |
Instance Method Details
#empty? ⇒ Boolean
Returns whether the section is empty (i.e, #size is 0).
143 144 145 |
# File 'lib/macho/sections.rb', line 143 def empty? size.zero? end |
#flag?(flag) ⇒ Boolean
Returns whether the flag is present in the section's #flags.
151 152 153 154 155 156 157 |
# File 'lib/macho/sections.rb', line 151 def flag?(flag) flag = SECTION_FLAGS[flag] return false if flag.nil? flags & flag == flag end |
#section_name ⇒ String
Returns the section's name.
133 134 135 |
# File 'lib/macho/sections.rb', line 133 def section_name sectname end |
#segment_name ⇒ String
Returns the parent segment's name.
138 139 140 |
# File 'lib/macho/sections.rb', line 138 def segment_name segname end |
#to_h ⇒ Hash
Returns a hash representation of this MachO::Sections::Section.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/macho/sections.rb', line 160 def to_h { "sectname" => sectname, "segname" => segname, "addr" => addr, "size" => size, "offset" => offset, "align" => align, "reloff" => reloff, "nreloc" => nreloc, "flags" => flags, "reserved1" => reserved1, "reserved2" => reserved2, }.merge super end |