Class: MachO::LoadCommands::BuildVersionCommand

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

Overview

A load command containing the minimum OS version on which the binary was built for its platform. Corresponds to LC_BUILD_VERSION.

Defined Under Namespace

Classes: ToolEntries

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?, #serialize, #to_s, #type

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(view, cmd, cmdsize, platform, minos, sdk, ntools) ⇒ BuildVersionCommand

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



1383
1384
1385
1386
1387
1388
1389
# File 'lib/macho/load_commands.rb', line 1383

def initialize(view, cmd, cmdsize, platform, minos, sdk, ntools)
  super(view, cmd, cmdsize)
  @platform = platform
  @minos = minos
  @sdk = sdk
  @tool_entries = ToolEntries.new(view, ntools)
end

Instance Attribute Details

#minosInteger (readonly)

Returns the minimum OS version X.Y.Z packed as x16.y8.z8.

Returns:

  • (Integer)

    the minimum OS version X.Y.Z packed as x16.y8.z8



1366
1367
1368
# File 'lib/macho/load_commands.rb', line 1366

def minos
  @minos
end

#platformInteger (readonly)

Returns:

  • (Integer)


1363
1364
1365
# File 'lib/macho/load_commands.rb', line 1363

def platform
  @platform
end

#sdkInteger (readonly)

Returns the SDK version X.Y.Z packed as x16.y8.z8.

Returns:

  • (Integer)

    the SDK version X.Y.Z packed as x16.y8.z8



1369
1370
1371
# File 'lib/macho/load_commands.rb', line 1369

def sdk
  @sdk
end

#tool_entriesToolEntries (readonly)

Returns tool entries.

Returns:



1372
1373
1374
# File 'lib/macho/load_commands.rb', line 1372

def tool_entries
  @tool_entries
end

Instance Method Details

#minos_stringString

A string representation of the binary's minimum OS version.

Returns:

  • (String)

    a string representing the minimum OS version.



1393
1394
1395
1396
1397
1398
1399
1400
# File 'lib/macho/load_commands.rb', line 1393

def minos_string
  binary = "%032<minos>b" % { :minos => minos }
  segs = [
    binary[0..15], binary[16..23], binary[24..31]
  ].map { |s| s.to_i(2) }

  segs.join(".")
end

#sdk_stringString

A string representation of the binary's SDK version.

Returns:

  • (String)

    a string representing the SDK version.



1404
1405
1406
1407
1408
1409
1410
1411
# File 'lib/macho/load_commands.rb', line 1404

def sdk_string
  binary = "%032<sdk>b" % { :sdk => sdk }
  segs = [
    binary[0..15], binary[16..23], binary[24..31]
  ].map { |s| s.to_i(2) }

  segs.join(".")
end

#to_hHash

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

Returns:



1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
# File 'lib/macho/load_commands.rb', line 1414

def to_h
  {
    "platform" => platform,
    "minos" => minos,
    "minos_string" => minos_string,
    "sdk" => sdk,
    "sdk_string" => sdk_string,
    "tool_entries" => tool_entries.tools.map(&:to_h),
  }.merge super
end