class MachO::Sections::Section

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

Public Instance Methods

attribute?(attr_sym) click to toggle source

@example

puts "pure instructions" if sect.attribute?(:S_ATTR_PURE_INSTRUCTIONS)

@param attr_sym [Symbol] a section attribute symbol @return [Boolean] whether this section is of the given type

# File lib/macho/sections.rb, line 162
def attribute?(attr_sym)
  !!(attributes & SECTION_ATTRIBUTES[attr_sym])
end
attributes() click to toggle source

@return [Integer] the raw numeric attributes of this section

# File lib/macho/sections.rb, line 154
def attributes
  flags & SECTION_ATTRIBUTES_MASK
end
empty?() click to toggle source

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

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

@deprecated Use {#type?} or {#attribute?} instead. @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 171
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

# File lib/macho/sections.rb, line 126
def section_name
  sectname
end
segment_name() click to toggle source

@return [String] the parent segment’s name

# File lib/macho/sections.rb, line 131
def segment_name
  segname
end
to_h() click to toggle source

@return [Hash] a hash representation of this {Section}

Calls superclass method
# File lib/macho/sections.rb, line 180
def to_h
  {
    "sectname" => sectname,
    "segname" => segname,
    "addr" => addr,
    "size" => size,
    "offset" => offset,
    "align" => align,
    "reloff" => reloff,
    "nreloc" => nreloc,
    "flags" => flags,
    "reserved1" => reserved1,
    "reserved2" => reserved2,
  }.merge super
end
type() click to toggle source

@return [Integer] the raw numeric type of this section

# File lib/macho/sections.rb, line 141
def type
  flags & SECTION_TYPE_MASK
end
type?(type_sym) click to toggle source

@example

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

@param type_sym [Symbol] a section type symbol @return [Boolean] whether this section is of the given type

# File lib/macho/sections.rb, line 149
def type?(type_sym)
  type == SECTION_TYPES[type_sym]
end