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

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



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/macho/sections.rb', line 174

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

#addrFixnum (readonly)

Returns the memory address of the section.

Returns:

  • (Fixnum)

    the memory address of the section



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

def addr
  @addr
end

#alignFixnum (readonly)

Returns the section alignment (power of 2) of the section.

Returns:

  • (Fixnum)

    the section alignment (power of 2) of the section



150
151
152
# File 'lib/macho/sections.rb', line 150

def align
  @align
end

#flagsFixnum (readonly)

Returns flags for type and addrributes of the section.

Returns:

  • (Fixnum)

    flags for type and addrributes of the section



159
160
161
# File 'lib/macho/sections.rb', line 159

def flags
  @flags
end

#nrelocFixnum (readonly)

Returns the number of relocation entries.

Returns:

  • (Fixnum)

    the number of relocation entries



156
157
158
# File 'lib/macho/sections.rb', line 156

def nreloc
  @nreloc
end

#offsetFixnum (readonly)

Returns the file offset of the section.

Returns:

  • (Fixnum)

    the file offset of the section



147
148
149
# File 'lib/macho/sections.rb', line 147

def offset
  @offset
end

#reloffFixnum (readonly)

Returns the file offset of the section’s relocation entries.

Returns:

  • (Fixnum)

    the file offset of the section’s relocation entries



153
154
155
# File 'lib/macho/sections.rb', line 153

def reloff
  @reloff
end

#reserved1void (readonly)

This method returns an undefined value.

Returns reserved (for offset or index).



162
163
164
# File 'lib/macho/sections.rb', line 162

def reserved1
  @reserved1
end

#reserved2void (readonly)

This method returns an undefined value.

Returns reserved (for count or sizeof).



165
166
167
# File 'lib/macho/sections.rb', line 165

def reserved2
  @reserved2
end

#reserved3void (readonly)

This method returns an undefined value.

Returns reserved.



168
169
170
# File 'lib/macho/sections.rb', line 168

def reserved3
  @reserved3
end

#sectnameString (readonly)

Returns the name of the section, including null pad bytes.

Returns:

  • (String)

    the name of the section, including null pad bytes



135
136
137
# File 'lib/macho/sections.rb', line 135

def sectname
  @sectname
end

#segnameString (readonly)

Returns the name of the segment’s section, including null pad bytes.

Returns:

  • (String)

    the name of the segment’s section, including null pad bytes



138
139
140
# File 'lib/macho/sections.rb', line 138

def segname
  @segname
end

#sizeFixnum (readonly)

Returns the size, in bytes, of the section.

Returns:

  • (Fixnum)

    the size, in bytes, of the section



144
145
146
# File 'lib/macho/sections.rb', line 144

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



204
205
206
# File 'lib/macho/sections.rb', line 204

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



191
192
193
# File 'lib/macho/sections.rb', line 191

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



196
197
198
# File 'lib/macho/sections.rb', line 196

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