Class: MachO::LoadCommands::LinkeditDataCommand

Inherits:
LoadCommand show all
Defined in:
lib/macho/load_commands.rb

Overview

A load command representing the offsets and sizes of a blob of data in the __LINKEDIT segment. Corresponds to LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS, LC_LINKER_OPTIMIZATION_HINT, LC_DYLD_EXPORTS_TRIE, LC_DYLD_CHAINED_FIXUPS, LC_ATOM_INFO, LC_FUNCTION_VARIANTS, LC_FUNCTION_VARIANT_FIXUPS, or LC_LAZY_LOAD_DYLIB_INFO.

Instance Method Summary collapse

Methods inherited from LoadCommand

#cmd, #cmdsize, create, new_from_bin, #offset, #serializable?, #to_s, #type, #view

Methods inherited from MachOStructure

bytesize, format, #initialize, new_from_bin

Constructor Details

This class inherits a constructor from MachO::MachOStructure

Instance Method Details

#dataoffInteger

Returns offset to the data in the __LINKEDIT segment.

Returns:

  • (Integer)

    offset to the data in the __LINKEDIT segment



1089
# File 'lib/macho/load_commands.rb', line 1089

field :dataoff, :uint32

#datasizeInteger

Returns size of the data in the __LINKEDIT segment.

Returns:

  • (Integer)

    size of the data in the __LINKEDIT segment



1092
# File 'lib/macho/load_commands.rb', line 1092

field :datasize, :uint32

#serialize(context) ⇒ String

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 the serialized fields of the load command.

Parameters:

Returns:

  • (String)

    the serialized fields of the load command

Raises:



1097
1098
1099
1100
1101
1102
# File 'lib/macho/load_commands.rb', line 1097

def serialize(context)
  raise LoadCommandNotSerializableError, type unless serializable?

  format = Utils.specialize_format(self.class.format, context.endianness)
  [cmd, self.class.bytesize, dataoff, datasize].pack(format)
end

#superblobCodeSigning::SuperBlob

The embedded signature referenced by this command.

Returns:

Raises:



1107
1108
1109
1110
1111
# File 'lib/macho/load_commands.rb', line 1107

def superblob
  raise CodeSigningError, "#{type} does not contain a code signature" unless type == :LC_CODE_SIGNATURE

  CodeSigning::SuperBlob.new(view.raw_data.byteslice(dataoff, datasize))
end

#to_hHash

Returns a hash representation of this MachO::LoadCommands::LinkeditDataCommand.

Returns:



1114
1115
1116
1117
1118
1119
# File 'lib/macho/load_commands.rb', line 1114

def to_h
  {
    "dataoff" => dataoff,
    "datasize" => datasize,
  }.merge super
end