class MachO::Sections::Section

Represents a section of a segment for 32-bit architectures.

Constants

FORMAT

@see MachOStructure::FORMAT

SIZEOF

@see MachOStructure::SIZEOF

Attributes

addr[R]

@return [Fixnum] the memory address of the section

align[R]

@return [Fixnum] the section alignment (power of 2) of the section

flags[R]

@return [Fixnum] flags for type and attributes of the section

nreloc[R]

@return [Fixnum] the number of relocation entries

offset[R]

@return [Fixnum] the file offset of the section

reloff[R]

@return [Fixnum] the file offset of the section's relocation entries

reserved1[R]

@return [void] reserved (for offset or index)

reserved2[R]

@return [void] reserved (for count or sizeof)

sectname[R]

@return [String] the name of the section, including null pad bytes

segname[R]

@return [String] the name of the segment's section, including null

pad bytes
size[R]

@return [Fixnum] the size, in bytes, of the section

Public Class Methods

new(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2) click to toggle source

@api private

# File lib/macho/sections.rb, line 113
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

Public Instance Methods

empty?() click to toggle source

@return [Boolean] whether the section is empty (i.e, {size} is 0)

# File lib/macho/sections.rb, line 141
def empty?
  size.zero?
end
flag?(flag) click to toggle source

@example

puts "this section is regular" if sect.flag?(:S_REGULAR)

@param flag [Symbol] a section flag symbol @return [Boolean] whether the flag is present in the section's {flags}

# File lib/macho/sections.rb, line 149
def flag?(flag)
  flag = SECTION_FLAGS[flag]
  return false if flag.nil?
  flags & flag == flag
end
section_name() click to toggle source

@return [String] the section's name, with any trailing NULL characters

removed
# File lib/macho/sections.rb, line 130
def section_name
  sectname.delete("\x00")
end
segment_name() click to toggle source

@return [String] the parent segment's name, with any trailing NULL

characters removed
# File lib/macho/sections.rb, line 136
def segment_name
  segname.delete("\x00")
end