Class: MachO::Section
- Inherits:
-
MachOStructure
- Object
- MachOStructure
- MachO::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 =
"a16a16VVVVVVVVV"- SIZEOF =
68
Instance Attribute Summary collapse
-
#addr ⇒ Fixnum
readonly
The memory address of the section.
-
#align ⇒ Fixnum
readonly
The section alignment (power of 2) of the section.
-
#flags ⇒ Fixnum
readonly
Flags for type and addrributes of the section.
-
#nreloc ⇒ Fixnum
readonly
The number of relocation entries.
-
#offset ⇒ Fixnum
readonly
The file offset of the section.
-
#reloff ⇒ Fixnum
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 ⇒ Fixnum
readonly
The size, in bytes, of the section.
Instance Method Summary collapse
-
#flag?(flag) ⇒ Boolean
True if
flagis present in the sections's flag field. -
#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, with any trailing NULL characters removed.
-
#segment_name ⇒ String
The parent segment's name, with any trailing NULL characters removed.
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.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/macho/sections.rb', line 164 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 ⇒ Fixnum (readonly)
Returns the memory address of the section.
134 135 136 |
# File 'lib/macho/sections.rb', line 134 def addr @addr end |
#align ⇒ Fixnum (readonly)
Returns the section alignment (power of 2) of the section.
143 144 145 |
# File 'lib/macho/sections.rb', line 143 def align @align end |
#flags ⇒ Fixnum (readonly)
Returns flags for type and addrributes of the section.
152 153 154 |
# File 'lib/macho/sections.rb', line 152 def flags @flags end |
#nreloc ⇒ Fixnum (readonly)
Returns the number of relocation entries.
149 150 151 |
# File 'lib/macho/sections.rb', line 149 def nreloc @nreloc end |
#offset ⇒ Fixnum (readonly)
Returns the file offset of the section.
140 141 142 |
# File 'lib/macho/sections.rb', line 140 def offset @offset end |
#reloff ⇒ Fixnum (readonly)
Returns the file offset of the section's relocation entries.
146 147 148 |
# File 'lib/macho/sections.rb', line 146 def reloff @reloff end |
#reserved1 ⇒ void (readonly)
This method returns an undefined value.
Returns reserved (for offset or index).
155 156 157 |
# File 'lib/macho/sections.rb', line 155 def reserved1 @reserved1 end |
#reserved2 ⇒ void (readonly)
This method returns an undefined value.
Returns reserved (for count or sizeof).
158 159 160 |
# File 'lib/macho/sections.rb', line 158 def reserved2 @reserved2 end |
#sectname ⇒ String (readonly)
Returns the name of the section, including null pad bytes.
128 129 130 |
# File 'lib/macho/sections.rb', line 128 def sectname @sectname end |
#segname ⇒ String (readonly)
Returns the name of the segment's section, including null pad bytes.
131 132 133 |
# File 'lib/macho/sections.rb', line 131 def segname @segname end |
#size ⇒ Fixnum (readonly)
Returns the size, in bytes, of the section.
137 138 139 |
# File 'lib/macho/sections.rb', line 137 def size @size end |
Instance Method Details
#flag?(flag) ⇒ Boolean
Returns true if flag is present in the sections's flag field.
193 194 195 |
# File 'lib/macho/sections.rb', line 193 def flag?(flag) flags & flag == flag end |
#section_name ⇒ String
Returns the section's name, with any trailing NULL characters removed.
180 181 182 |
# File 'lib/macho/sections.rb', line 180 def section_name @sectname.delete("\x00") end |
#segment_name ⇒ String
Returns the parent segment's name, with any trailing NULL characters removed.
185 186 187 |
# File 'lib/macho/sections.rb', line 185 def segment_name @segname.delete("\x00") end |