Class: MachO::SegmentCommand

Inherits:
LoadCommand show all
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.

Instance Attribute Summary collapse

Attributes inherited from LoadCommand

#cmd, #cmdsize, #offset

Instance Method Summary collapse

Methods inherited from LoadCommand

new_from_bin, #to_s

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, filesize, maxprot, initprot, nsects, flags) ⇒ SegmentCommand

Returns a new instance of SegmentCommand.



388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/macho/load_commands.rb', line 388

def initialize(offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff,
		filesize, maxprot, initprot, nsects, flags)
	super(offset, cmd, cmdsize)
	@segname = segname
	@vmaddr = vmaddr
	@vmsize = vmsize
	@fileoff = fileoff
	@filesize = filesize
	@maxprot = maxprot
	@initprot = initprot
	@nsects = nsects
	@flags = flags
end

Instance Attribute Details

#fileoffFixnum (readonly)

Returns the file offset of the segment.

Returns:

  • (Fixnum)

    the file offset of the segment



367
368
369
# File 'lib/macho/load_commands.rb', line 367

def fileoff
  @fileoff
end

#filesizeFixnum (readonly)

Returns the amount to map from the file.

Returns:

  • (Fixnum)

    the amount to map from the file



370
371
372
# File 'lib/macho/load_commands.rb', line 370

def filesize
  @filesize
end

#flagsFixnum (readonly)

Returns any flags associated with the segment.

Returns:

  • (Fixnum)

    any flags associated with the segment



382
383
384
# File 'lib/macho/load_commands.rb', line 382

def flags
  @flags
end

#initprotFixnum (readonly)

Returns the initial VM protection.

Returns:

  • (Fixnum)

    the initial VM protection



376
377
378
# File 'lib/macho/load_commands.rb', line 376

def initprot
  @initprot
end

#maxprotFixnum (readonly)

Returns the maximum VM protection.

Returns:

  • (Fixnum)

    the maximum VM protection



373
374
375
# File 'lib/macho/load_commands.rb', line 373

def maxprot
  @maxprot
end

#nsectsFixnum (readonly)

Returns the number of sections in the segment.

Returns:

  • (Fixnum)

    the number of sections in the segment



379
380
381
# File 'lib/macho/load_commands.rb', line 379

def nsects
  @nsects
end

#segnameString (readonly)

Returns the name of the segment, including null padding bytes.

Returns:

  • (String)

    the name of the segment, including null padding bytes



358
359
360
# File 'lib/macho/load_commands.rb', line 358

def segname
  @segname
end

#vmaddrFixnum (readonly)

Returns the memory address of the segment.

Returns:

  • (Fixnum)

    the memory address of the segment



361
362
363
# File 'lib/macho/load_commands.rb', line 361

def vmaddr
  @vmaddr
end

#vmsizeFixnum (readonly)

Returns the memory size of the segment.

Returns:

  • (Fixnum)

    the memory size of the segment



364
365
366
# File 'lib/macho/load_commands.rb', line 364

def vmsize
  @vmsize
end

Instance Method Details

#segment_nameString

Returns the segment’s name, with any trailing NULL characters removed.

Returns:

  • (String)

    the segment’s name, with any trailing NULL characters removed



403
404
405
# File 'lib/macho/load_commands.rb', line 403

def segment_name
	@segname.delete("\x00")
end