Merge pull request #9115 from Homebrew/dependabot/bundler/Library/Homebrew/ruby-macho-2.5.0
build(deps): bump ruby-macho from 2.2.0 to 2.5.0 in /Library/Homebrew
This commit is contained in:
commit
1f8dc4886a
@ -117,7 +117,7 @@ GEM
|
|||||||
rubocop-ast (>= 1.1.0)
|
rubocop-ast (>= 1.1.0)
|
||||||
rubocop-sorbet (0.5.1)
|
rubocop-sorbet (0.5.1)
|
||||||
rubocop
|
rubocop
|
||||||
ruby-macho (2.2.0)
|
ruby-macho (2.5.0)
|
||||||
ruby-progressbar (1.10.1)
|
ruby-progressbar (1.10.1)
|
||||||
simplecov (0.19.1)
|
simplecov (0.19.1)
|
||||||
docile (~> 1.1)
|
docile (~> 1.1)
|
||||||
|
@ -51,7 +51,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.20.0/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-3.3.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-3.3.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.2.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-0.5.6036/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-0.5.6040/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parlour-4.0.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parlour-4.0.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/patchelf-1.3.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/patchelf-1.3.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
|
||||||
@ -76,9 +76,9 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.2.0/lib"
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.8.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.8.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.0.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.0.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-static-0.5.6036-universal-darwin-19/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-static-0.5.6042-universal-darwin-19/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-0.5.6036/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-0.5.6042/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-stub-0.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-stub-0.2.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thor-1.0.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thor-1.0.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/spoom-1.0.4/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/spoom-1.0.4/lib"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "open3"
|
||||||
|
|
||||||
require_relative "macho/structure"
|
require_relative "macho/structure"
|
||||||
require_relative "macho/view"
|
require_relative "macho/view"
|
||||||
require_relative "macho/headers"
|
require_relative "macho/headers"
|
||||||
@ -12,7 +16,7 @@ require_relative "macho/tools"
|
|||||||
# The primary namespace for ruby-macho.
|
# The primary namespace for ruby-macho.
|
||||||
module MachO
|
module MachO
|
||||||
# release version
|
# release version
|
||||||
VERSION = "2.2.0".freeze
|
VERSION = "2.5.0"
|
||||||
|
|
||||||
# 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
|
||||||
@ -25,7 +29,7 @@ module MachO
|
|||||||
raise ArgumentError, "#{filename}: no such file" unless File.file?(filename)
|
raise ArgumentError, "#{filename}: no such file" unless File.file?(filename)
|
||||||
raise TruncatedFileError unless File.stat(filename).size >= 4
|
raise TruncatedFileError unless File.stat(filename).size >= 4
|
||||||
|
|
||||||
magic = File.open(filename, "rb") { |f| f.read(4) }.unpack("N").first
|
magic = File.open(filename, "rb") { |f| f.read(4) }.unpack1("N")
|
||||||
|
|
||||||
if Utils.fat_magic?(magic)
|
if Utils.fat_magic?(magic)
|
||||||
file = FatFile.new(filename)
|
file = FatFile.new(filename)
|
||||||
@ -37,4 +41,21 @@ module MachO
|
|||||||
|
|
||||||
file
|
file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Signs the dylib using an ad-hoc identity.
|
||||||
|
# Necessary after making any changes to a dylib, since otherwise
|
||||||
|
# changing a signed file invalidates its signature.
|
||||||
|
# @param filename [String] the file being opened
|
||||||
|
# @return [void]
|
||||||
|
# @raise [ModificationError] if the operation fails
|
||||||
|
def self.codesign!(filename)
|
||||||
|
raise ArgumentError, "codesign binary is not available on Linux" if RUBY_PLATFORM !~ /darwin/
|
||||||
|
raise ArgumentError, "#{filename}: no such file" unless File.file?(filename)
|
||||||
|
|
||||||
|
_, _, status = Open3.capture3("codesign", "--sign", "-", "--force",
|
||||||
|
"--preserve-metadata=entitlements,requirements,flags,runtime",
|
||||||
|
filename)
|
||||||
|
|
||||||
|
raise CodeSigningError, "#{filename}: signing failed!" unless status.success?
|
||||||
|
end
|
||||||
end
|
end
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# A generic Mach-O error in execution.
|
# A generic Mach-O error in execution.
|
||||||
class MachOError < RuntimeError
|
class MachOError < RuntimeError
|
||||||
@ -7,6 +9,11 @@ module MachO
|
|||||||
class ModificationError < MachOError
|
class ModificationError < MachOError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Raised when codesigning fails. Certain environments
|
||||||
|
# may want to rescue this to treat it as non-fatal.
|
||||||
|
class CodeSigningError < MachOError
|
||||||
|
end
|
||||||
|
|
||||||
# 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
|
||||||
@ -25,10 +32,6 @@ module MachO
|
|||||||
|
|
||||||
# Raised when a file is not a Mach-O.
|
# Raised when a file is not a Mach-O.
|
||||||
class NotAMachOError < MachOError
|
class NotAMachOError < MachOError
|
||||||
# @param error [String] the error in question
|
|
||||||
def initialize(error)
|
|
||||||
super error
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Raised when a file is too short to be a valid Mach-O file.
|
# Raised when a file is too short to be a valid Mach-O file.
|
||||||
@ -41,8 +44,8 @@ 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 [Integer] the unknown number
|
# @param num [Integer] the unknown number
|
||||||
def initialize(num)
|
def initialize(magic)
|
||||||
super "Unrecognized Mach-O magic: 0x#{"%02x" % num}"
|
super "Unrecognized Mach-O magic: 0x%02<magic>x" % { :magic => magic }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -71,7 +74,7 @@ module MachO
|
|||||||
class CPUTypeError < MachOError
|
class CPUTypeError < MachOError
|
||||||
# @param cputype [Integer] 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%08<cputype>x" % { :cputype => cputype }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -80,8 +83,8 @@ module MachO
|
|||||||
# @param cputype [Integer] the CPU type of the unknown pair
|
# @param cputype [Integer] the CPU type of the unknown pair
|
||||||
# @param cpusubtype [Integer] 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%08<cpusubtype>x" \
|
||||||
" (for CPU type: 0x#{"%08x" % cputype})"
|
" (for CPU type: 0x%08<cputype>x" % { :cputype => cputype, :cpusubtype => cpusubtype }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -89,7 +92,7 @@ module MachO
|
|||||||
class FiletypeError < MachOError
|
class FiletypeError < MachOError
|
||||||
# @param num [Integer] 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%02<num>x" % { :num => num }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -97,7 +100,7 @@ module MachO
|
|||||||
class LoadCommandError < MachOError
|
class LoadCommandError < MachOError
|
||||||
# @param num [Integer] 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%02<num>x" % { :num => num }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "forwardable"
|
require "forwardable"
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
@ -64,7 +66,7 @@ module MachO
|
|||||||
offset += (macho.serialize.bytesize + macho_pads[macho])
|
offset += (macho.serialize.bytesize + macho_pads[macho])
|
||||||
end
|
end
|
||||||
|
|
||||||
machos.each do |macho|
|
machos.each do |macho| # rubocop:disable Style/CombinableLoops
|
||||||
bin << Utils.nullpad(macho_pads[macho])
|
bin << Utils.nullpad(macho_pads[macho])
|
||||||
bin << macho.serialize
|
bin << macho.serialize
|
||||||
end
|
end
|
||||||
@ -396,16 +398,14 @@ module MachO
|
|||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
machos.each_with_index do |macho, index|
|
machos.each_with_index do |macho, index|
|
||||||
begin
|
|
||||||
yield macho
|
yield macho
|
||||||
rescue RecoverableModificationError => error
|
rescue RecoverableModificationError => e
|
||||||
error.macho_slice = index
|
e.macho_slice = index
|
||||||
|
|
||||||
# Strict mode: Immediately re-raise. Otherwise: Retain, check later.
|
# Strict mode: Immediately re-raise. Otherwise: Retain, check later.
|
||||||
raise error if strict
|
raise e if strict
|
||||||
|
|
||||||
errors << error
|
errors << e
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Non-strict mode: Raise first error if *all* Mach-O slices failed.
|
# Non-strict mode: Raise first error if *all* Mach-O slices failed.
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# Classes and constants for parsing the headers of Mach-O binaries.
|
# Classes and constants for parsing the headers of Mach-O binaries.
|
||||||
module Headers
|
module Headers
|
||||||
@ -490,7 +492,7 @@ module MachO
|
|||||||
# always big-endian
|
# always big-endian
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "N2".freeze
|
FORMAT = "N2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -498,6 +500,7 @@ module MachO
|
|||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
def initialize(magic, nfat_arch)
|
def initialize(magic, nfat_arch)
|
||||||
|
super()
|
||||||
@magic = magic
|
@magic = magic
|
||||||
@nfat_arch = nfat_arch
|
@nfat_arch = nfat_arch
|
||||||
end
|
end
|
||||||
@ -541,7 +544,7 @@ module MachO
|
|||||||
# @note Always big endian.
|
# @note Always big endian.
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L>5".freeze
|
FORMAT = "L>5"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -549,6 +552,7 @@ module MachO
|
|||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
def initialize(cputype, cpusubtype, offset, size, align)
|
def initialize(cputype, cpusubtype, offset, size, align)
|
||||||
|
super()
|
||||||
@cputype = cputype
|
@cputype = cputype
|
||||||
@cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK
|
@cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK
|
||||||
@offset = offset
|
@offset = offset
|
||||||
@ -587,7 +591,7 @@ module MachO
|
|||||||
# @note Always big endian.
|
# @note Always big endian.
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L>2Q>2L>2".freeze
|
FORMAT = "L>2Q>2L>2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -637,7 +641,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=7".freeze
|
FORMAT = "L=7"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -646,6 +650,7 @@ module MachO
|
|||||||
# @api private
|
# @api private
|
||||||
def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds,
|
def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds,
|
||||||
flags)
|
flags)
|
||||||
|
super()
|
||||||
@magic = magic
|
@magic = magic
|
||||||
@cputype = cputype
|
@cputype = cputype
|
||||||
# For now we're not interested in additional capability bits also to be
|
# For now we're not interested in additional capability bits also to be
|
||||||
@ -760,7 +765,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=8".freeze
|
FORMAT = "L=8"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# Classes and constants for parsing load commands in Mach-O binaries.
|
# Classes and constants for parsing load commands in Mach-O binaries.
|
||||||
module LoadCommands
|
module LoadCommands
|
||||||
@ -60,6 +62,8 @@ module MachO
|
|||||||
0x30 => :LC_VERSION_MIN_WATCHOS,
|
0x30 => :LC_VERSION_MIN_WATCHOS,
|
||||||
0x31 => :LC_NOTE,
|
0x31 => :LC_NOTE,
|
||||||
0x32 => :LC_BUILD_VERSION,
|
0x32 => :LC_BUILD_VERSION,
|
||||||
|
(0x33 | LC_REQ_DYLD) => :LC_DYLD_EXPORTS_TRIE,
|
||||||
|
(0x34 | LC_REQ_DYLD) => :LD_DYLD_CHAINED_FIXUPS,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# association of symbol representations to load command constants
|
# association of symbol representations to load command constants
|
||||||
@ -145,6 +149,8 @@ module MachO
|
|||||||
:LC_VERSION_MIN_WATCHOS => "VersionMinCommand",
|
:LC_VERSION_MIN_WATCHOS => "VersionMinCommand",
|
||||||
:LC_NOTE => "NoteCommand",
|
:LC_NOTE => "NoteCommand",
|
||||||
:LC_BUILD_VERSION => "BuildVersionCommand",
|
:LC_BUILD_VERSION => "BuildVersionCommand",
|
||||||
|
:LC_DYLD_EXPORTS_TRIE => "LinkeditDataCommand",
|
||||||
|
:LD_DYLD_CHAINED_FIXUPS => "LinkeditDataCommand",
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# association of segment name symbols to names
|
# association of segment name symbols to names
|
||||||
@ -186,7 +192,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2".freeze
|
FORMAT = "L=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -225,6 +231,7 @@ module MachO
|
|||||||
# @param cmdsize [Integer] 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)
|
||||||
|
super()
|
||||||
@view = view
|
@view = view
|
||||||
@cmd = cmd
|
@cmd = cmd
|
||||||
@cmdsize = cmdsize
|
@cmdsize = cmdsize
|
||||||
@ -365,7 +372,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2a16".freeze
|
FORMAT = "L=2a16"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -379,7 +386,7 @@ module MachO
|
|||||||
|
|
||||||
# @return [String] a string representation of the UUID
|
# @return [String] a string representation of the UUID
|
||||||
def uuid_string
|
def uuid_string
|
||||||
hexes = uuid.map { |e| "%02x" % e }
|
hexes = uuid.map { |elem| "%02<elem>x" % { :elem => elem } }
|
||||||
segs = [
|
segs = [
|
||||||
hexes[0..3].join, hexes[4..5].join, hexes[6..7].join,
|
hexes[0..3].join, hexes[4..5].join, hexes[6..7].join,
|
||||||
hexes[8..9].join, hexes[10..15].join
|
hexes[8..9].join, hexes[10..15].join
|
||||||
@ -429,7 +436,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2Z16L=4l=2L=2".freeze
|
FORMAT = "L=2Z16L=4l=2L=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -524,7 +531,7 @@ module MachO
|
|||||||
class SegmentCommand64 < SegmentCommand
|
class SegmentCommand64 < SegmentCommand
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2Z16Q=4l=2L=2".freeze
|
FORMAT = "L=2Z16Q=4l=2L=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -550,7 +557,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=6".freeze
|
FORMAT = "L=6"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -601,7 +608,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -649,7 +656,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=5".freeze
|
FORMAT = "L=5"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -679,7 +686,7 @@ module MachO
|
|||||||
class ThreadCommand < LoadCommand
|
class ThreadCommand < LoadCommand
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2".freeze
|
FORMAT = "L=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -717,7 +724,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=10".freeze
|
FORMAT = "L=10"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -758,7 +765,7 @@ module MachO
|
|||||||
class RoutinesCommand64 < RoutinesCommand
|
class RoutinesCommand64 < RoutinesCommand
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2Q=8".freeze
|
FORMAT = "L=2Q=8"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -773,7 +780,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -801,7 +808,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -829,7 +836,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -857,7 +864,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -894,7 +901,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=6".freeze
|
FORMAT = "L=6"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -979,7 +986,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=20".freeze
|
FORMAT = "L=20"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1052,7 +1059,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=4".freeze
|
FORMAT = "L=4"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1127,7 +1134,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1156,7 +1163,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1191,7 +1198,8 @@ module MachO
|
|||||||
# A load command representing the offsets and sizes of a blob of data in
|
# A load command representing the offsets and sizes of a blob of data in
|
||||||
# the __LINKEDIT segment. Corresponds to LC_CODE_SIGNATURE,
|
# the __LINKEDIT segment. Corresponds to LC_CODE_SIGNATURE,
|
||||||
# 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, LC_LINKER_OPTIMIZATION_HINT, LC_DYLD_EXPORTS_TRIE,
|
||||||
|
# or LC_DYLD_CHAINED_FIXUPS.
|
||||||
class LinkeditDataCommand < LoadCommand
|
class LinkeditDataCommand < LoadCommand
|
||||||
# @return [Integer] offset to the data in the __LINKEDIT segment
|
# @return [Integer] offset to the data in the __LINKEDIT segment
|
||||||
attr_reader :dataoff
|
attr_reader :dataoff
|
||||||
@ -1201,7 +1209,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=4".freeze
|
FORMAT = "L=4"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1237,7 +1245,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=5".freeze
|
FORMAT = "L=5"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1269,7 +1277,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=6".freeze
|
FORMAT = "L=6"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1301,7 +1309,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=4".freeze
|
FORMAT = "L=4"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1317,7 +1325,7 @@ module MachO
|
|||||||
# A string representation of the binary's minimum OS version.
|
# A string representation of the binary's minimum OS version.
|
||||||
# @return [String] a string representing the minimum OS version.
|
# @return [String] a string representing the minimum OS version.
|
||||||
def version_string
|
def version_string
|
||||||
binary = "%032b" % version
|
binary = "%032<version>b" % { :version => version }
|
||||||
segs = [
|
segs = [
|
||||||
binary[0..15], binary[16..23], binary[24..31]
|
binary[0..15], binary[16..23], binary[24..31]
|
||||||
].map { |s| s.to_i(2) }
|
].map { |s| s.to_i(2) }
|
||||||
@ -1328,7 +1336,7 @@ module MachO
|
|||||||
# A string representation of the binary's SDK version.
|
# A string representation of the binary's SDK version.
|
||||||
# @return [String] a string representing the SDK version.
|
# @return [String] a string representing the SDK version.
|
||||||
def sdk_string
|
def sdk_string
|
||||||
binary = "%032b" % sdk
|
binary = "%032<sdk>b" % { :sdk => sdk }
|
||||||
segs = [
|
segs = [
|
||||||
binary[0..15], binary[16..23], binary[24..31]
|
binary[0..15], binary[16..23], binary[24..31]
|
||||||
].map { |s| s.to_i(2) }
|
].map { |s| s.to_i(2) }
|
||||||
@ -1365,7 +1373,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=6".freeze
|
FORMAT = "L=6"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1383,7 +1391,7 @@ module MachO
|
|||||||
# A string representation of the binary's minimum OS version.
|
# A string representation of the binary's minimum OS version.
|
||||||
# @return [String] a string representing the minimum OS version.
|
# @return [String] a string representing the minimum OS version.
|
||||||
def minos_string
|
def minos_string
|
||||||
binary = "%032b" % minos
|
binary = "%032<minos>b" % { :minos => minos }
|
||||||
segs = [
|
segs = [
|
||||||
binary[0..15], binary[16..23], binary[24..31]
|
binary[0..15], binary[16..23], binary[24..31]
|
||||||
].map { |s| s.to_i(2) }
|
].map { |s| s.to_i(2) }
|
||||||
@ -1394,7 +1402,7 @@ module MachO
|
|||||||
# A string representation of the binary's SDK version.
|
# A string representation of the binary's SDK version.
|
||||||
# @return [String] a string representing the SDK version.
|
# @return [String] a string representing the SDK version.
|
||||||
def sdk_string
|
def sdk_string
|
||||||
binary = "%032b" % sdk
|
binary = "%032<sdk>b" % { :sdk => sdk }
|
||||||
segs = [
|
segs = [
|
||||||
binary[0..15], binary[16..23], binary[24..31]
|
binary[0..15], binary[16..23], binary[24..31]
|
||||||
].map { |s| s.to_i(2) }
|
].map { |s| s.to_i(2) }
|
||||||
@ -1494,7 +1502,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=12".freeze
|
FORMAT = "L=12"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1542,7 +1550,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=3".freeze
|
FORMAT = "L=3"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1572,7 +1580,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2Q=2".freeze
|
FORMAT = "L=2Q=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1602,7 +1610,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2Q=1".freeze
|
FORMAT = "L=2Q=1"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1617,7 +1625,7 @@ module MachO
|
|||||||
# A string representation of the sources used to build the binary.
|
# A string representation of the sources used to build the binary.
|
||||||
# @return [String] a string representation of the version
|
# @return [String] a string representation of the version
|
||||||
def version_string
|
def version_string
|
||||||
binary = "%064b" % version
|
binary = "%064<version>b" % { :version => version }
|
||||||
segs = [
|
segs = [
|
||||||
binary[0..23], binary[24..33], binary[34..43], binary[44..53],
|
binary[0..23], binary[24..33], binary[34..43], binary[44..53],
|
||||||
binary[54..63]
|
binary[54..63]
|
||||||
@ -1646,7 +1654,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=4".freeze
|
FORMAT = "L=4"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1674,7 +1682,7 @@ module MachO
|
|||||||
class IdentCommand < LoadCommand
|
class IdentCommand < LoadCommand
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2".freeze
|
FORMAT = "L=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1692,7 +1700,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=4".freeze
|
FORMAT = "L=4"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1727,7 +1735,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=5".freeze
|
FORMAT = "L=5"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
||||||
@ -1764,7 +1772,7 @@ module MachO
|
|||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "L=2Z16Q=2".freeze
|
FORMAT = "L=2Z16Q=2"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
# @api private
|
# @api private
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "forwardable"
|
require "forwardable"
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
@ -476,7 +478,7 @@ module MachO
|
|||||||
# @raise [FatBinaryError] if the magic is for a Fat file
|
# @raise [FatBinaryError] if the magic is for a Fat file
|
||||||
# @api private
|
# @api private
|
||||||
def populate_and_check_magic
|
def populate_and_check_magic
|
||||||
magic = @raw_data[0..3].unpack("N").first
|
magic = @raw_data[0..3].unpack1("N")
|
||||||
|
|
||||||
raise MagicError, magic unless Utils.magic?(magic)
|
raise MagicError, magic unless Utils.magic?(magic)
|
||||||
raise FatBinaryError if Utils.fat_magic?(magic)
|
raise FatBinaryError if Utils.fat_magic?(magic)
|
||||||
@ -522,7 +524,7 @@ module MachO
|
|||||||
|
|
||||||
header.ncmds.times do
|
header.ncmds.times do
|
||||||
fmt = Utils.specialize_format("L=", endianness)
|
fmt = Utils.specialize_format("L=", endianness)
|
||||||
cmd = @raw_data.slice(offset, 4).unpack(fmt).first
|
cmd = @raw_data.slice(offset, 4).unpack1(fmt)
|
||||||
cmd_sym = LoadCommands::LOAD_COMMANDS[cmd]
|
cmd_sym = LoadCommands::LOAD_COMMANDS[cmd]
|
||||||
|
|
||||||
raise LoadCommandError, cmd unless cmd_sym || permissive
|
raise LoadCommandError, cmd unless cmd_sym || permissive
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# Classes and constants for parsing sections in Mach-O binaries.
|
# Classes and constants for parsing sections in Mach-O binaries.
|
||||||
module Sections
|
module Sections
|
||||||
@ -108,7 +110,7 @@ module MachO
|
|||||||
attr_reader :reserved2
|
attr_reader :reserved2
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
FORMAT = "Z16Z16L=9".freeze
|
FORMAT = "Z16Z16L=9"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
SIZEOF = 68
|
SIZEOF = 68
|
||||||
@ -116,6 +118,7 @@ module MachO
|
|||||||
# @api private
|
# @api private
|
||||||
def initialize(sectname, segname, addr, size, offset, align, reloff,
|
def initialize(sectname, segname, addr, size, offset, align, reloff,
|
||||||
nreloc, flags, reserved1, reserved2)
|
nreloc, flags, reserved1, reserved2)
|
||||||
|
super()
|
||||||
@sectname = sectname
|
@sectname = sectname
|
||||||
@segname = segname
|
@segname = segname
|
||||||
@addr = addr
|
@addr = addr
|
||||||
@ -180,7 +183,7 @@ module MachO
|
|||||||
attr_reader :reserved3
|
attr_reader :reserved3
|
||||||
|
|
||||||
# @see MachOStructure::FORMAT
|
# @see MachOStructure::FORMAT
|
||||||
FORMAT = "Z16Z16Q=2L=8".freeze
|
FORMAT = "Z16Z16Q=2L=8"
|
||||||
|
|
||||||
# @see MachOStructure::SIZEOF
|
# @see MachOStructure::SIZEOF
|
||||||
SIZEOF = 80
|
SIZEOF = 80
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# A general purpose pseudo-structure.
|
# A general purpose pseudo-structure.
|
||||||
# @abstract
|
# @abstract
|
||||||
@ -5,7 +7,7 @@ module MachO
|
|||||||
# The String#unpack format of the data structure.
|
# The String#unpack format of the data structure.
|
||||||
# @return [String] the unpacking format
|
# @return [String] the unpacking format
|
||||||
# @api private
|
# @api private
|
||||||
FORMAT = "".freeze
|
FORMAT = ""
|
||||||
|
|
||||||
# The size of the data structure, in bytes.
|
# The size of the data structure, in bytes.
|
||||||
# @return [Integer] the size, in bytes
|
# @return [Integer] the size, in bytes
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# A collection of convenient methods for common operations on Mach-O and Fat
|
# A collection of convenient methods for common operations on Mach-O and Fat
|
||||||
# binaries.
|
# binaries.
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# A collection of utility functions used throughout ruby-macho.
|
# A collection of utility functions used throughout ruby-macho.
|
||||||
module Utils
|
module Utils
|
||||||
@ -51,7 +53,7 @@ module MachO
|
|||||||
def self.pack_strings(fixed_offset, alignment, strings = {})
|
def self.pack_strings(fixed_offset, alignment, strings = {})
|
||||||
offsets = {}
|
offsets = {}
|
||||||
next_offset = fixed_offset
|
next_offset = fixed_offset
|
||||||
payload = ""
|
payload = +""
|
||||||
|
|
||||||
strings.each do |key, string|
|
strings.each do |key, string|
|
||||||
offsets[key] = next_offset
|
offsets[key] = next_offset
|
||||||
@ -61,7 +63,7 @@ module MachO
|
|||||||
end
|
end
|
||||||
|
|
||||||
payload << Utils.nullpad(padding_for(fixed_offset + payload.bytesize, alignment))
|
payload << Utils.nullpad(padding_for(fixed_offset + payload.bytesize, alignment))
|
||||||
[payload, offsets]
|
[payload.freeze, offsets]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compares the given number to valid Mach-O magic numbers.
|
# Compares the given number to valid Mach-O magic numbers.
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module MachO
|
module MachO
|
||||||
# A representation of some unspecified Mach-O data.
|
# A representation of some unspecified Mach-O data.
|
||||||
class MachOView
|
class MachOView
|
Loading…
x
Reference in New Issue
Block a user