Class: MachO::Section64

Inherits:
MachOStructure show all
Defined in:
lib/macho/sections.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2, reserved3) ⇒ Section64

Returns a new instance of Section64.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/macho/sections.rb', line 111

def initialize(sectname, segname, addr, size, offset, align, reloff,
    nreloc, flags, reserved1, reserved2, reserved3)
  @sectname = sectname
  @segname = segname
  @addr = addr
  @size = size
  @offset = offset
  @align = align
  @reloff = reloff
  @nreloc = nreloc
  @flags = flags
  @reserved1 = reserved1
  @reserved2 = reserved2
  @reserved3 = reserved3
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



104
105
106
# File 'lib/macho/sections.rb', line 104

def addr
  @addr
end

#alignObject (readonly)

Returns the value of attribute align.



104
105
106
# File 'lib/macho/sections.rb', line 104

def align
  @align
end

#flagsObject (readonly)

Returns the value of attribute flags.



105
106
107
# File 'lib/macho/sections.rb', line 105

def flags
  @flags
end

#nrelocObject (readonly)

Returns the value of attribute nreloc.



105
106
107
# File 'lib/macho/sections.rb', line 105

def nreloc
  @nreloc
end

#offsetObject (readonly)

Returns the value of attribute offset.



104
105
106
# File 'lib/macho/sections.rb', line 104

def offset
  @offset
end

#reloffObject (readonly)

Returns the value of attribute reloff.



104
105
106
# File 'lib/macho/sections.rb', line 104

def reloff
  @reloff
end

#reserved1Object (readonly)

Returns the value of attribute reserved1.



105
106
107
# File 'lib/macho/sections.rb', line 105

def reserved1
  @reserved1
end

#reserved2Object (readonly)

Returns the value of attribute reserved2.



105
106
107
# File 'lib/macho/sections.rb', line 105

def reserved2
  @reserved2
end

#reserved3Object (readonly)

Returns the value of attribute reserved3.



105
106
107
# File 'lib/macho/sections.rb', line 105

def reserved3
  @reserved3
end

#sectnameObject (readonly)

Returns the value of attribute sectname.



104
105
106
# File 'lib/macho/sections.rb', line 104

def sectname
  @sectname
end

#segnameObject (readonly)

Returns the value of attribute segname.



104
105
106
# File 'lib/macho/sections.rb', line 104

def segname
  @segname
end

#sizeObject (readonly)

Returns the value of attribute size.



104
105
106
# File 'lib/macho/sections.rb', line 104

def size
  @size
end

Instance Method Details

#flag?(flag) ⇒ Boolean

Returns true if ‘flag` is present in the sections’s flag field.

Examples:

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

Parameters:

  • flag (Fixnum)

    a section flag constant

Returns:

  • (Boolean)

    true if ‘flag` is present in the sections’s flag field



141
142
143
# File 'lib/macho/sections.rb', line 141

def flag?(flag)
  flags & flag == flag
end

#section_nameString

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

Returns:

  • (String)

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



128
129
130
# File 'lib/macho/sections.rb', line 128

def section_name
  @sectname.delete("\x00")
end

#segment_nameString

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

Returns:

  • (String)

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



133
134
135
# File 'lib/macho/sections.rb', line 133

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