Class: MachO::Section

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

Overview

Represents a section of a segment for 32-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) ⇒ Section

Returns a new instance of Section.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/macho/sections.rb', line 68

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

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



61
62
63
# File 'lib/macho/sections.rb', line 61

def addr
  @addr
end

#alignObject (readonly)

Returns the value of attribute align.



61
62
63
# File 'lib/macho/sections.rb', line 61

def align
  @align
end

#flagsObject (readonly)

Returns the value of attribute flags.



62
63
64
# File 'lib/macho/sections.rb', line 62

def flags
  @flags
end

#nrelocObject (readonly)

Returns the value of attribute nreloc.



62
63
64
# File 'lib/macho/sections.rb', line 62

def nreloc
  @nreloc
end

#offsetObject (readonly)

Returns the value of attribute offset.



61
62
63
# File 'lib/macho/sections.rb', line 61

def offset
  @offset
end

#reloffObject (readonly)

Returns the value of attribute reloff.



61
62
63
# File 'lib/macho/sections.rb', line 61

def reloff
  @reloff
end

#reserved1Object (readonly)

Returns the value of attribute reserved1.



62
63
64
# File 'lib/macho/sections.rb', line 62

def reserved1
  @reserved1
end

#reserved2Object (readonly)

Returns the value of attribute reserved2.



62
63
64
# File 'lib/macho/sections.rb', line 62

def reserved2
  @reserved2
end

#sectnameObject (readonly)

Returns the value of attribute sectname.



61
62
63
# File 'lib/macho/sections.rb', line 61

def sectname
  @sectname
end

#segnameObject (readonly)

Returns the value of attribute segname.



61
62
63
# File 'lib/macho/sections.rb', line 61

def segname
  @segname
end

#sizeObject (readonly)

Returns the value of attribute size.



61
62
63
# File 'lib/macho/sections.rb', line 61

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



97
98
99
# File 'lib/macho/sections.rb', line 97

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



84
85
86
# File 'lib/macho/sections.rb', line 84

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



89
90
91
# File 'lib/macho/sections.rb', line 89

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