Class: MachO::LoadCommand
- Inherits:
-
MachOStructure
- Object
- MachOStructure
- MachO::LoadCommand
- Defined in:
- lib/macho/load_commands.rb
Overview
Mach-O load command structure This is the most generic load command - only cmd ID and size are represented, and no actual data. Used when a more specific class isn't available/implemented.
Direct Known Subclasses
DyldInfoCommand, DylibCommand, DylinkerCommand, DysymtabCommand, EncryptionInfoCommand, EncryptionInfoCommand64, EntryPointCommand, LinkeditDataCommand, LinkerOptionCommand, PrebindCksumCommand, PreboundDylibCommand, RoutinesCommand, RoutinesCommand64, RpathCommand, SegmentCommand, SegmentCommand64, SourceVersionCommand, SubClientCommand, SubFrameworkCommand, SubLibraryCommand, SubUmbrellaCommand, SymtabCommand, ThreadCommand, TwolevelHintsCommand, UUIDCommand, VersionMinCommand
Defined Under Namespace
Classes: LCStr
Constant Summary collapse
- FORMAT =
"L=2"- SIZEOF =
8
Instance Attribute Summary collapse
-
#cmd ⇒ Fixnum
readonly
The load command's identifying number.
-
#cmdsize ⇒ Fixnum
readonly
The size of the load command, in bytes.
-
#offset ⇒ Fixnum
readonly
The offset in the file the command was created from.
Class Method Summary collapse
-
.new_from_bin(raw_data, endianness, offset, bin) ⇒ MachO::LoadCommand
private
Creates a new LoadCommand given an offset and binary string.
Instance Method Summary collapse
-
#initialize(raw_data, offset, cmd, cmdsize) ⇒ LoadCommand
constructor
private
A new instance of LoadCommand.
-
#to_s ⇒ String
A string representation of the load command's identifying number.
-
#type ⇒ Symbol
(also: #to_sym)
A symbol representation of the load command's identifying number.
Methods inherited from MachOStructure
Constructor Details
#initialize(raw_data, offset, cmd, cmdsize) ⇒ LoadCommand
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 LoadCommand.
181 182 183 184 185 186 |
# File 'lib/macho/load_commands.rb', line 181 def initialize(raw_data, offset, cmd, cmdsize) @raw_data = raw_data @offset = offset @cmd = cmd @cmdsize = cmdsize end |
Instance Attribute Details
#cmd ⇒ Fixnum (readonly)
Returns the load command's identifying number.
155 156 157 |
# File 'lib/macho/load_commands.rb', line 155 def cmd @cmd end |
#cmdsize ⇒ Fixnum (readonly)
Returns the size of the load command, in bytes.
158 159 160 |
# File 'lib/macho/load_commands.rb', line 158 def cmdsize @cmdsize end |
#offset ⇒ Fixnum (readonly)
Returns the offset in the file the command was created from.
152 153 154 |
# File 'lib/macho/load_commands.rb', line 152 def offset @offset end |
Class Method Details
.new_from_bin(raw_data, endianness, offset, bin) ⇒ MachO::LoadCommand
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.
Creates a new LoadCommand given an offset and binary string
170 171 172 173 174 |
# File 'lib/macho/load_commands.rb', line 170 def self.new_from_bin(raw_data, endianness, offset, bin) format = specialize_format(self::FORMAT, endianness) self.new(raw_data, offset, *bin.unpack(format)) end |
Instance Method Details
#to_s ⇒ String
Returns a string representation of the load command's identifying number.
196 197 198 |
# File 'lib/macho/load_commands.rb', line 196 def to_s type.to_s end |
#type ⇒ Symbol Also known as: to_sym
Returns a symbol representation of the load command's identifying number.
189 190 191 |
# File 'lib/macho/load_commands.rb', line 189 def type LOAD_COMMANDS[cmd] end |