Class: MachO::SegmentCommand
- Inherits:
-
LoadCommand
- Object
- MachOStructure
- LoadCommand
- MachO::SegmentCommand
- Defined in:
- lib/macho/load_commands.rb
Overview
A load command indicating that part of this file is to be mapped into the task's address space. Corresponds to LC_SEGMENT.
Constant Summary collapse
- FORMAT =
"VVa16VVVVVVVV"
- SIZEOF =
56
Instance Attribute Summary collapse
-
#fileoff ⇒ Fixnum
readonly
The file offset of the segment.
-
#filesize ⇒ Fixnum
readonly
The amount to map from the file.
-
#flags ⇒ Fixnum
readonly
Any flags associated with the segment.
-
#initprot ⇒ Fixnum
readonly
The initial VM protection.
-
#maxprot ⇒ Fixnum
readonly
The maximum VM protection.
-
#nsects ⇒ Fixnum
readonly
The number of sections in the segment.
-
#segname ⇒ String
readonly
The name of the segment.
-
#vmaddr ⇒ Fixnum
readonly
The memory address of the segment.
-
#vmsize ⇒ Fixnum
readonly
The memory size of the segment.
Attributes inherited from LoadCommand
Instance Method Summary collapse
-
#flag?(flag) ⇒ Boolean
True if
flag
is present in the segment's flag field. -
#initialize(raw_data, offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, filesize, maxprot, initprot, nsects, flags) ⇒ SegmentCommand
constructor
private
A new instance of SegmentCommand.
Methods inherited from LoadCommand
Methods inherited from MachOStructure
Constructor Details
#initialize(raw_data, offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, filesize, maxprot, initprot, nsects, flags) ⇒ SegmentCommand
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 SegmentCommand.
270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/macho/load_commands.rb', line 270 def initialize(raw_data, offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, filesize, maxprot, initprot, nsects, flags) super(raw_data, offset, cmd, cmdsize) @segname = segname.delete("\x00") @vmaddr = vmaddr @vmsize = vmsize @fileoff = fileoff @filesize = filesize @maxprot = maxprot @initprot = initprot @nsects = nsects @flags = flags end |
Instance Attribute Details
#fileoff ⇒ Fixnum (readonly)
Returns the file offset of the segment.
249 250 251 |
# File 'lib/macho/load_commands.rb', line 249 def fileoff @fileoff end |
#filesize ⇒ Fixnum (readonly)
Returns the amount to map from the file.
252 253 254 |
# File 'lib/macho/load_commands.rb', line 252 def filesize @filesize end |
#flags ⇒ Fixnum (readonly)
Returns any flags associated with the segment.
264 265 266 |
# File 'lib/macho/load_commands.rb', line 264 def flags @flags end |
#initprot ⇒ Fixnum (readonly)
Returns the initial VM protection.
258 259 260 |
# File 'lib/macho/load_commands.rb', line 258 def initprot @initprot end |
#maxprot ⇒ Fixnum (readonly)
Returns the maximum VM protection.
255 256 257 |
# File 'lib/macho/load_commands.rb', line 255 def maxprot @maxprot end |
#nsects ⇒ Fixnum (readonly)
Returns the number of sections in the segment.
261 262 263 |
# File 'lib/macho/load_commands.rb', line 261 def nsects @nsects end |
#segname ⇒ String (readonly)
Returns the name of the segment.
240 241 242 |
# File 'lib/macho/load_commands.rb', line 240 def segname @segname end |
#vmaddr ⇒ Fixnum (readonly)
Returns the memory address of the segment.
243 244 245 |
# File 'lib/macho/load_commands.rb', line 243 def vmaddr @vmaddr end |
#vmsize ⇒ Fixnum (readonly)
Returns the memory size of the segment.
246 247 248 |
# File 'lib/macho/load_commands.rb', line 246 def vmsize @vmsize end |
Instance Method Details
#flag?(flag) ⇒ Boolean
Returns true if flag
is present in the segment's flag field.
288 289 290 291 292 |
# File 'lib/macho/load_commands.rb', line 288 def flag?(flag) flag = SEGMENT_FLAGS[flag] return false if flag.nil? flags & flag == flag end |