Merge pull request #4285 from woodruffw/ruby-macho-1.2.0
vendor: Update ruby-macho to 1.2.0
This commit is contained in:
commit
e78158a4f1
4
Library/Homebrew/vendor/README.md
vendored
4
Library/Homebrew/vendor/README.md
vendored
@ -3,7 +3,7 @@ Vendored Dependencies
|
|||||||
|
|
||||||
* [plist](https://github.com/patsplat/plist), version 3.3.0
|
* [plist](https://github.com/patsplat/plist), version 3.3.0
|
||||||
|
|
||||||
* [ruby-macho](https://github.com/Homebrew/ruby-macho), version 1.1.0
|
* [ruby-macho](https://github.com/Homebrew/ruby-macho), version 1.2.0
|
||||||
|
|
||||||
* [backports](https://github.com/marcandre/backports), version 3.8.0
|
* [backports](https://github.com/marcandre/backports), version 3.8.0
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ Vendored Dependencies
|
|||||||
### ruby-macho
|
### ruby-macho
|
||||||
|
|
||||||
> The MIT License
|
> The MIT License
|
||||||
> Copyright (c) 2015, 2016, 2017 William Woodruff <william @ tuffbizz.com>
|
> Copyright (c) 2015, 2016, 2017, 2018 William Woodruff <william @ yossarian.net>
|
||||||
>
|
>
|
||||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
> of this software and associated documentation files (the "Software"), to deal
|
> of this software and associated documentation files (the "Software"), to deal
|
||||||
|
2
Library/Homebrew/vendor/macho/macho.rb
vendored
2
Library/Homebrew/vendor/macho/macho.rb
vendored
@ -12,7 +12,7 @@ require "#{File.dirname(__FILE__)}/macho/tools"
|
|||||||
# The primary namespace for ruby-macho.
|
# The primary namespace for ruby-macho.
|
||||||
module MachO
|
module MachO
|
||||||
# release version
|
# release version
|
||||||
VERSION = "1.1.0".freeze
|
VERSION = "1.2.0".freeze
|
||||||
|
|
||||||
# Opens the given filename as a MachOFile or FatFile, depending on its magic.
|
# Opens the given filename as a MachOFile or FatFile, depending on its magic.
|
||||||
# @param filename [String] the file being opened
|
# @param filename [String] the file being opened
|
||||||
|
@ -10,7 +10,7 @@ module MachO
|
|||||||
# Raised when a Mach-O file modification fails but can be recovered when
|
# Raised when a Mach-O file modification fails but can be recovered when
|
||||||
# operating on multiple Mach-O slices of a fat binary in non-strict mode.
|
# operating on multiple Mach-O slices of a fat binary in non-strict mode.
|
||||||
class RecoverableModificationError < ModificationError
|
class RecoverableModificationError < ModificationError
|
||||||
# @return [Fixnum, nil] The index of the Mach-O slice of a fat binary for
|
# @return [Integer, nil] The index of the Mach-O slice of a fat binary for
|
||||||
# which modification failed or `nil` if not a fat binary. This is used to
|
# which modification failed or `nil` if not a fat binary. This is used to
|
||||||
# make the error message more useful.
|
# make the error message more useful.
|
||||||
attr_accessor :macho_slice
|
attr_accessor :macho_slice
|
||||||
@ -40,7 +40,7 @@ module MachO
|
|||||||
|
|
||||||
# Raised when a file's magic bytes are not valid Mach-O magic.
|
# Raised when a file's magic bytes are not valid Mach-O magic.
|
||||||
class MagicError < NotAMachOError
|
class MagicError < NotAMachOError
|
||||||
# @param num [Fixnum] the unknown number
|
# @param num [Integer] the unknown number
|
||||||
def initialize(num)
|
def initialize(num)
|
||||||
super "Unrecognized Mach-O magic: 0x#{"%02x" % num}"
|
super "Unrecognized Mach-O magic: 0x#{"%02x" % num}"
|
||||||
end
|
end
|
||||||
@ -69,7 +69,7 @@ module MachO
|
|||||||
|
|
||||||
# Raised when the CPU type is unknown.
|
# Raised when the CPU type is unknown.
|
||||||
class CPUTypeError < MachOError
|
class CPUTypeError < MachOError
|
||||||
# @param cputype [Fixnum] the unknown CPU type
|
# @param cputype [Integer] the unknown CPU type
|
||||||
def initialize(cputype)
|
def initialize(cputype)
|
||||||
super "Unrecognized CPU type: 0x#{"%08x" % cputype}"
|
super "Unrecognized CPU type: 0x#{"%08x" % cputype}"
|
||||||
end
|
end
|
||||||
@ -77,8 +77,8 @@ module MachO
|
|||||||
|
|
||||||
# Raised when the CPU type/sub-type pair is unknown.
|
# Raised when the CPU type/sub-type pair is unknown.
|
||||||
class CPUSubtypeError < MachOError
|
class CPUSubtypeError < MachOError
|
||||||
# @param cputype [Fixnum] the CPU type of the unknown pair
|
# @param cputype [Integer] the CPU type of the unknown pair
|
||||||
# @param cpusubtype [Fixnum] the CPU sub-type of the unknown pair
|
# @param cpusubtype [Integer] the CPU sub-type of the unknown pair
|
||||||
def initialize(cputype, cpusubtype)
|
def initialize(cputype, cpusubtype)
|
||||||
super "Unrecognized CPU sub-type: 0x#{"%08x" % cpusubtype}" \
|
super "Unrecognized CPU sub-type: 0x#{"%08x" % cpusubtype}" \
|
||||||
" (for CPU type: 0x#{"%08x" % cputype})"
|
" (for CPU type: 0x#{"%08x" % cputype})"
|
||||||
@ -87,7 +87,7 @@ module MachO
|
|||||||
|
|
||||||
# Raised when a mach-o file's filetype field is unknown.
|
# Raised when a mach-o file's filetype field is unknown.
|
||||||
class FiletypeError < MachOError
|
class FiletypeError < MachOError
|
||||||
# @param num [Fixnum] the unknown number
|
# @param num [Integer] the unknown number
|
||||||
def initialize(num)
|
def initialize(num)
|
||||||
super "Unrecognized Mach-O filetype code: 0x#{"%02x" % num}"
|
super "Unrecognized Mach-O filetype code: 0x#{"%02x" % num}"
|
||||||
end
|
end
|
||||||
@ -95,7 +95,7 @@ module MachO
|
|||||||
|
|
||||||
# Raised when an unknown load command is encountered.
|
# Raised when an unknown load command is encountered.
|
||||||
class LoadCommandError < MachOError
|
class LoadCommandError < MachOError
|
||||||
# @param num [Fixnum] the unknown number
|
# @param num [Integer] the unknown number
|
||||||
def initialize(num)
|
def initialize(num)
|
||||||
super "Unrecognized Mach-O load command: 0x#{"%02x" % num}"
|
super "Unrecognized Mach-O load command: 0x#{"%02x" % num}"
|
||||||
end
|
end
|
||||||
@ -113,8 +113,8 @@ module MachO
|
|||||||
# is wrong.
|
# is wrong.
|
||||||
class LoadCommandCreationArityError < MachOError
|
class LoadCommandCreationArityError < MachOError
|
||||||
# @param cmd_sym [Symbol] the load command's symbol
|
# @param cmd_sym [Symbol] the load command's symbol
|
||||||
# @param expected_arity [Fixnum] the number of arguments expected
|
# @param expected_arity [Integer] the number of arguments expected
|
||||||
# @param actual_arity [Fixnum] the number of arguments received
|
# @param actual_arity [Integer] the number of arguments received
|
||||||
def initialize(cmd_sym, expected_arity, actual_arity)
|
def initialize(cmd_sym, expected_arity, actual_arity)
|
||||||
super "Expected #{expected_arity} arguments for #{cmd_sym} creation," \
|
super "Expected #{expected_arity} arguments for #{cmd_sym} creation," \
|
||||||
" got #{actual_arity}"
|
" got #{actual_arity}"
|
||||||
@ -140,7 +140,7 @@ module MachO
|
|||||||
|
|
||||||
# Raised when a change at an offset is not valid.
|
# Raised when a change at an offset is not valid.
|
||||||
class OffsetInsertionError < ModificationError
|
class OffsetInsertionError < ModificationError
|
||||||
# @param offset [Fixnum] the invalid offset
|
# @param offset [Integer] the invalid offset
|
||||||
def initialize(offset)
|
def initialize(offset)
|
||||||
super "Insertion at offset #{offset} is not valid"
|
super "Insertion at offset #{offset} is not valid"
|
||||||
end
|
end
|
||||||
|
@ -261,11 +261,8 @@ module MachO
|
|||||||
# @raise [MachOError] if the instance was initialized without a file
|
# @raise [MachOError] if the instance was initialized without a file
|
||||||
# @note Overwrites all data in the file!
|
# @note Overwrites all data in the file!
|
||||||
def write!
|
def write!
|
||||||
if filename.nil?
|
raise MachOError, "no initial file to write to" if filename.nil?
|
||||||
raise MachOError, "cannot write to a default file when initialized from a binary string"
|
File.open(@filename, "wb") { |f| f.write(@raw_data) }
|
||||||
else
|
|
||||||
File.open(@filename, "wb") { |f| f.write(@raw_data) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
30
Library/Homebrew/vendor/macho/macho/headers.rb
vendored
30
Library/Homebrew/vendor/macho/macho/headers.rb
vendored
@ -450,10 +450,10 @@ module MachO
|
|||||||
# Fat binary header structure
|
# Fat binary header structure
|
||||||
# @see MachO::FatArch
|
# @see MachO::FatArch
|
||||||
class FatHeader < MachOStructure
|
class FatHeader < MachOStructure
|
||||||
# @return [Fixnum] the magic number of the header (and file)
|
# @return [Integer] the magic number of the header (and file)
|
||||||
attr_reader :magic
|
attr_reader :magic
|
||||||
|
|
||||||
# @return [Fixnum] the number of fat architecture structures following the header
|
# @return [Integer] the number of fat architecture structures following the header
|
||||||
attr_reader :nfat_arch
|
attr_reader :nfat_arch
|
||||||
|
|
||||||
# always big-endian
|
# always big-endian
|
||||||
@ -481,19 +481,19 @@ module MachO
|
|||||||
# these, representing one or more internal Mach-O blobs.
|
# these, representing one or more internal Mach-O blobs.
|
||||||
# @see MachO::Headers::FatHeader
|
# @see MachO::Headers::FatHeader
|
||||||
class FatArch < MachOStructure
|
class FatArch < MachOStructure
|
||||||
# @return [Fixnum] the CPU type of the Mach-O
|
# @return [Integer] the CPU type of the Mach-O
|
||||||
attr_reader :cputype
|
attr_reader :cputype
|
||||||
|
|
||||||
# @return [Fixnum] the CPU subtype of the Mach-O
|
# @return [Integer] the CPU subtype of the Mach-O
|
||||||
attr_reader :cpusubtype
|
attr_reader :cpusubtype
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the beginning of the Mach-O data
|
# @return [Integer] the file offset to the beginning of the Mach-O data
|
||||||
attr_reader :offset
|
attr_reader :offset
|
||||||
|
|
||||||
# @return [Fixnum] the size, in bytes, of the Mach-O data
|
# @return [Integer] the size, in bytes, of the Mach-O data
|
||||||
attr_reader :size
|
attr_reader :size
|
||||||
|
|
||||||
# @return [Fixnum] the alignment, as a power of 2
|
# @return [Integer] the alignment, as a power of 2
|
||||||
attr_reader :align
|
attr_reader :align
|
||||||
|
|
||||||
# always big-endian
|
# always big-endian
|
||||||
@ -522,25 +522,25 @@ module MachO
|
|||||||
|
|
||||||
# 32-bit Mach-O file header structure
|
# 32-bit Mach-O file header structure
|
||||||
class MachHeader < MachOStructure
|
class MachHeader < MachOStructure
|
||||||
# @return [Fixnum] the magic number
|
# @return [Integer] the magic number
|
||||||
attr_reader :magic
|
attr_reader :magic
|
||||||
|
|
||||||
# @return [Fixnum] the CPU type of the Mach-O
|
# @return [Integer] the CPU type of the Mach-O
|
||||||
attr_reader :cputype
|
attr_reader :cputype
|
||||||
|
|
||||||
# @return [Fixnum] the CPU subtype of the Mach-O
|
# @return [Integer] the CPU subtype of the Mach-O
|
||||||
attr_reader :cpusubtype
|
attr_reader :cpusubtype
|
||||||
|
|
||||||
# @return [Fixnum] the file type of the Mach-O
|
# @return [Integer] the file type of the Mach-O
|
||||||
attr_reader :filetype
|
attr_reader :filetype
|
||||||
|
|
||||||
# @return [Fixnum] the number of load commands in the Mach-O
|
# @return [Integer] the number of load commands in the Mach-O
|
||||||
attr_reader :ncmds
|
attr_reader :ncmds
|
||||||
|
|
||||||
# @return [Fixnum] the size of all load commands, in bytes, in the Mach-O
|
# @return [Integer] the size of all load commands, in bytes, in the Mach-O
|
||||||
attr_reader :sizeofcmds
|
attr_reader :sizeofcmds
|
||||||
|
|
||||||
# @return [Fixnum] the header flags associated with the Mach-O
|
# @return [Integer] the header flags associated with the Mach-O
|
||||||
attr_reader :flags
|
attr_reader :flags
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -635,7 +635,7 @@ module MachO
|
|||||||
Utils.magic64?(magic)
|
Utils.magic64?(magic)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Fixnum] the file's internal alignment
|
# @return [Integer] the file's internal alignment
|
||||||
def alignment
|
def alignment
|
||||||
magic32? ? 4 : 8
|
magic32? ? 4 : 8
|
||||||
end
|
end
|
||||||
|
281
Library/Homebrew/vendor/macho/macho/load_commands.rb
vendored
281
Library/Homebrew/vendor/macho/macho/load_commands.rb
vendored
@ -58,6 +58,8 @@ module MachO
|
|||||||
0x2e => :LC_LINKER_OPTIMIZATION_HINT,
|
0x2e => :LC_LINKER_OPTIMIZATION_HINT,
|
||||||
0x2f => :LC_VERSION_MIN_TVOS,
|
0x2f => :LC_VERSION_MIN_TVOS,
|
||||||
0x30 => :LC_VERSION_MIN_WATCHOS,
|
0x30 => :LC_VERSION_MIN_WATCHOS,
|
||||||
|
0x31 => :LC_NOTE,
|
||||||
|
0x32 => :LC_BUILD_VERSION,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# association of symbol representations to load command constants
|
# association of symbol representations to load command constants
|
||||||
@ -66,20 +68,20 @@ module MachO
|
|||||||
|
|
||||||
# load commands responsible for loading dylibs
|
# load commands responsible for loading dylibs
|
||||||
# @api private
|
# @api private
|
||||||
DYLIB_LOAD_COMMANDS = [
|
DYLIB_LOAD_COMMANDS = %i[
|
||||||
:LC_LOAD_DYLIB,
|
LC_LOAD_DYLIB
|
||||||
:LC_LOAD_WEAK_DYLIB,
|
LC_LOAD_WEAK_DYLIB
|
||||||
:LC_REEXPORT_DYLIB,
|
LC_REEXPORT_DYLIB
|
||||||
:LC_LAZY_LOAD_DYLIB,
|
LC_LAZY_LOAD_DYLIB
|
||||||
:LC_LOAD_UPWARD_DYLIB,
|
LC_LOAD_UPWARD_DYLIB
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# load commands that can be created manually via {LoadCommand.create}
|
# load commands that can be created manually via {LoadCommand.create}
|
||||||
# @api private
|
# @api private
|
||||||
CREATABLE_LOAD_COMMANDS = DYLIB_LOAD_COMMANDS + [
|
CREATABLE_LOAD_COMMANDS = DYLIB_LOAD_COMMANDS + %i[
|
||||||
:LC_ID_DYLIB,
|
LC_ID_DYLIB
|
||||||
:LC_RPATH,
|
LC_RPATH
|
||||||
:LC_LOAD_DYLINKER,
|
LC_LOAD_DYLINKER
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# association of load command symbols to string representations of classes
|
# association of load command symbols to string representations of classes
|
||||||
@ -141,6 +143,8 @@ module MachO
|
|||||||
:LC_LINKER_OPTIMIZATION_HINT => "LinkeditDataCommand",
|
:LC_LINKER_OPTIMIZATION_HINT => "LinkeditDataCommand",
|
||||||
:LC_VERSION_MIN_TVOS => "VersionMinCommand",
|
:LC_VERSION_MIN_TVOS => "VersionMinCommand",
|
||||||
:LC_VERSION_MIN_WATCHOS => "VersionMinCommand",
|
:LC_VERSION_MIN_WATCHOS => "VersionMinCommand",
|
||||||
|
:LC_NOTE => "LoadCommand",
|
||||||
|
:LC_BUILD_VERSION => "BuildVersionCommand",
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# association of segment name symbols to names
|
# association of segment name symbols to names
|
||||||
@ -173,10 +177,10 @@ module MachO
|
|||||||
# @return [MachO::MachOView] the raw view associated with the load command
|
# @return [MachO::MachOView] the raw view associated with the load command
|
||||||
attr_reader :view
|
attr_reader :view
|
||||||
|
|
||||||
# @return [Fixnum] the load command's identifying number
|
# @return [Integer] the load command's identifying number
|
||||||
attr_reader :cmd
|
attr_reader :cmd
|
||||||
|
|
||||||
# @return [Fixnum] the size of the load command, in bytes
|
# @return [Integer] the size of the load command, in bytes
|
||||||
attr_reader :cmdsize
|
attr_reader :cmdsize
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -216,8 +220,8 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @param view [MachO::MachOView] the load command's raw view
|
# @param view [MachO::MachOView] the load command's raw view
|
||||||
# @param cmd [Fixnum] the load command's identifying number
|
# @param cmd [Integer] the load command's identifying number
|
||||||
# @param cmdsize [Fixnum] the size of the load command in bytes
|
# @param cmdsize [Integer] the size of the load command in bytes
|
||||||
# @api private
|
# @api private
|
||||||
def initialize(view, cmd, cmdsize)
|
def initialize(view, cmd, cmdsize)
|
||||||
@view = view
|
@view = view
|
||||||
@ -241,7 +245,7 @@ module MachO
|
|||||||
[cmd, SIZEOF].pack(format)
|
[cmd, SIZEOF].pack(format)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Fixnum] the load command's offset in the source file
|
# @return [Integer] the load command's offset in the source file
|
||||||
# @deprecated use {#view} instead
|
# @deprecated use {#view} instead
|
||||||
def offset
|
def offset
|
||||||
view.offset
|
view.offset
|
||||||
@ -267,7 +271,7 @@ module MachO
|
|||||||
# explicit operations on the raw Mach-O data.
|
# explicit operations on the raw Mach-O data.
|
||||||
class LCStr
|
class LCStr
|
||||||
# @param lc [LoadCommand] the load command
|
# @param lc [LoadCommand] the load command
|
||||||
# @param lc_str [Fixnum, String] the offset to the beginning of the
|
# @param lc_str [Integer, String] the offset to the beginning of the
|
||||||
# string, or the string itself if not being initialized with a view.
|
# string, or the string itself if not being initialized with a view.
|
||||||
# @raise [MachO::LCStrMalformedError] if the string is malformed
|
# @raise [MachO::LCStrMalformedError] if the string is malformed
|
||||||
# @todo devise a solution such that the `lc_str` parameter is not
|
# @todo devise a solution such that the `lc_str` parameter is not
|
||||||
@ -295,7 +299,7 @@ module MachO
|
|||||||
@string
|
@string
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Fixnum] the offset to the beginning of the string in the
|
# @return [Integer] the offset to the beginning of the string in the
|
||||||
# load command
|
# load command
|
||||||
def to_i
|
def to_i
|
||||||
@string_offset
|
@string_offset
|
||||||
@ -308,7 +312,7 @@ module MachO
|
|||||||
# @return [Symbol] the endianness of the serialized load command
|
# @return [Symbol] the endianness of the serialized load command
|
||||||
attr_reader :endianness
|
attr_reader :endianness
|
||||||
|
|
||||||
# @return [Fixnum] the constant alignment value used to pad the
|
# @return [Integer] the constant alignment value used to pad the
|
||||||
# serialized load command
|
# serialized load command
|
||||||
attr_reader :alignment
|
attr_reader :alignment
|
||||||
|
|
||||||
@ -320,7 +324,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @param endianness [Symbol] the endianness of the context
|
# @param endianness [Symbol] the endianness of the context
|
||||||
# @param alignment [Fixnum] the alignment of the context
|
# @param alignment [Integer] the alignment of the context
|
||||||
# @api private
|
# @api private
|
||||||
def initialize(endianness, alignment)
|
def initialize(endianness, alignment)
|
||||||
@endianness = endianness
|
@endianness = endianness
|
||||||
@ -333,7 +337,7 @@ module MachO
|
|||||||
# identifying an object produced by static link editor. Corresponds to
|
# identifying an object produced by static link editor. Corresponds to
|
||||||
# LC_UUID.
|
# LC_UUID.
|
||||||
class UUIDCommand < LoadCommand
|
class UUIDCommand < LoadCommand
|
||||||
# @return [Array<Fixnum>] the UUID
|
# @return [Array<Integer>] the UUID
|
||||||
attr_reader :uuid
|
attr_reader :uuid
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -368,28 +372,28 @@ module MachO
|
|||||||
# @return [String] the name of the segment
|
# @return [String] the name of the segment
|
||||||
attr_reader :segname
|
attr_reader :segname
|
||||||
|
|
||||||
# @return [Fixnum] the memory address of the segment
|
# @return [Integer] the memory address of the segment
|
||||||
attr_reader :vmaddr
|
attr_reader :vmaddr
|
||||||
|
|
||||||
# @return [Fixnum] the memory size of the segment
|
# @return [Integer] the memory size of the segment
|
||||||
attr_reader :vmsize
|
attr_reader :vmsize
|
||||||
|
|
||||||
# @return [Fixnum] the file offset of the segment
|
# @return [Integer] the file offset of the segment
|
||||||
attr_reader :fileoff
|
attr_reader :fileoff
|
||||||
|
|
||||||
# @return [Fixnum] the amount to map from the file
|
# @return [Integer] the amount to map from the file
|
||||||
attr_reader :filesize
|
attr_reader :filesize
|
||||||
|
|
||||||
# @return [Fixnum] the maximum VM protection
|
# @return [Integer] the maximum VM protection
|
||||||
attr_reader :maxprot
|
attr_reader :maxprot
|
||||||
|
|
||||||
# @return [Fixnum] the initial VM protection
|
# @return [Integer] the initial VM protection
|
||||||
attr_reader :initprot
|
attr_reader :initprot
|
||||||
|
|
||||||
# @return [Fixnum] the number of sections in the segment
|
# @return [Integer] the number of sections in the segment
|
||||||
attr_reader :nsects
|
attr_reader :nsects
|
||||||
|
|
||||||
# @return [Fixnum] any flags associated with the segment
|
# @return [Integer] any flags associated with the segment
|
||||||
attr_reader :flags
|
attr_reader :flags
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -466,13 +470,13 @@ module MachO
|
|||||||
# name as an LCStr
|
# name as an LCStr
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
# @return [Fixnum] the library's build time stamp
|
# @return [Integer] the library's build time stamp
|
||||||
attr_reader :timestamp
|
attr_reader :timestamp
|
||||||
|
|
||||||
# @return [Fixnum] the library's current version number
|
# @return [Integer] the library's current version number
|
||||||
attr_reader :current_version
|
attr_reader :current_version
|
||||||
|
|
||||||
# @return [Fixnum] the library's compatibility version number
|
# @return [Integer] the library's compatibility version number
|
||||||
attr_reader :compatibility_version
|
attr_reader :compatibility_version
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -551,10 +555,10 @@ module MachO
|
|||||||
# name as an LCStr
|
# name as an LCStr
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
# @return [Fixnum] the number of modules in the library
|
# @return [Integer] the number of modules in the library
|
||||||
attr_reader :nmodules
|
attr_reader :nmodules
|
||||||
|
|
||||||
# @return [Fixnum] a bit vector of linked modules
|
# @return [Integer] a bit vector of linked modules
|
||||||
attr_reader :linked_modules
|
attr_reader :linked_modules
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -591,10 +595,10 @@ module MachO
|
|||||||
# initialization routine and an index into the module table for the module
|
# initialization routine and an index into the module table for the module
|
||||||
# that defines the routine. Corresponds to LC_ROUTINES.
|
# that defines the routine. Corresponds to LC_ROUTINES.
|
||||||
class RoutinesCommand < LoadCommand
|
class RoutinesCommand < LoadCommand
|
||||||
# @return [Fixnum] the address of the initialization routine
|
# @return [Integer] the address of the initialization routine
|
||||||
attr_reader :init_address
|
attr_reader :init_address
|
||||||
|
|
||||||
# @return [Fixnum] the index into the module table that the init routine
|
# @return [Integer] the index into the module table that the init routine
|
||||||
# is defined in
|
# is defined in
|
||||||
attr_reader :init_module
|
attr_reader :init_module
|
||||||
|
|
||||||
@ -739,10 +743,10 @@ module MachO
|
|||||||
# A load command containing the offsets and sizes of the link-edit 4.3BSD
|
# A load command containing the offsets and sizes of the link-edit 4.3BSD
|
||||||
# "stab" style symbol table information. Corresponds to LC_SYMTAB.
|
# "stab" style symbol table information. Corresponds to LC_SYMTAB.
|
||||||
class SymtabCommand < LoadCommand
|
class SymtabCommand < LoadCommand
|
||||||
# @return [Fixnum] the symbol table's offset
|
# @return [Integer] the symbol table's offset
|
||||||
attr_reader :symoff
|
attr_reader :symoff
|
||||||
|
|
||||||
# @return [Fixnum] the number of symbol table entries
|
# @return [Integer] the number of symbol table entries
|
||||||
attr_reader :nsyms
|
attr_reader :nsyms
|
||||||
|
|
||||||
# @return the string table's offset
|
# @return the string table's offset
|
||||||
@ -772,58 +776,58 @@ module MachO
|
|||||||
# A load command containing symbolic information needed to support data
|
# A load command containing symbolic information needed to support data
|
||||||
# structures used by the dynamic link editor. Corresponds to LC_DYSYMTAB.
|
# structures used by the dynamic link editor. Corresponds to LC_DYSYMTAB.
|
||||||
class DysymtabCommand < LoadCommand
|
class DysymtabCommand < LoadCommand
|
||||||
# @return [Fixnum] the index to local symbols
|
# @return [Integer] the index to local symbols
|
||||||
attr_reader :ilocalsym
|
attr_reader :ilocalsym
|
||||||
|
|
||||||
# @return [Fixnum] the number of local symbols
|
# @return [Integer] the number of local symbols
|
||||||
attr_reader :nlocalsym
|
attr_reader :nlocalsym
|
||||||
|
|
||||||
# @return [Fixnum] the index to externally defined symbols
|
# @return [Integer] the index to externally defined symbols
|
||||||
attr_reader :iextdefsym
|
attr_reader :iextdefsym
|
||||||
|
|
||||||
# @return [Fixnum] the number of externally defined symbols
|
# @return [Integer] the number of externally defined symbols
|
||||||
attr_reader :nextdefsym
|
attr_reader :nextdefsym
|
||||||
|
|
||||||
# @return [Fixnum] the index to undefined symbols
|
# @return [Integer] the index to undefined symbols
|
||||||
attr_reader :iundefsym
|
attr_reader :iundefsym
|
||||||
|
|
||||||
# @return [Fixnum] the number of undefined symbols
|
# @return [Integer] the number of undefined symbols
|
||||||
attr_reader :nundefsym
|
attr_reader :nundefsym
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the table of contents
|
# @return [Integer] the file offset to the table of contents
|
||||||
attr_reader :tocoff
|
attr_reader :tocoff
|
||||||
|
|
||||||
# @return [Fixnum] the number of entries in the table of contents
|
# @return [Integer] the number of entries in the table of contents
|
||||||
attr_reader :ntoc
|
attr_reader :ntoc
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the module table
|
# @return [Integer] the file offset to the module table
|
||||||
attr_reader :modtaboff
|
attr_reader :modtaboff
|
||||||
|
|
||||||
# @return [Fixnum] the number of entries in the module table
|
# @return [Integer] the number of entries in the module table
|
||||||
attr_reader :nmodtab
|
attr_reader :nmodtab
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the referenced symbol table
|
# @return [Integer] the file offset to the referenced symbol table
|
||||||
attr_reader :extrefsymoff
|
attr_reader :extrefsymoff
|
||||||
|
|
||||||
# @return [Fixnum] the number of entries in the referenced symbol table
|
# @return [Integer] the number of entries in the referenced symbol table
|
||||||
attr_reader :nextrefsyms
|
attr_reader :nextrefsyms
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the indirect symbol table
|
# @return [Integer] the file offset to the indirect symbol table
|
||||||
attr_reader :indirectsymoff
|
attr_reader :indirectsymoff
|
||||||
|
|
||||||
# @return [Fixnum] the number of entries in the indirect symbol table
|
# @return [Integer] the number of entries in the indirect symbol table
|
||||||
attr_reader :nindirectsyms
|
attr_reader :nindirectsyms
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the external relocation entries
|
# @return [Integer] the file offset to the external relocation entries
|
||||||
attr_reader :extreloff
|
attr_reader :extreloff
|
||||||
|
|
||||||
# @return [Fixnum] the number of external relocation entries
|
# @return [Integer] the number of external relocation entries
|
||||||
attr_reader :nextrel
|
attr_reader :nextrel
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the local relocation entries
|
# @return [Integer] the file offset to the local relocation entries
|
||||||
attr_reader :locreloff
|
attr_reader :locreloff
|
||||||
|
|
||||||
# @return [Fixnum] the number of local relocation entries
|
# @return [Integer] the number of local relocation entries
|
||||||
attr_reader :nlocrel
|
attr_reader :nlocrel
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -865,10 +869,10 @@ module MachO
|
|||||||
# A load command containing the offset and number of hints in the two-level
|
# A load command containing the offset and number of hints in the two-level
|
||||||
# namespace lookup hints table. Corresponds to LC_TWOLEVEL_HINTS.
|
# namespace lookup hints table. Corresponds to LC_TWOLEVEL_HINTS.
|
||||||
class TwolevelHintsCommand < LoadCommand
|
class TwolevelHintsCommand < LoadCommand
|
||||||
# @return [Fixnum] the offset to the hint table
|
# @return [Integer] the offset to the hint table
|
||||||
attr_reader :htoffset
|
attr_reader :htoffset
|
||||||
|
|
||||||
# @return [Fixnum] the number of hints in the hint table
|
# @return [Integer] the number of hints in the hint table
|
||||||
attr_reader :nhints
|
attr_reader :nhints
|
||||||
|
|
||||||
# @return [TwolevelHintsTable]
|
# @return [TwolevelHintsTable]
|
||||||
@ -898,8 +902,8 @@ module MachO
|
|||||||
attr_reader :hints
|
attr_reader :hints
|
||||||
|
|
||||||
# @param view [MachO::MachOView] the view into the current Mach-O
|
# @param view [MachO::MachOView] the view into the current Mach-O
|
||||||
# @param htoffset [Fixnum] the offset of the hints table
|
# @param htoffset [Integer] the offset of the hints table
|
||||||
# @param nhints [Fixnum] the number of two-level hints in the table
|
# @param nhints [Integer] the number of two-level hints in the table
|
||||||
# @api private
|
# @api private
|
||||||
def initialize(view, htoffset, nhints)
|
def initialize(view, htoffset, nhints)
|
||||||
format = Utils.specialize_format("L=#{nhints}", view.endianness)
|
format = Utils.specialize_format("L=#{nhints}", view.endianness)
|
||||||
@ -911,13 +915,13 @@ module MachO
|
|||||||
|
|
||||||
# An individual two-level namespace lookup hint.
|
# An individual two-level namespace lookup hint.
|
||||||
class TwolevelHint
|
class TwolevelHint
|
||||||
# @return [Fixnum] the index into the sub-images
|
# @return [Integer] the index into the sub-images
|
||||||
attr_reader :isub_image
|
attr_reader :isub_image
|
||||||
|
|
||||||
# @return [Fixnum] the index into the table of contents
|
# @return [Integer] the index into the table of contents
|
||||||
attr_reader :itoc
|
attr_reader :itoc
|
||||||
|
|
||||||
# @param blob [Fixnum] the 32-bit number containing the lookup hint
|
# @param blob [Integer] the 32-bit number containing the lookup hint
|
||||||
# @api private
|
# @api private
|
||||||
def initialize(blob)
|
def initialize(blob)
|
||||||
@isub_image = blob >> 24
|
@isub_image = blob >> 24
|
||||||
@ -930,7 +934,7 @@ module MachO
|
|||||||
# A load command containing the value of the original checksum for prebound
|
# A load command containing the value of the original checksum for prebound
|
||||||
# files, or zero. Corresponds to LC_PREBIND_CKSUM.
|
# files, or zero. Corresponds to LC_PREBIND_CKSUM.
|
||||||
class PrebindCksumCommand < LoadCommand
|
class PrebindCksumCommand < LoadCommand
|
||||||
# @return [Fixnum] the checksum or 0
|
# @return [Integer] the checksum or 0
|
||||||
attr_reader :cksum
|
attr_reader :cksum
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -987,10 +991,10 @@ module MachO
|
|||||||
# LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE,
|
# LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE,
|
||||||
# LC_DYLIB_CODE_SIGN_DRS, and LC_LINKER_OPTIMIZATION_HINT.
|
# LC_DYLIB_CODE_SIGN_DRS, and LC_LINKER_OPTIMIZATION_HINT.
|
||||||
class LinkeditDataCommand < LoadCommand
|
class LinkeditDataCommand < LoadCommand
|
||||||
# @return [Fixnum] offset to the data in the __LINKEDIT segment
|
# @return [Integer] offset to the data in the __LINKEDIT segment
|
||||||
attr_reader :dataoff
|
attr_reader :dataoff
|
||||||
|
|
||||||
# @return [Fixnum] size of the data in the __LINKEDIT segment
|
# @return [Integer] size of the data in the __LINKEDIT segment
|
||||||
attr_reader :datasize
|
attr_reader :datasize
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1012,13 +1016,13 @@ module MachO
|
|||||||
# A load command representing the offset to and size of an encrypted
|
# A load command representing the offset to and size of an encrypted
|
||||||
# segment. Corresponds to LC_ENCRYPTION_INFO.
|
# segment. Corresponds to LC_ENCRYPTION_INFO.
|
||||||
class EncryptionInfoCommand < LoadCommand
|
class EncryptionInfoCommand < LoadCommand
|
||||||
# @return [Fixnum] the offset to the encrypted segment
|
# @return [Integer] the offset to the encrypted segment
|
||||||
attr_reader :cryptoff
|
attr_reader :cryptoff
|
||||||
|
|
||||||
# @return [Fixnum] the size of the encrypted segment
|
# @return [Integer] the size of the encrypted segment
|
||||||
attr_reader :cryptsize
|
attr_reader :cryptsize
|
||||||
|
|
||||||
# @return [Fixnum] the encryption system, or 0 if not encrypted yet
|
# @return [Integer] the encryption system, or 0 if not encrypted yet
|
||||||
attr_reader :cryptid
|
attr_reader :cryptid
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1041,16 +1045,16 @@ module MachO
|
|||||||
# A load command representing the offset to and size of an encrypted
|
# A load command representing the offset to and size of an encrypted
|
||||||
# segment. Corresponds to LC_ENCRYPTION_INFO_64.
|
# segment. Corresponds to LC_ENCRYPTION_INFO_64.
|
||||||
class EncryptionInfoCommand64 < LoadCommand
|
class EncryptionInfoCommand64 < LoadCommand
|
||||||
# @return [Fixnum] the offset to the encrypted segment
|
# @return [Integer] the offset to the encrypted segment
|
||||||
attr_reader :cryptoff
|
attr_reader :cryptoff
|
||||||
|
|
||||||
# @return [Fixnum] the size of the encrypted segment
|
# @return [Integer] the size of the encrypted segment
|
||||||
attr_reader :cryptsize
|
attr_reader :cryptsize
|
||||||
|
|
||||||
# @return [Fixnum] the encryption system, or 0 if not encrypted yet
|
# @return [Integer] the encryption system, or 0 if not encrypted yet
|
||||||
attr_reader :cryptid
|
attr_reader :cryptid
|
||||||
|
|
||||||
# @return [Fixnum] 64-bit padding value
|
# @return [Integer] 64-bit padding value
|
||||||
attr_reader :pad
|
attr_reader :pad
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1075,10 +1079,10 @@ module MachO
|
|||||||
# was built to run. Corresponds to LC_VERSION_MIN_MACOSX and
|
# was built to run. Corresponds to LC_VERSION_MIN_MACOSX and
|
||||||
# LC_VERSION_MIN_IPHONEOS.
|
# LC_VERSION_MIN_IPHONEOS.
|
||||||
class VersionMinCommand < LoadCommand
|
class VersionMinCommand < LoadCommand
|
||||||
# @return [Fixnum] the version X.Y.Z packed as x16.y8.z8
|
# @return [Integer] the version X.Y.Z packed as x16.y8.z8
|
||||||
attr_reader :version
|
attr_reader :version
|
||||||
|
|
||||||
# @return [Fixnum] the SDK version X.Y.Z packed as x16.y8.z8
|
# @return [Integer] the SDK version X.Y.Z packed as x16.y8.z8
|
||||||
attr_reader :sdk
|
attr_reader :sdk
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1119,38 +1123,129 @@ module MachO
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# A load command containing the minimum OS version on which
|
||||||
|
# the binary was built for its platform.
|
||||||
|
# Corresponds to LC_BUILD_VERSION.
|
||||||
|
class BuildVersionCommand < LoadCommand
|
||||||
|
# @return [Integer]
|
||||||
|
attr_reader :platform
|
||||||
|
|
||||||
|
# @return [Integer] the minimum OS version X.Y.Z packed as x16.y8.z8
|
||||||
|
attr_reader :minos
|
||||||
|
|
||||||
|
# @return [Integer] the SDK version X.Y.Z packed as x16.y8.z8
|
||||||
|
attr_reader :sdk
|
||||||
|
|
||||||
|
# @return [ToolEntries] tool entries
|
||||||
|
attr_reader :tool_entries
|
||||||
|
|
||||||
|
# @see MachOStructure::FORMAT
|
||||||
|
# @api private
|
||||||
|
FORMAT = "L=6".freeze
|
||||||
|
|
||||||
|
# @see MachOStructure::SIZEOF
|
||||||
|
# @api private
|
||||||
|
SIZEOF = 24
|
||||||
|
|
||||||
|
# @api private
|
||||||
|
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
|
||||||
|
|
||||||
|
# A representation of the tool versions exposed
|
||||||
|
# by a {BuildVersionCommand} (`LC_BUILD_VERSION`).
|
||||||
|
class ToolEntries
|
||||||
|
# @return [Array<Tool>] all tools
|
||||||
|
attr_reader :tools
|
||||||
|
|
||||||
|
# @param view [MachO::MachOView] the view into the current Mach-O
|
||||||
|
# @param ntools [Integer] the number of tools
|
||||||
|
# @api private
|
||||||
|
def initialize(view, ntools)
|
||||||
|
format = Utils.specialize_format("L=#{ntools * 2}", view.endianness)
|
||||||
|
raw_table = view.raw_data[view.offset + 24, ntools * 8]
|
||||||
|
blobs = raw_table.unpack(format).each_slice(2).to_a
|
||||||
|
|
||||||
|
@tools = blobs.map { |b| Tool.new(*b) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# An individual tool.
|
||||||
|
class Tool
|
||||||
|
# @return [Integer] the enum for the tool
|
||||||
|
attr_reader :tool
|
||||||
|
|
||||||
|
# @return [Integer] the tool's version number
|
||||||
|
attr_reader :version
|
||||||
|
|
||||||
|
# @param tool 32-bit integer
|
||||||
|
# # @param version 32-bit integer
|
||||||
|
# @api private
|
||||||
|
def initialize(tool, version)
|
||||||
|
@tool = tool
|
||||||
|
@version = version
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# A string representation of the binary's minimum OS version.
|
||||||
|
# @return [String] a string representing the minimum OS version.
|
||||||
|
def minos_string
|
||||||
|
binary = "%032b" % minos
|
||||||
|
segs = [
|
||||||
|
binary[0..15], binary[16..23], binary[24..31]
|
||||||
|
].map { |s| s.to_i(2) }
|
||||||
|
|
||||||
|
segs.join(".")
|
||||||
|
end
|
||||||
|
|
||||||
|
# A string representation of the binary's SDK version.
|
||||||
|
# @return [String] a string representing the SDK version.
|
||||||
|
def sdk_string
|
||||||
|
binary = "%032b" % sdk
|
||||||
|
segs = [
|
||||||
|
binary[0..15], binary[16..23], binary[24..31]
|
||||||
|
].map { |s| s.to_i(2) }
|
||||||
|
|
||||||
|
segs.join(".")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# A load command containing the file offsets and sizes of the new
|
# A load command containing the file offsets and sizes of the new
|
||||||
# compressed form of the information dyld needs to load the image.
|
# compressed form of the information dyld needs to load the image.
|
||||||
# Corresponds to LC_DYLD_INFO and LC_DYLD_INFO_ONLY.
|
# Corresponds to LC_DYLD_INFO and LC_DYLD_INFO_ONLY.
|
||||||
class DyldInfoCommand < LoadCommand
|
class DyldInfoCommand < LoadCommand
|
||||||
# @return [Fixnum] the file offset to the rebase information
|
# @return [Integer] the file offset to the rebase information
|
||||||
attr_reader :rebase_off
|
attr_reader :rebase_off
|
||||||
|
|
||||||
# @return [Fixnum] the size of the rebase information
|
# @return [Integer] the size of the rebase information
|
||||||
attr_reader :rebase_size
|
attr_reader :rebase_size
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the binding information
|
# @return [Integer] the file offset to the binding information
|
||||||
attr_reader :bind_off
|
attr_reader :bind_off
|
||||||
|
|
||||||
# @return [Fixnum] the size of the binding information
|
# @return [Integer] the size of the binding information
|
||||||
attr_reader :bind_size
|
attr_reader :bind_size
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the weak binding information
|
# @return [Integer] the file offset to the weak binding information
|
||||||
attr_reader :weak_bind_off
|
attr_reader :weak_bind_off
|
||||||
|
|
||||||
# @return [Fixnum] the size of the weak binding information
|
# @return [Integer] the size of the weak binding information
|
||||||
attr_reader :weak_bind_size
|
attr_reader :weak_bind_size
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the lazy binding information
|
# @return [Integer] the file offset to the lazy binding information
|
||||||
attr_reader :lazy_bind_off
|
attr_reader :lazy_bind_off
|
||||||
|
|
||||||
# @return [Fixnum] the size of the lazy binding information
|
# @return [Integer] the size of the lazy binding information
|
||||||
attr_reader :lazy_bind_size
|
attr_reader :lazy_bind_size
|
||||||
|
|
||||||
# @return [Fixnum] the file offset to the export information
|
# @return [Integer] the file offset to the export information
|
||||||
attr_reader :export_off
|
attr_reader :export_off
|
||||||
|
|
||||||
# @return [Fixnum] the size of the export information
|
# @return [Integer] the size of the export information
|
||||||
attr_reader :export_size
|
attr_reader :export_size
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1182,7 +1277,7 @@ module MachO
|
|||||||
# A load command containing linker options embedded in object files.
|
# A load command containing linker options embedded in object files.
|
||||||
# Corresponds to LC_LINKER_OPTION.
|
# Corresponds to LC_LINKER_OPTION.
|
||||||
class LinkerOptionCommand < LoadCommand
|
class LinkerOptionCommand < LoadCommand
|
||||||
# @return [Fixnum] the number of strings
|
# @return [Integer] the number of strings
|
||||||
attr_reader :count
|
attr_reader :count
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1202,10 +1297,10 @@ module MachO
|
|||||||
|
|
||||||
# A load command specifying the offset of main(). Corresponds to LC_MAIN.
|
# A load command specifying the offset of main(). Corresponds to LC_MAIN.
|
||||||
class EntryPointCommand < LoadCommand
|
class EntryPointCommand < LoadCommand
|
||||||
# @return [Fixnum] the file (__TEXT) offset of main()
|
# @return [Integer] the file (__TEXT) offset of main()
|
||||||
attr_reader :entryoff
|
attr_reader :entryoff
|
||||||
|
|
||||||
# @return [Fixnum] if not 0, the initial stack size.
|
# @return [Integer] if not 0, the initial stack size.
|
||||||
attr_reader :stacksize
|
attr_reader :stacksize
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1227,7 +1322,7 @@ module MachO
|
|||||||
# A load command specifying the version of the sources used to build the
|
# A load command specifying the version of the sources used to build the
|
||||||
# binary. Corresponds to LC_SOURCE_VERSION.
|
# binary. Corresponds to LC_SOURCE_VERSION.
|
||||||
class SourceVersionCommand < LoadCommand
|
class SourceVersionCommand < LoadCommand
|
||||||
# @return [Fixnum] the version packed as a24.b10.c10.d10.e10
|
# @return [Integer] the version packed as a24.b10.c10.d10.e10
|
||||||
attr_reader :version
|
attr_reader :version
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1260,10 +1355,10 @@ module MachO
|
|||||||
# An obsolete load command containing the offset and size of the (GNU style)
|
# An obsolete load command containing the offset and size of the (GNU style)
|
||||||
# symbol table information. Corresponds to LC_SYMSEG.
|
# symbol table information. Corresponds to LC_SYMSEG.
|
||||||
class SymsegCommand < LoadCommand
|
class SymsegCommand < LoadCommand
|
||||||
# @return [Fixnum] the offset to the symbol segment
|
# @return [Integer] the offset to the symbol segment
|
||||||
attr_reader :offset
|
attr_reader :offset
|
||||||
|
|
||||||
# @return [Fixnum] the size of the symbol segment in bytes
|
# @return [Integer] the size of the symbol segment in bytes
|
||||||
attr_reader :size
|
attr_reader :size
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1301,7 +1396,7 @@ module MachO
|
|||||||
# @return [LCStr] the pathname of the file being loaded
|
# @return [LCStr] the pathname of the file being loaded
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
# @return [Fixnum] the virtual address being loaded at
|
# @return [Integer] the virtual address being loaded at
|
||||||
attr_reader :header_addr
|
attr_reader :header_addr
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
@ -1325,10 +1420,10 @@ module MachO
|
|||||||
# @return [LCStr] the library's target pathname
|
# @return [LCStr] the library's target pathname
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
# @return [Fixnum] the library's minor version number
|
# @return [Integer] the library's minor version number
|
||||||
attr_reader :minor_version
|
attr_reader :minor_version
|
||||||
|
|
||||||
# @return [Fixnum] the library's header address
|
# @return [Integer] the library's header address
|
||||||
attr_reader :header_addr
|
attr_reader :header_addr
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
|
@ -134,7 +134,7 @@ module MachO
|
|||||||
alias [] command
|
alias [] command
|
||||||
|
|
||||||
# Inserts a load command at the given offset.
|
# Inserts a load command at the given offset.
|
||||||
# @param offset [Fixnum] the offset to insert at
|
# @param offset [Integer] the offset to insert at
|
||||||
# @param lc [LoadCommands::LoadCommand] the load command to insert
|
# @param lc [LoadCommands::LoadCommand] the load command to insert
|
||||||
# @param options [Hash]
|
# @param options [Hash]
|
||||||
# @option options [Boolean] :repopulate (true) whether or not to repopulate
|
# @option options [Boolean] :repopulate (true) whether or not to repopulate
|
||||||
@ -404,11 +404,8 @@ module MachO
|
|||||||
# @raise [MachOError] if the instance was initialized without a file
|
# @raise [MachOError] if the instance was initialized without a file
|
||||||
# @note Overwrites all data in the file!
|
# @note Overwrites all data in the file!
|
||||||
def write!
|
def write!
|
||||||
if @filename.nil?
|
raise MachOError, "no initial file to write to" if @filename.nil?
|
||||||
raise MachOError, "cannot write to a default file when initialized from a binary string"
|
File.open(@filename, "wb") { |f| f.write(@raw_data) }
|
||||||
else
|
|
||||||
File.open(@filename, "wb") { |f| f.write(@raw_data) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -434,7 +431,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Read just the file's magic number and check its validity.
|
# Read just the file's magic number and check its validity.
|
||||||
# @return [Fixnum] the magic
|
# @return [Integer] the magic
|
||||||
# @raise [MagicError] if the magic is not valid Mach-O magic
|
# @raise [MagicError] if the magic is not valid Mach-O magic
|
||||||
# @raise [FatBinaryError] if the magic is for a Fat file
|
# @raise [FatBinaryError] if the magic is for a Fat file
|
||||||
# @api private
|
# @api private
|
||||||
@ -450,7 +447,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Check the file's CPU type.
|
# Check the file's CPU type.
|
||||||
# @param cputype [Fixnum] the CPU type
|
# @param cputype [Integer] the CPU type
|
||||||
# @raise [CPUTypeError] if the CPU type is unknown
|
# @raise [CPUTypeError] if the CPU type is unknown
|
||||||
# @api private
|
# @api private
|
||||||
def check_cputype(cputype)
|
def check_cputype(cputype)
|
||||||
@ -458,7 +455,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Check the file's CPU type/subtype pair.
|
# Check the file's CPU type/subtype pair.
|
||||||
# @param cpusubtype [Fixnum] the CPU subtype
|
# @param cpusubtype [Integer] the CPU subtype
|
||||||
# @raise [CPUSubtypeError] if the CPU sub-type is unknown
|
# @raise [CPUSubtypeError] if the CPU sub-type is unknown
|
||||||
# @api private
|
# @api private
|
||||||
def check_cpusubtype(cputype, cpusubtype)
|
def check_cpusubtype(cputype, cpusubtype)
|
||||||
@ -467,7 +464,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Check the file's type.
|
# Check the file's type.
|
||||||
# @param filetype [Fixnum] the file type
|
# @param filetype [Integer] the file type
|
||||||
# @raise [FiletypeError] if the file type is unknown
|
# @raise [FiletypeError] if the file type is unknown
|
||||||
# @api private
|
# @api private
|
||||||
def check_filetype(filetype)
|
def check_filetype(filetype)
|
||||||
@ -503,7 +500,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# The low file offset (offset to first section data).
|
# The low file offset (offset to first section data).
|
||||||
# @return [Fixnum] the offset
|
# @return [Integer] the offset
|
||||||
# @api private
|
# @api private
|
||||||
def low_fileoff
|
def low_fileoff
|
||||||
offset = @raw_data.size
|
offset = @raw_data.size
|
||||||
@ -523,7 +520,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Updates the number of load commands in the raw data.
|
# Updates the number of load commands in the raw data.
|
||||||
# @param ncmds [Fixnum] the new number of commands
|
# @param ncmds [Integer] the new number of commands
|
||||||
# @return [void]
|
# @return [void]
|
||||||
# @api private
|
# @api private
|
||||||
def update_ncmds(ncmds)
|
def update_ncmds(ncmds)
|
||||||
@ -533,7 +530,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Updates the size of all load commands in the raw data.
|
# Updates the size of all load commands in the raw data.
|
||||||
# @param size [Fixnum] the new size, in bytes
|
# @param size [Integer] the new size, in bytes
|
||||||
# @return [void]
|
# @return [void]
|
||||||
# @api private
|
# @api private
|
||||||
def update_sizeofcmds(size)
|
def update_sizeofcmds(size)
|
||||||
|
14
Library/Homebrew/vendor/macho/macho/sections.rb
vendored
14
Library/Homebrew/vendor/macho/macho/sections.rb
vendored
@ -76,25 +76,25 @@ module MachO
|
|||||||
# pad bytes
|
# pad bytes
|
||||||
attr_reader :segname
|
attr_reader :segname
|
||||||
|
|
||||||
# @return [Fixnum] the memory address of the section
|
# @return [Integer] the memory address of the section
|
||||||
attr_reader :addr
|
attr_reader :addr
|
||||||
|
|
||||||
# @return [Fixnum] the size, in bytes, of the section
|
# @return [Integer] the size, in bytes, of the section
|
||||||
attr_reader :size
|
attr_reader :size
|
||||||
|
|
||||||
# @return [Fixnum] the file offset of the section
|
# @return [Integer] the file offset of the section
|
||||||
attr_reader :offset
|
attr_reader :offset
|
||||||
|
|
||||||
# @return [Fixnum] the section alignment (power of 2) of the section
|
# @return [Integer] the section alignment (power of 2) of the section
|
||||||
attr_reader :align
|
attr_reader :align
|
||||||
|
|
||||||
# @return [Fixnum] the file offset of the section's relocation entries
|
# @return [Integer] the file offset of the section's relocation entries
|
||||||
attr_reader :reloff
|
attr_reader :reloff
|
||||||
|
|
||||||
# @return [Fixnum] the number of relocation entries
|
# @return [Integer] the number of relocation entries
|
||||||
attr_reader :nreloc
|
attr_reader :nreloc
|
||||||
|
|
||||||
# @return [Fixnum] flags for type and attributes of the section
|
# @return [Integer] flags for type and attributes of the section
|
||||||
attr_reader :flags
|
attr_reader :flags
|
||||||
|
|
||||||
# @return [void] reserved (for offset or index)
|
# @return [void] reserved (for offset or index)
|
||||||
|
@ -8,11 +8,11 @@ module MachO
|
|||||||
FORMAT = "".freeze
|
FORMAT = "".freeze
|
||||||
|
|
||||||
# The size of the data structure, in bytes.
|
# The size of the data structure, in bytes.
|
||||||
# @return [Fixnum] the size, in bytes
|
# @return [Integer] the size, in bytes
|
||||||
# @api private
|
# @api private
|
||||||
SIZEOF = 0
|
SIZEOF = 0
|
||||||
|
|
||||||
# @return [Fixnum] the size, in bytes, of the represented structure.
|
# @return [Integer] the size, in bytes, of the represented structure.
|
||||||
def self.bytesize
|
def self.bytesize
|
||||||
self::SIZEOF
|
self::SIZEOF
|
||||||
end
|
end
|
||||||
|
2
Library/Homebrew/vendor/macho/macho/tools.rb
vendored
2
Library/Homebrew/vendor/macho/macho/tools.rb
vendored
@ -88,7 +88,7 @@ module MachO
|
|||||||
|
|
||||||
# Merge multiple Mach-Os into one universal (Fat) binary.
|
# Merge multiple Mach-Os into one universal (Fat) binary.
|
||||||
# @param filename [String] the fat binary to create
|
# @param filename [String] the fat binary to create
|
||||||
# @param files [Array<MachO::MachOFile, MachO::FatFile>] the files to merge
|
# @param files [Array<String>] the files to merge
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def self.merge_machos(filename, *files)
|
def self.merge_machos(filename, *files)
|
||||||
machos = files.map do |file|
|
machos = files.map do |file|
|
||||||
|
28
Library/Homebrew/vendor/macho/macho/utils.rb
vendored
28
Library/Homebrew/vendor/macho/macho/utils.rb
vendored
@ -2,9 +2,9 @@ module MachO
|
|||||||
# A collection of utility functions used throughout ruby-macho.
|
# A collection of utility functions used throughout ruby-macho.
|
||||||
module Utils
|
module Utils
|
||||||
# Rounds a value to the next multiple of the given round.
|
# Rounds a value to the next multiple of the given round.
|
||||||
# @param value [Fixnum] the number being rounded
|
# @param value [Integer] the number being rounded
|
||||||
# @param round [Fixnum] the number being rounded with
|
# @param round [Integer] the number being rounded with
|
||||||
# @return [Fixnum] the rounded value
|
# @return [Integer] the rounded value
|
||||||
# @see http://www.opensource.apple.com/source/cctools/cctools-870/libstuff/rnd.c
|
# @see http://www.opensource.apple.com/source/cctools/cctools-870/libstuff/rnd.c
|
||||||
def self.round(value, round)
|
def self.round(value, round)
|
||||||
round -= 1
|
round -= 1
|
||||||
@ -15,9 +15,9 @@ module MachO
|
|||||||
|
|
||||||
# Returns the number of bytes needed to pad the given size to the given
|
# Returns the number of bytes needed to pad the given size to the given
|
||||||
# alignment.
|
# alignment.
|
||||||
# @param size [Fixnum] the unpadded size
|
# @param size [Integer] the unpadded size
|
||||||
# @param alignment [Fixnum] the number to alignment the size with
|
# @param alignment [Integer] the number to alignment the size with
|
||||||
# @return [Fixnum] the number of pad bytes required
|
# @return [Integer] the number of pad bytes required
|
||||||
def self.padding_for(size, alignment)
|
def self.padding_for(size, alignment)
|
||||||
round(size, alignment) - size
|
round(size, alignment) - size
|
||||||
end
|
end
|
||||||
@ -33,9 +33,9 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Packs tagged strings into an aligned payload.
|
# Packs tagged strings into an aligned payload.
|
||||||
# @param fixed_offset [Fixnum] the baseline offset for the first packed
|
# @param fixed_offset [Integer] the baseline offset for the first packed
|
||||||
# string
|
# string
|
||||||
# @param alignment [Fixnum] the alignment value to use for packing
|
# @param alignment [Integer] the alignment value to use for packing
|
||||||
# @param strings [Hash] the labeled strings to pack
|
# @param strings [Hash] the labeled strings to pack
|
||||||
# @return [Array<String, Hash>] the packed string and labeled offsets
|
# @return [Array<String, Hash>] the packed string and labeled offsets
|
||||||
def self.pack_strings(fixed_offset, alignment, strings = {})
|
def self.pack_strings(fixed_offset, alignment, strings = {})
|
||||||
@ -55,42 +55,42 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid Mach-O magic numbers.
|
# Compares the given number to valid Mach-O magic numbers.
|
||||||
# @param num [Fixnum] the number being checked
|
# @param num [Integer] the number being checked
|
||||||
# @return [Boolean] whether `num` is a valid Mach-O magic number
|
# @return [Boolean] whether `num` is a valid Mach-O magic number
|
||||||
def self.magic?(num)
|
def self.magic?(num)
|
||||||
Headers::MH_MAGICS.key?(num)
|
Headers::MH_MAGICS.key?(num)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid Fat magic numbers.
|
# Compares the given number to valid Fat magic numbers.
|
||||||
# @param num [Fixnum] the number being checked
|
# @param num [Integer] the number being checked
|
||||||
# @return [Boolean] whether `num` is a valid Fat magic number
|
# @return [Boolean] whether `num` is a valid Fat magic number
|
||||||
def self.fat_magic?(num)
|
def self.fat_magic?(num)
|
||||||
num == Headers::FAT_MAGIC
|
num == Headers::FAT_MAGIC
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid 32-bit Mach-O magic numbers.
|
# Compares the given number to valid 32-bit Mach-O magic numbers.
|
||||||
# @param num [Fixnum] the number being checked
|
# @param num [Integer] the number being checked
|
||||||
# @return [Boolean] whether `num` is a valid 32-bit magic number
|
# @return [Boolean] whether `num` is a valid 32-bit magic number
|
||||||
def self.magic32?(num)
|
def self.magic32?(num)
|
||||||
num == Headers::MH_MAGIC || num == Headers::MH_CIGAM
|
num == Headers::MH_MAGIC || num == Headers::MH_CIGAM
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid 64-bit Mach-O magic numbers.
|
# Compares the given number to valid 64-bit Mach-O magic numbers.
|
||||||
# @param num [Fixnum] the number being checked
|
# @param num [Integer] the number being checked
|
||||||
# @return [Boolean] whether `num` is a valid 64-bit magic number
|
# @return [Boolean] whether `num` is a valid 64-bit magic number
|
||||||
def self.magic64?(num)
|
def self.magic64?(num)
|
||||||
num == Headers::MH_MAGIC_64 || num == Headers::MH_CIGAM_64
|
num == Headers::MH_MAGIC_64 || num == Headers::MH_CIGAM_64
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid little-endian magic numbers.
|
# Compares the given number to valid little-endian magic numbers.
|
||||||
# @param num [Fixnum] the number being checked
|
# @param num [Integer] the number being checked
|
||||||
# @return [Boolean] whether `num` is a valid little-endian magic number
|
# @return [Boolean] whether `num` is a valid little-endian magic number
|
||||||
def self.little_magic?(num)
|
def self.little_magic?(num)
|
||||||
num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
|
num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid big-endian magic numbers.
|
# Compares the given number to valid big-endian magic numbers.
|
||||||
# @param num [Fixnum] the number being checked
|
# @param num [Integer] the number being checked
|
||||||
# @return [Boolean] whether `num` is a valid big-endian magic number
|
# @return [Boolean] whether `num` is a valid big-endian magic number
|
||||||
def self.big_magic?(num)
|
def self.big_magic?(num)
|
||||||
num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
|
num == Headers::MH_CIGAM || num == Headers::MH_CIGAM_64
|
||||||
|
4
Library/Homebrew/vendor/macho/macho/view.rb
vendored
4
Library/Homebrew/vendor/macho/macho/view.rb
vendored
@ -7,13 +7,13 @@ module MachO
|
|||||||
# @return [Symbol] the endianness of the data (`:big` or `:little`)
|
# @return [Symbol] the endianness of the data (`:big` or `:little`)
|
||||||
attr_reader :endianness
|
attr_reader :endianness
|
||||||
|
|
||||||
# @return [Fixnum] the offset of the relevant data (in {#raw_data})
|
# @return [Integer] the offset of the relevant data (in {#raw_data})
|
||||||
attr_reader :offset
|
attr_reader :offset
|
||||||
|
|
||||||
# Creates a new MachOView.
|
# Creates a new MachOView.
|
||||||
# @param raw_data [String] the raw Mach-O data
|
# @param raw_data [String] the raw Mach-O data
|
||||||
# @param endianness [Symbol] the endianness of the data
|
# @param endianness [Symbol] the endianness of the data
|
||||||
# @param offset [Fixnum] the offset of the relevant data
|
# @param offset [Integer] the offset of the relevant data
|
||||||
def initialize(raw_data, endianness, offset)
|
def initialize(raw_data, endianness, offset)
|
||||||
@raw_data = raw_data
|
@raw_data = raw_data
|
||||||
@endianness = endianness
|
@endianness = endianness
|
||||||
|
Loading…
x
Reference in New Issue
Block a user