Class: MachO::Sections::Section
- Inherits:
-
MachOStructure
- Object
- MachOStructure
- MachO::Sections::Section
- Defined in:
- lib/macho/sections.rb
Overview
Represents a section of a segment for 32-bit architectures.
Direct Known Subclasses
Instance Method Summary collapse
-
#addr ⇒ Integer
The memory address of the section.
-
#align ⇒ Integer
The section alignment (power of 2) of the section.
-
#attribute?(attr_sym) ⇒ Boolean
Whether this section is of the given type.
-
#attributes ⇒ Integer
The raw numeric attributes of this section.
-
#empty? ⇒ Boolean
Whether the section is empty (i.e, #size is 0).
-
#flag?(flag) ⇒ Boolean
deprecated
Deprecated.
Use #type? or #attribute? instead.
-
#flags ⇒ Integer
Flags for type and attributes of the section.
-
#nreloc ⇒ Integer
The number of relocation entries.
-
#offset ⇒ Integer
The file offset of the section.
-
#reloff ⇒ Integer
The file offset of the section's relocation entries.
-
#reserved1 ⇒ void
Reserved (for offset or index).
-
#reserved2 ⇒ void
Reserved (for count or sizeof).
-
#section_name ⇒ String
The section's name.
-
#sectname ⇒ String
The name of the section, including null pad bytes.
-
#segment_name ⇒ String
The parent segment's name.
-
#segname ⇒ String
The name of the segment's section, including null pad bytes.
-
#size ⇒ Integer
The size, in bytes, of the section.
-
#to_h ⇒ Hash
A hash representation of this Section.
-
#type ⇒ Integer
The raw numeric type of this section.
-
#type?(type_sym) ⇒ Boolean
Whether this section is of the given type.
Methods inherited from MachOStructure
bytesize, format, #initialize, new_from_bin
Constructor Details
This class inherits a constructor from MachO::MachOStructure
Instance Method Details
#addr ⇒ Integer
Returns the memory address of the section.
99 |
# File 'lib/macho/sections.rb', line 99 field :addr, :uint32 |
#align ⇒ Integer
Returns the section alignment (power of 2) of the section.
108 |
# File 'lib/macho/sections.rb', line 108 field :align, :uint32 |
#attribute?(attr_sym) ⇒ Boolean
Returns whether this section is of the given type.
162 163 164 |
# File 'lib/macho/sections.rb', line 162 def attribute?(attr_sym) !!(attributes & SECTION_ATTRIBUTES[attr_sym]) end |
#attributes ⇒ Integer
Returns the raw numeric attributes of this section.
154 155 156 |
# File 'lib/macho/sections.rb', line 154 def attributes flags & SECTION_ATTRIBUTES_MASK end |
#empty? ⇒ Boolean
Returns whether the section is empty (i.e, #size is 0).
136 137 138 |
# File 'lib/macho/sections.rb', line 136 def empty? size.zero? end |
#flag?(flag) ⇒ Boolean
Use #type? or #attribute? instead.
Returns whether the flag is present in the section's #flags.
171 172 173 174 175 176 177 |
# File 'lib/macho/sections.rb', line 171 def flag?(flag) flag = SECTION_FLAGS[flag] return false if flag.nil? flags & flag == flag end |
#flags ⇒ Integer
Returns flags for type and attributes of the section.
117 |
# File 'lib/macho/sections.rb', line 117 field :flags, :uint32 |
#nreloc ⇒ Integer
Returns the number of relocation entries.
114 |
# File 'lib/macho/sections.rb', line 114 field :nreloc, :uint32 |
#offset ⇒ Integer
Returns the file offset of the section.
105 |
# File 'lib/macho/sections.rb', line 105 field :offset, :uint32 |
#reloff ⇒ Integer
Returns the file offset of the section's relocation entries.
111 |
# File 'lib/macho/sections.rb', line 111 field :reloff, :uint32 |
#reserved1 ⇒ void
This method returns an undefined value.
Returns reserved (for offset or index).
120 |
# File 'lib/macho/sections.rb', line 120 field :reserved1, :uint32 |
#reserved2 ⇒ void
This method returns an undefined value.
Returns reserved (for count or sizeof).
123 |
# File 'lib/macho/sections.rb', line 123 field :reserved2, :uint32 |
#section_name ⇒ String
Returns the section's name.
126 127 128 |
# File 'lib/macho/sections.rb', line 126 def section_name sectname end |
#sectname ⇒ String
Returns the name of the section, including null pad bytes.
92 |
# File 'lib/macho/sections.rb', line 92 field :sectname, :string, :padding => :null, :size => 16 |
#segment_name ⇒ String
Returns the parent segment's name.
131 132 133 |
# File 'lib/macho/sections.rb', line 131 def segment_name segname end |
#segname ⇒ String
Returns the name of the segment's section, including null pad bytes.
96 |
# File 'lib/macho/sections.rb', line 96 field :segname, :string, :padding => :null, :size => 16 |
#size ⇒ Integer
Returns the size, in bytes, of the section.
102 |
# File 'lib/macho/sections.rb', line 102 field :size, :uint32 |
#to_h ⇒ Hash
Returns a hash representation of this MachO::Sections::Section.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# 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 ⇒ Integer
Returns the raw numeric type of this section.
141 142 143 |
# File 'lib/macho/sections.rb', line 141 def type flags & SECTION_TYPE_MASK end |
#type?(type_sym) ⇒ Boolean
Returns whether this section is of the given type.
149 150 151 |
# File 'lib/macho/sections.rb', line 149 def type?(type_sym) type == SECTION_TYPES[type_sym] end |