Class: MachO::SegmentCommand64

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_64.

Constant Summary collapse

FORMAT =
"VVa16QQQQVVVV"
SIZEOF =
72

Instance Attribute Summary collapse

Attributes inherited from LoadCommand

#cmd, #cmdsize, #offset

Instance Method Summary collapse

Methods inherited from LoadCommand

new_from_bin, #to_s, #type

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

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

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 SegmentCommand64.



329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/macho/load_commands.rb', line 329

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

#fileoffFixnum (readonly)

Returns the file offset of the segment.

Returns:

  • (Fixnum)

    the file offset of the segment



308
309
310
# File 'lib/macho/load_commands.rb', line 308

def fileoff
  @fileoff
end

#filesizeFixnum (readonly)

Returns the amount to map from the file.

Returns:

  • (Fixnum)

    the amount to map from the file



311
312
313
# File 'lib/macho/load_commands.rb', line 311

def filesize
  @filesize
end

#flagsFixnum (readonly)

Returns any flags associated with the segment.

Returns:

  • (Fixnum)

    any flags associated with the segment



323
324
325
# File 'lib/macho/load_commands.rb', line 323

def flags
  @flags
end

#initprotFixnum (readonly)

Returns the initial VM protection.

Returns:

  • (Fixnum)

    the initial VM protection



317
318
319
# File 'lib/macho/load_commands.rb', line 317

def initprot
  @initprot
end

#maxprotFixnum (readonly)

Returns the maximum VM protection.

Returns:

  • (Fixnum)

    the maximum VM protection



314
315
316
# File 'lib/macho/load_commands.rb', line 314

def maxprot
  @maxprot
end

#nsectsFixnum (readonly)

Returns the number of sections in the segment.

Returns:

  • (Fixnum)

    the number of sections in the segment



320
321
322
# File 'lib/macho/load_commands.rb', line 320

def nsects
  @nsects
end

#segnameString (readonly)

Returns the name of the segment.

Returns:

  • (String)

    the name of the segment



299
300
301
# File 'lib/macho/load_commands.rb', line 299

def segname
  @segname
end

#vmaddrFixnum (readonly)

Returns the memory address of the segment.

Returns:

  • (Fixnum)

    the memory address of the segment



302
303
304
# File 'lib/macho/load_commands.rb', line 302

def vmaddr
  @vmaddr
end

#vmsizeFixnum (readonly)

Returns the memory size of the segment.

Returns:

  • (Fixnum)

    the memory size of the segment



305
306
307
# File 'lib/macho/load_commands.rb', line 305

def vmsize
  @vmsize
end

Instance Method Details

#flag?(flag) ⇒ Boolean

Returns true if flag is present in the segment's flag field.

Examples:

puts "this segment relocated in/to it" if sect.flag?(:SG_NORELOC)

Parameters:

  • flag (Symbol)

    a segment flag symbol

Returns:

  • (Boolean)

    true if flag is present in the segment's flag field



347
348
349
350
351
# File 'lib/macho/load_commands.rb', line 347

def flag?(flag)
	flag = SEGMENT_FLAGS[flag]
	return false if flag.nil?
	flags & flag == flag
end