Class: MachO::LoadCommands::RpathCommand

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

Overview

A load command representing an rpath, which specifies a path that should be added to the current run path used to find @rpath prefixed dylibs. Corresponds to LC_RPATH.

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, path) ⇒ RpathCommand

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



1173
1174
1175
1176
# File 'lib/macho/load_commands.rb', line 1173

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

Instance Attribute Details

#pathLCStr (readonly)

Returns the path to add to the run path as an LCStr.

Returns:

  • (LCStr)

    the path to add to the run path as an LCStr



1162
1163
1164
# File 'lib/macho/load_commands.rb', line 1162

def path
  @path
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



1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/macho/load_commands.rb', line 1181

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

#to_hHash

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

Returns:



1191
1192
1193
1194
1195
# File 'lib/macho/load_commands.rb', line 1191

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