Class: MachO::LoadCommands::DylibCommand

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

Overview

A load command representing some aspect of shared libraries, depending on filetype. Corresponds to LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, and LC_REEXPORT_DYLIB.

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=6"
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.

24

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, timestamp, current_version, compatibility_version) ⇒ DylibCommand

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



567
568
569
570
571
572
573
574
# File 'lib/macho/load_commands.rb', line 567

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

Instance Attribute Details

#compatibility_versionInteger (readonly)

Returns the library's compatibility version number.

Returns:

  • (Integer)

    the library's compatibility version number



556
557
558
# File 'lib/macho/load_commands.rb', line 556

def compatibility_version
  @compatibility_version
end

#current_versionInteger (readonly)

Returns the library's current version number.

Returns:

  • (Integer)

    the library's current version number



553
554
555
# File 'lib/macho/load_commands.rb', line 553

def current_version
  @current_version
end

#nameLCStr (readonly)

Returns the library's path name as an LCStr.

Returns:

  • (LCStr)

    the library's path name as an LCStr



547
548
549
# File 'lib/macho/load_commands.rb', line 547

def name
  @name
end

#timestampInteger (readonly)

Returns the library's build time stamp.

Returns:

  • (Integer)

    the library's build time stamp



550
551
552
# File 'lib/macho/load_commands.rb', line 550

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



580
581
582
583
584
585
586
587
588
# File 'lib/macho/load_commands.rb', line 580

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], timestamp, current_version,
   compatibility_version].pack(format) + string_payload
end

#to_hHash

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

Returns:



591
592
593
594
595
596
597
598
# File 'lib/macho/load_commands.rb', line 591

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