class MachO::LoadCommands::DylibUseCommand
The newer format of load command representing some aspect of shared libraries, depending on filetype. Corresponds to LC_LOAD_DYLIB or LC_LOAD_WEAK_DYLIB.
Public Class Methods
Instantiates a new DylibCommand
or DylibUseCommand
. macOS 15 and later use a new format for dylib commands (DylibUseCommand
), which is determined based on a special timestamp and the name offset. @param view [MachO::MachOView] the load command’s raw view @return [DylibCommand] the new dylib load command @api private
MachO::LoadCommands::LoadCommand::new_from_bin
# File lib/macho/load_commands.rb, line 608 def self.new_from_bin(view) dylib_command = DylibCommand.new_from_bin(view) if dylib_command.timestamp == DYLIB_USE_MARKER && dylib_command.name.to_i == DylibUseCommand.bytesize super(view) else dylib_command end end
Public Instance Methods
@example
puts "this dylib is weakly loaded" if dylib_command.flag?(:DYLIB_USE_WEAK_LINK)
@param flag [Symbol] a dylib use command flag symbol @return [Boolean] true if ‘flag` applies to this dylib command
# File lib/macho/load_commands.rb, line 623 def flag?(flag) flag = DYLIB_USE_FLAGS[flag] return false if flag.nil? flags & flag == flag end
@param context [SerializationContext]
the context
@return [String] the serialized fields of the load command @api private
# File lib/macho/load_commands.rb, line 635 def serialize(context) format = Utils.specialize_format(self.class.format, context.endianness) string_payload, string_offsets = Utils.pack_strings(self.class.bytesize, context.alignment, :name => name.to_s) cmdsize = self.class.bytesize + string_payload.bytesize [cmd, cmdsize, string_offsets[:name], marker, current_version, compatibility_version, flags].pack(format) + string_payload end
@return [Hash] a hash representation of this {DylibUseCommand}
MachO::LoadCommands::DylibCommand#to_h
# File lib/macho/load_commands.rb, line 646 def to_h { "flags" => flags, }.merge super end