Class: MachO::LoadCommands::DylinkerCommand

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

Overview

A load command representing some aspect of the dynamic linker, depending on filetype. Corresponds to LC_ID_DYLINKER, LC_LOAD_DYLINKER, and LC_DYLD_ENVIRONMENT.

Constant Summary collapse

FORMAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"L=3"
SIZEOF =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

12

Instance Attribute Summary collapse

Attributes inherited from LoadCommand

#cmd, #cmdsize, #view

Instance Method Summary collapse

Methods inherited from LoadCommand

create, new_from_bin, #offset, #serializable?, #to_s, #type

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(view, cmd, cmdsize, name) ⇒ DylinkerCommand

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



618
619
620
621
# File 'lib/macho/load_commands.rb', line 618

def initialize(view, cmd, cmdsize, name)
  super(view, cmd, cmdsize)
  @name = LCStr.new(self, name)
end

Instance Attribute Details

#nameLCStr (readonly)

Returns the dynamic linker's path name as an LCStr.

Returns:

  • (LCStr)

    the dynamic linker's path name as an LCStr



607
608
609
# File 'lib/macho/load_commands.rb', line 607

def name
  @name
end

Instance Method Details

#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



627
628
629
630
631
632
633
634
# File 'lib/macho/load_commands.rb', line 627

def serialize(context)
  format = Utils.specialize_format(FORMAT, context.endianness)
  string_payload, string_offsets = Utils.pack_strings(SIZEOF,
                                                      context.alignment,
                                                      :name => name.to_s)
  cmdsize = SIZEOF + string_payload.bytesize
  [cmd, cmdsize, string_offsets[:name]].pack(format) + string_payload
end

#to_hHash

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

Returns:



637
638
639
640
641
# File 'lib/macho/load_commands.rb', line 637

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