class MachO::LoadCommands::SegmentCommand
A load command indicating that part of this file is to be mapped into the task's address space. Corresponds to LC_SEGMENT.
Constants
- FORMAT
@see MachOStructure::FORMAT @api private
- SIZEOF
@see MachOStructure::SIZEOF @api private
Attributes
@return [Fixnum] the file offset of the segment
@return [Fixnum] the amount to map from the file
@return [Fixnum] any flags associated with the segment
@return [Fixnum] the initial VM protection
@return [Fixnum] the maximum VM protection
@return [Fixnum] the number of sections in the segment
@return [String] the name of the segment
@return [Fixnum] the memory address of the segment
@return [Fixnum] the memory size of the segment
Public Class Methods
@api private
# File lib/macho/load_commands.rb, line 404 def initialize(view, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, filesize, maxprot, initprot, nsects, flags) super(view, cmd, cmdsize) @segname = segname.delete("\x00") @vmaddr = vmaddr @vmsize = vmsize @fileoff = fileoff @filesize = filesize @maxprot = maxprot @initprot = initprot @nsects = nsects @flags = flags end
Public Instance Methods
@example
puts "this segment relocated in/to it" if sect.flag?(:SG_NORELOC)
@param flag [Symbol] a segment flag symbol @return [Boolean] true if `flag` is present in the segment's flag field
# File lib/macho/load_commands.rb, line 442 def flag?(flag) flag = SEGMENT_FLAGS[flag] return false if flag.nil? flags & flag == flag end
All sections referenced within this segment. @return [Array<MachO::Sections::Section>] if the Mach-O is 32-bit @return [Array<MachO::Sections::Section64>] if the Mach-O is 64-bit
# File lib/macho/load_commands.rb, line 421 def sections klass = case self when SegmentCommand64 MachO::Sections::Section64 when SegmentCommand MachO::Sections::Section end offset = view.offset + self.class.bytesize length = nsects * klass.bytesize bins = view.raw_data[offset, length] bins.unpack("a#{klass.bytesize}" * nsects).map do |bin| klass.new_from_bin(view.endianness, bin) end end