From 051f3e719f6f5205798a1183fecd8b5d853cbdb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 18:22:05 +0000 Subject: [PATCH 1/3] build(deps): bump ruby-macho from 3.0.0 to 4.0.0 in /Library/Homebrew Bumps [ruby-macho](https://github.com/Homebrew/ruby-macho) from 3.0.0 to 4.0.0. - [Release notes](https://github.com/Homebrew/ruby-macho/releases) - [Commits](https://github.com/Homebrew/ruby-macho/compare/v3.0.0...v4.0.0) --- updated-dependencies: - dependency-name: ruby-macho dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Library/Homebrew/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 857208a786a2d..f222408176161 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -120,7 +120,7 @@ GEM rubocop-capybara (~> 2.17) rubocop-sorbet (0.7.0) rubocop (>= 0.90.0) - ruby-macho (3.0.0) + ruby-macho (4.0.0) ruby-prof (1.4.3) ruby-progressbar (1.13.0) simplecov (0.22.0) From e91b64d138d0307dd0e1a4c0bbe0a2e11917fdd4 Mon Sep 17 00:00:00 2001 From: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> Date: Tue, 25 Jul 2023 18:25:53 +0000 Subject: [PATCH 2/3] brew vendor-gems: commit updates. --- .../Homebrew/vendor/bundle/bundler/setup.rb | 2 +- .../ruby-macho-3.0.0/lib/macho/structure.rb | 42 - .../lib/macho.rb | 4 +- .../lib/macho/exceptions.rb | 38 +- .../lib/macho/fat_file.rb | 12 + .../lib/macho/headers.rb | 171 +--- .../lib/macho/load_commands.rb | 828 ++++-------------- .../lib/macho/macho_file.rb | 19 +- .../lib/macho/sections.rb | 65 +- .../ruby-macho-4.0.0/lib/macho/structure.rb | 284 ++++++ .../lib/macho/tools.rb | 0 .../lib/macho/utils.rb | 0 .../lib/macho/view.rb | 11 +- 13 files changed, 583 insertions(+), 893 deletions(-) delete mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/structure.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho.rb (99%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/exceptions.rb (83%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/fat_file.rb (95%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/headers.rb (85%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/load_commands.rb (69%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/macho_file.rb (97%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/sections.rb (81%) create mode 100644 Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/structure.rb rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/tools.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/utils.rb (100%) rename Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/{ruby-macho-3.0.0 => ruby-macho-4.0.0}/lib/macho/view.rb (67%) diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index 62e2b2fb685d4..4a043af7c4f32 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -96,7 +96,7 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.19.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.20.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib") -$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-4.0.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/ruby-prof-1.4.3") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-prof-1.4.3/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-html-0.12.3/lib") diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/structure.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/structure.rb deleted file mode 100644 index 0356d605af695..0000000000000 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/structure.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -module MachO - # A general purpose pseudo-structure. - # @abstract - class MachOStructure - # The String#unpack format of the data structure. - # @return [String] the unpacking format - # @api private - FORMAT = "" - - # The size of the data structure, in bytes. - # @return [Integer] the size, in bytes - # @api private - SIZEOF = 0 - - # @return [Integer] the size, in bytes, of the represented structure. - def self.bytesize - self::SIZEOF - end - - # @param endianness [Symbol] either `:big` or `:little` - # @param bin [String] the string to be unpacked into the new structure - # @return [MachO::MachOStructure] the resulting structure - # @api private - def self.new_from_bin(endianness, bin) - format = Utils.specialize_format(self::FORMAT, endianness) - - new(*bin.unpack(format)) - end - - # @return [Hash] a hash representation of this {MachOStructure}. - def to_h - { - "structure" => { - "format" => self.class::FORMAT, - "bytesize" => self.class.bytesize, - }, - } - end - end -end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho.rb similarity index 99% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho.rb index 8b9e24f81a18c..f11343c81dd4c 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho.rb @@ -2,6 +2,7 @@ require "open3" +require_relative "macho/utils" require_relative "macho/structure" require_relative "macho/view" require_relative "macho/headers" @@ -10,13 +11,12 @@ require_relative "macho/macho_file" require_relative "macho/fat_file" require_relative "macho/exceptions" -require_relative "macho/utils" require_relative "macho/tools" # The primary namespace for ruby-macho. module MachO # release version - VERSION = "3.0.0" + VERSION = "4.0.0" # Opens the given filename as a MachOFile or FatFile, depending on its magic. # @param filename [String] the file being opened diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/exceptions.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/exceptions.rb similarity index 83% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/exceptions.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/exceptions.rb index 368c16e9c2c34..66af33427f941 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/exceptions.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/exceptions.rb @@ -56,6 +56,28 @@ def initialize end end + # Raised when a a fat Mach-O file has zero architectures + class ZeroArchitectureError < NotAMachOError + def initialize + super "Fat file has zero internal architectures" + end + end + + # Raised when there is a mismatch between the fat arch + # and internal slice cputype or cpusubtype. + class CPUTypeMismatchError < NotAMachOError + def initialize(fat_cputype, fat_cpusubtype, macho_cputype, macho_cpusubtype) + # @param cputype_fat [Integer] the CPU type in the fat header + # @param cpusubtype_fat [Integer] the CPU subtype in the fat header + # @param cputype_macho [Integer] the CPU type in the macho header + # @param cpusubtype_macho [Integer] the CPU subtype in the macho header + super ("Mismatch between cputypes >> 0x%08x and 0x%08x\n" \ + "and/or cpusubtypes >> 0x%08x and 0x%08x" % + { :fat_cputype => fat_cputype, :macho_cputype => macho_cputype, + :fat_cpusubtype => fat_cpusubtype, :macho_cpusubtype => macho_cpusubtype }) + end + end + # Raised when a fat binary is loaded with MachOFile. class FatBinaryError < MachOError def initialize @@ -83,8 +105,8 @@ class CPUSubtypeError < MachOError # @param cputype [Integer] the CPU type of the unknown pair # @param cpusubtype [Integer] the CPU sub-type of the unknown pair def initialize(cputype, cpusubtype) - super "Unrecognized CPU sub-type: 0x%08x" \ - " (for CPU type: 0x%08x" % { :cputype => cputype, :cpusubtype => cpusubtype } + super "Unrecognized CPU sub-type: 0x%08x " \ + "(for CPU type: 0x%08x" % { :cputype => cputype, :cpusubtype => cpusubtype } end end @@ -119,8 +141,8 @@ class LoadCommandCreationArityError < MachOError # @param expected_arity [Integer] the number of arguments expected # @param actual_arity [Integer] the number of arguments received def initialize(cmd_sym, expected_arity, actual_arity) - super "Expected #{expected_arity} arguments for #{cmd_sym} creation," \ - " got #{actual_arity}" + super "Expected #{expected_arity} arguments for #{cmd_sym} creation, " \ + "got #{actual_arity}" end end @@ -136,8 +158,8 @@ def initialize(cmd_sym) class LCStrMalformedError < MachOError # @param lc [MachO::LoadCommand] the load command containing the string def initialize(lc) - super "Load command #{lc.type} at offset #{lc.view.offset} contains a" \ - " malformed string" + super "Load command #{lc.type} at offset #{lc.view.offset} contains a " \ + "malformed string" end end @@ -203,8 +225,8 @@ def initialize(thing) class FatArchOffsetOverflowError < MachOError # @param offset [Integer] the offending offset def initialize(offset) - super "Offset #{offset} exceeds the 32-bit width of a fat_arch offset." \ - " Consider merging with `fat64: true`" + super "Offset #{offset} exceeds the 32-bit width of a fat_arch offset. " \ + "Consider merging with `fat64: true`" end end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/fat_file.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/fat_file.rb similarity index 95% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/fat_file.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/fat_file.rb index 569250cc75e22..637e1c5aa50d2 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/fat_file.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/fat_file.rb @@ -327,6 +327,8 @@ def to_h # @raise [MagicError] if the magic is not valid Mach-O magic # @raise [MachOBinaryError] if the magic is for a non-fat Mach-O file # @raise [JavaClassFileError] if the file is a Java classfile + # @raise [ZeroArchitectureError] if the file has no internal slices + # (i.e., nfat_arch == 0) and the permissive option is not set # @api private def populate_fat_header # the smallest fat Mach-O header is 8 bytes @@ -346,6 +348,9 @@ def populate_fat_header # formats. raise JavaClassFileError if fh.nfat_arch > 30 + # Rationale: return an error if the file has no internal slices. + raise ZeroArchitectureError if fh.nfat_arch.zero? + fh end @@ -374,6 +379,13 @@ def populate_machos fat_archs.each do |arch| machos << MachOFile.new_from_bin(@raw_data[arch.offset, arch.size], **options) + + # Make sure that each fat_arch and internal slice. + # contain matching cputypes and cpusubtypes + next if machos.last.header.cputype == arch.cputype && + machos.last.header.cpusubtype == arch.cpusubtype + + raise CPUTypeMismatchError.new(arch.cputype, arch.cpusubtype, machos.last.header.cputype, machos.last.header.cpusubtype) end machos diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/headers.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/headers.rb similarity index 85% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/headers.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/headers.rb index a810f6317dc49..4abdd533d43d1 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/headers.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/headers.rb @@ -505,30 +505,14 @@ module Headers # @see MachO::FatArch class FatHeader < MachOStructure # @return [Integer] the magic number of the header (and file) - attr_reader :magic + field :magic, :uint32, :endian => :big # @return [Integer] the number of fat architecture structures following the header - attr_reader :nfat_arch - - # always big-endian - # @see MachOStructure::FORMAT - # @api private - FORMAT = "N2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 8 - - # @api private - def initialize(magic, nfat_arch) - super() - @magic = magic - @nfat_arch = nfat_arch - end + field :nfat_arch, :uint32, :endian => :big # @return [String] the serialized fields of the fat header def serialize - [magic, nfat_arch].pack(FORMAT) + [magic, nfat_arch].pack(self.class.format) end # @return [Hash] a hash representation of this {FatHeader} @@ -548,42 +532,23 @@ def to_h # @see MachO::Headers::FatHeader class FatArch < MachOStructure # @return [Integer] the CPU type of the Mach-O - attr_reader :cputype + field :cputype, :uint32, :endian => :big # @return [Integer] the CPU subtype of the Mach-O - attr_reader :cpusubtype + field :cpusubtype, :uint32, :endian => :big, :mask => CPU_SUBTYPE_MASK # @return [Integer] the file offset to the beginning of the Mach-O data - attr_reader :offset + field :offset, :uint32, :endian => :big # @return [Integer] the size, in bytes, of the Mach-O data - attr_reader :size + field :size, :uint32, :endian => :big # @return [Integer] the alignment, as a power of 2 - attr_reader :align - - # @note Always big endian. - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L>5" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 20 - - # @api private - def initialize(cputype, cpusubtype, offset, size, align) - super() - @cputype = cputype - @cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK - @offset = offset - @size = size - @align = align - end + field :align, :uint32, :endian => :big # @return [String] the serialized fields of the fat arch def serialize - [cputype, cpusubtype, offset, size, align].pack(FORMAT) + [cputype, cpusubtype, offset, size, align].pack(self.class.format) end # @return [Hash] a hash representation of this {FatArch} @@ -606,27 +571,18 @@ def to_h # Mach-Os that it points to necessarily *are* 64-bit. # @see MachO::Headers::FatHeader class FatArch64 < FatArch - # @return [void] - attr_reader :reserved - - # @note Always big endian. - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L>2Q>2L>2" + # @return [Integer] the file offset to the beginning of the Mach-O data + field :offset, :uint64, :endian => :big - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 32 + # @return [Integer] the size, in bytes, of the Mach-O data + field :size, :uint64, :endian => :big - # @api private - def initialize(cputype, cpusubtype, offset, size, align, reserved = 0) - super(cputype, cpusubtype, offset, size, align) - @reserved = reserved - end + # @return [void] + field :reserved, :uint32, :endian => :big, :default => 0 # @return [String] the serialized fields of the fat arch def serialize - [cputype, cpusubtype, offset, size, align, reserved].pack(FORMAT) + [cputype, cpusubtype, offset, size, align, reserved].pack(self.class.format) end # @return [Hash] a hash representation of this {FatArch64} @@ -640,48 +596,25 @@ def to_h # 32-bit Mach-O file header structure class MachHeader < MachOStructure # @return [Integer] the magic number - attr_reader :magic + field :magic, :uint32 # @return [Integer] the CPU type of the Mach-O - attr_reader :cputype + field :cputype, :uint32 # @return [Integer] the CPU subtype of the Mach-O - attr_reader :cpusubtype + field :cpusubtype, :uint32, :mask => CPU_SUBTYPE_MASK # @return [Integer] the file type of the Mach-O - attr_reader :filetype + field :filetype, :uint32 # @return [Integer] the number of load commands in the Mach-O - attr_reader :ncmds + field :ncmds, :uint32 # @return [Integer] the size of all load commands, in bytes, in the Mach-O - attr_reader :sizeofcmds + field :sizeofcmds, :uint32 # @return [Integer] the header flags associated with the Mach-O - attr_reader :flags - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=7" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 28 - - # @api private - def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, - flags) - super() - @magic = magic - @cputype = cputype - # For now we're not interested in additional capability bits also to be - # found in the `cpusubtype` field. We only care about the CPU sub-type. - @cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK - @filetype = filetype - @ncmds = ncmds - @sizeofcmds = sizeofcmds - @flags = flags - end + field :flags, :uint32 # @example # puts "this mach-o has position-independent execution" if header.flag?(:MH_PIE) @@ -787,22 +720,7 @@ def to_h # 64-bit Mach-O file header structure class MachHeader64 < MachHeader # @return [void] - attr_reader :reserved - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=8" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 32 - - # @api private - def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, - flags, reserved) - super(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags) - @reserved = reserved - end + field :reserved, :uint32 # @return [Hash] a hash representation of this {MachHeader64} def to_h @@ -815,54 +733,31 @@ def to_h # Prelinked kernel/"kernelcache" header structure class PrelinkedKernelHeader < MachOStructure # @return [Integer] the magic number for a compressed header ({COMPRESSED_MAGIC}) - attr_reader :signature + field :signature, :uint32, :endian => :big # @return [Integer] the type of compression used - attr_reader :compress_type + field :compress_type, :uint32, :endian => :big # @return [Integer] a checksum for the uncompressed data - attr_reader :adler32 + field :adler32, :uint32, :endian => :big # @return [Integer] the size of the uncompressed data, in bytes - attr_reader :uncompressed_size + field :uncompressed_size, :uint32, :endian => :big # @return [Integer] the size of the compressed data, in bytes - attr_reader :compressed_size + field :compressed_size, :uint32, :endian => :big # @return [Integer] the version of the prelink format - attr_reader :prelink_version + field :prelink_version, :uint32, :endian => :big # @return [void] - attr_reader :reserved + field :reserved, :string, :size => 40, :unpack => "L>10" # @return [void] - attr_reader :platform_name + field :platform_name, :string, :size => 64 # @return [void] - attr_reader :root_path - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L>6a40a64a256" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 384 - - # @api private - def initialize(signature, compress_type, adler32, uncompressed_size, compressed_size, prelink_version, reserved, platform_name, root_path) - super() - - @signature = signature - @compress_type = compress_type - @adler32 = adler32 - @uncompressed_size = uncompressed_size - @compressed_size = compressed_size - @prelink_version = prelink_version - @reserved = reserved.unpack("L>10") - @platform_name = platform_name - @root_path = root_path - end + field :root_path, :string, :size => 256 # @return [Boolean] whether this prelinked kernel supports KASLR def kaslr? diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/load_commands.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/load_commands.rb similarity index 69% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/load_commands.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/load_commands.rb index c1404e4c4a19a..c420c8bd99246 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/load_commands.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/load_commands.rb @@ -34,24 +34,24 @@ module LoadCommands 0x15 => :LC_SUB_LIBRARY, 0x16 => :LC_TWOLEVEL_HINTS, 0x17 => :LC_PREBIND_CKSUM, - (0x18 | LC_REQ_DYLD) => :LC_LOAD_WEAK_DYLIB, + (LC_REQ_DYLD | 0x18) => :LC_LOAD_WEAK_DYLIB, 0x19 => :LC_SEGMENT_64, 0x1a => :LC_ROUTINES_64, 0x1b => :LC_UUID, - (0x1c | LC_REQ_DYLD) => :LC_RPATH, + (LC_REQ_DYLD | 0x1c) => :LC_RPATH, 0x1d => :LC_CODE_SIGNATURE, 0x1e => :LC_SEGMENT_SPLIT_INFO, - (0x1f | LC_REQ_DYLD) => :LC_REEXPORT_DYLIB, + (LC_REQ_DYLD | 0x1f) => :LC_REEXPORT_DYLIB, 0x20 => :LC_LAZY_LOAD_DYLIB, 0x21 => :LC_ENCRYPTION_INFO, 0x22 => :LC_DYLD_INFO, - (0x22 | LC_REQ_DYLD) => :LC_DYLD_INFO_ONLY, - (0x23 | LC_REQ_DYLD) => :LC_LOAD_UPWARD_DYLIB, + (LC_REQ_DYLD | 0x22) => :LC_DYLD_INFO_ONLY, + (LC_REQ_DYLD | 0x23) => :LC_LOAD_UPWARD_DYLIB, 0x24 => :LC_VERSION_MIN_MACOSX, 0x25 => :LC_VERSION_MIN_IPHONEOS, 0x26 => :LC_FUNCTION_STARTS, 0x27 => :LC_DYLD_ENVIRONMENT, - (0x28 | LC_REQ_DYLD) => :LC_MAIN, + (LC_REQ_DYLD | 0x28) => :LC_MAIN, 0x29 => :LC_DATA_IN_CODE, 0x2a => :LC_SOURCE_VERSION, 0x2b => :LC_DYLIB_CODE_SIGN_DRS, @@ -62,9 +62,9 @@ module LoadCommands 0x30 => :LC_VERSION_MIN_WATCHOS, 0x31 => :LC_NOTE, 0x32 => :LC_BUILD_VERSION, - (0x33 | LC_REQ_DYLD) => :LC_DYLD_EXPORTS_TRIE, - (0x34 | LC_REQ_DYLD) => :LC_DYLD_CHAINED_FIXUPS, - (0x35 | LC_REQ_DYLD) => :LC_FILESET_ENTRY, + (LC_REQ_DYLD | 0x33) => :LC_DYLD_EXPORTS_TRIE, + (LC_REQ_DYLD | 0x34) => :LC_DYLD_CHAINED_FIXUPS, + (LC_REQ_DYLD | 0x35) => :LC_FILESET_ENTRY, }.freeze # association of symbol representations to load command constants @@ -160,12 +160,27 @@ module LoadCommands SEGMENT_NAMES = { :SEG_PAGEZERO => "__PAGEZERO", :SEG_TEXT => "__TEXT", + :SEG_TEXT_EXEC => "__TEXT_EXEC", :SEG_DATA => "__DATA", + :SEG_DATA_CONST => "__DATA_CONST", :SEG_OBJC => "__OBJC", + :SEG_OBJC_CONST => "__OBJC_CONST", :SEG_ICON => "__ICON", :SEG_LINKEDIT => "__LINKEDIT", + :SEG_LINKINFO => "__LINKINFO", :SEG_UNIXSTACK => "__UNIXSTACK", :SEG_IMPORT => "__IMPORT", + :SEG_KLD => "__KLD", + :SEG_KLDDATA => "__KLDDATA", + :SEG_HIB => "__HIB", + :SEG_VECTORS => "__VECTORS", + :SEG_LAST => "__LAST", + :SEG_LASTDATA_CONST => "__LASTDATA_CONST", + :SEG_PRELINK_TEXT => "__PRELINK_TEXT", + :SEG_PRELINK_INFO => "__PRELINK_INFO", + :SEG_CTF => "__CTF", + :SEG_AUTH => "__AUTH", + :SEG_AUTH_CONST => "__AUTH_CONST", }.freeze # association of segment flag symbols to values @@ -185,21 +200,13 @@ module LoadCommands class LoadCommand < MachOStructure # @return [MachO::MachOView, nil] the raw view associated with the load command, # or nil if the load command was created via {create}. - attr_reader :view + field :view, :view # @return [Integer] the load command's type ID - attr_reader :cmd + field :cmd, :uint32 # @return [Integer] the size of the load command, in bytes - attr_reader :cmdsize - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 8 + field :cmdsize, :uint32 # Instantiates a new LoadCommand given a view into its origin Mach-O # @param view [MachO::MachOView] the load command's raw view @@ -207,7 +214,7 @@ class LoadCommand < MachOStructure # @api private def self.new_from_bin(view) bin = view.raw_data.slice(view.offset, bytesize) - format = Utils.specialize_format(self::FORMAT, view.endianness) + format = Utils.specialize_format(self.format, view.endianness) new(view, *bin.unpack(format)) end @@ -222,24 +229,13 @@ def self.create(cmd_sym, *args) cmd = LOAD_COMMAND_CONSTANTS[cmd_sym] # cmd will be filled in, view and cmdsize will be left unpopulated - klass_arity = klass.instance_method(:initialize).arity - 3 + klass_arity = klass.min_args - 3 - raise LoadCommandCreationArityError.new(cmd_sym, klass_arity, args.size) if klass_arity != args.size + raise LoadCommandCreationArityError.new(cmd_sym, klass_arity, args.size) if klass_arity > args.size klass.new(nil, cmd, nil, *args) end - # @param view [MachO::MachOView] the load command's raw view - # @param cmd [Integer] the load command's identifying number - # @param cmdsize [Integer] the size of the load command in bytes - # @api private - def initialize(view, cmd, cmdsize) - super() - @view = view - @cmd = cmd - @cmdsize = cmdsize - end - # @return [Boolean] whether the load command can be serialized def serializable? CREATABLE_LOAD_COMMANDS.include?(LOAD_COMMANDS[cmd]) @@ -253,8 +249,8 @@ def serializable? def serialize(context) raise LoadCommandNotSerializableError, LOAD_COMMANDS[cmd] unless serializable? - format = Utils.specialize_format(FORMAT, context.endianness) - [cmd, SIZEOF].pack(format) + format = Utils.specialize_format(self.class.format, context.endianness) + [cmd, self.class.bytesize].pack(format) end # @return [Integer] the load command's offset in the source file @@ -371,21 +367,7 @@ def initialize(endianness, alignment) # LC_UUID. class UUIDCommand < LoadCommand # @return [Array] the UUID - attr_reader :uuid - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2a16" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 24 - - # @api private - def initialize(view, cmd, cmdsize, uuid) - super(view, cmd, cmdsize) - @uuid = uuid.unpack("C16") # re-unpack for the actual UUID array - end + field :uuid, :string, :size => 16, :unpack => "C16" # @return [String] a string representation of the UUID def uuid_string @@ -398,6 +380,11 @@ def uuid_string segs.join("-") end + # @return [String] an alias for uuid_string + def to_s + uuid_string + end + # @return [Hash] returns a hash representation of this {UUIDCommand} def to_h { @@ -411,54 +398,31 @@ def to_h # the task's address space. Corresponds to LC_SEGMENT. class SegmentCommand < LoadCommand # @return [String] the name of the segment - attr_reader :segname + field :segname, :string, :padding => :null, :size => 16, :to_s => true # @return [Integer] the memory address of the segment - attr_reader :vmaddr + field :vmaddr, :uint32 # @return [Integer] the memory size of the segment - attr_reader :vmsize + field :vmsize, :uint32 # @return [Integer] the file offset of the segment - attr_reader :fileoff + field :fileoff, :uint32 # @return [Integer] the amount to map from the file - attr_reader :filesize + field :filesize, :uint32 # @return [Integer] the maximum VM protection - attr_reader :maxprot + field :maxprot, :int32 # @return [Integer] the initial VM protection - attr_reader :initprot + field :initprot, :int32 # @return [Integer] the number of sections in the segment - attr_reader :nsects + field :nsects, :uint32 # @return [Integer] any flags associated with the segment - attr_reader :flags - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Z16L=4l=2L=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 56 - - # @api private - def initialize(view, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, - filesize, maxprot, initprot, nsects, flags) - super(view, cmd, cmdsize) - @segname = segname - @vmaddr = vmaddr - @vmsize = vmsize - @fileoff = fileoff - @filesize = filesize - @maxprot = maxprot - @initprot = initprot - @nsects = nsects - @flags = flags - end + field :flags, :uint32 # All sections referenced within this segment. # @return [Array] if the Mach-O is 32-bit @@ -532,13 +496,17 @@ def to_h # A load command indicating that part of this file is to be mapped into # the task's address space. Corresponds to LC_SEGMENT_64. class SegmentCommand64 < SegmentCommand - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Z16Q=4l=2L=2" + # @return [Integer] the memory address of the segment + field :vmaddr, :uint64 - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 72 + # @return [Integer] the memory size of the segment + field :vmsize, :uint64 + + # @return [Integer] the file offset of the segment + field :fileoff, :uint64 + + # @return [Integer] the amount to map from the file + field :filesize, :uint64 end # A load command representing some aspect of shared libraries, depending @@ -547,45 +515,27 @@ class SegmentCommand64 < SegmentCommand class DylibCommand < LoadCommand # @return [LCStr] the library's path # name as an LCStr - attr_reader :name + field :name, :lcstr, :to_s => true # @return [Integer] the library's build time stamp - attr_reader :timestamp + field :timestamp, :uint32 # @return [Integer] the library's current version number - attr_reader :current_version + field :current_version, :uint32 # @return [Integer] the library's compatibility version number - attr_reader :compatibility_version - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=6" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 24 - - # @api private - def initialize(view, cmd, cmdsize, name, timestamp, current_version, - compatibility_version) - super(view, cmd, cmdsize) - @name = LCStr.new(self, name) - @timestamp = timestamp - @current_version = current_version - @compatibility_version = compatibility_version - end + field :compatibility_version, :uint32 # @param context [SerializationContext] # the context # @return [String] the serialized fields of the load command # @api private def serialize(context) - format = Utils.specialize_format(FORMAT, context.endianness) - string_payload, string_offsets = Utils.pack_strings(SIZEOF, + format = Utils.specialize_format(self.class.format, context.endianness) + string_payload, string_offsets = Utils.pack_strings(self.class.bytesize, context.alignment, :name => name.to_s) - cmdsize = SIZEOF + string_payload.bytesize + cmdsize = self.class.bytesize + string_payload.bytesize [cmd, cmdsize, string_offsets[:name], timestamp, current_version, compatibility_version].pack(format) + string_payload end @@ -607,32 +557,18 @@ def to_h class DylinkerCommand < LoadCommand # @return [LCStr] the dynamic linker's # path name as an LCStr - attr_reader :name - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, name) - super(view, cmd, cmdsize) - @name = LCStr.new(self, name) - end + field :name, :lcstr, :to_s => true # @param context [SerializationContext] # the context # @return [String] the serialized fields of the load command # @api private def serialize(context) - format = Utils.specialize_format(FORMAT, context.endianness) - string_payload, string_offsets = Utils.pack_strings(SIZEOF, + format = Utils.specialize_format(self.class.format, context.endianness) + string_payload, string_offsets = Utils.pack_strings(self.class.bytesize, context.alignment, :name => name.to_s) - cmdsize = SIZEOF + string_payload.bytesize + cmdsize = self.class.bytesize + string_payload.bytesize [cmd, cmdsize, string_offsets[:name]].pack(format) + string_payload end @@ -649,29 +585,13 @@ def to_h class PreboundDylibCommand < LoadCommand # @return [LCStr] the library's path # name as an LCStr - attr_reader :name + field :name, :lcstr, :to_s => true # @return [Integer] the number of modules in the library - attr_reader :nmodules + field :nmodules, :uint32 # @return [Integer] a bit vector of linked modules - attr_reader :linked_modules - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=5" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 20 - - # @api private - def initialize(view, cmd, cmdsize, name, nmodules, linked_modules) - super(view, cmd, cmdsize) - @name = LCStr.new(self, name) - @nmodules = nmodules - @linked_modules = linked_modules - end + field :linked_modules, :uint32 # @return [Hash] a hash representation of this {PreboundDylibCommand} def to_h @@ -687,13 +607,6 @@ def to_h # @note cctools-870 and onwards have all fields of thread_command commented # out except the common ones (cmd, cmdsize) class ThreadCommand < LoadCommand - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 8 end # A load command containing the address of the dynamic shared library @@ -701,51 +614,29 @@ class ThreadCommand < LoadCommand # that defines the routine. Corresponds to LC_ROUTINES. class RoutinesCommand < LoadCommand # @return [Integer] the address of the initialization routine - attr_reader :init_address + field :init_address, :uint32 # @return [Integer] the index into the module table that the init routine # is defined in - attr_reader :init_module + field :init_module, :uint32 # @return [void] - attr_reader :reserved1 + field :reserved1, :uint32 # @return [void] - attr_reader :reserved2 + field :reserved2, :uint32 # @return [void] - attr_reader :reserved3 + field :reserved3, :uint32 # @return [void] - attr_reader :reserved4 + field :reserved4, :uint32 # @return [void] - attr_reader :reserved5 + field :reserved5, :uint32 # @return [void] - attr_reader :reserved6 - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=10" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 40 - - # @api private - def initialize(view, cmd, cmdsize, init_address, init_module, reserved1, - reserved2, reserved3, reserved4, reserved5, reserved6) - super(view, cmd, cmdsize) - @init_address = init_address - @init_module = init_module - @reserved1 = reserved1 - @reserved2 = reserved2 - @reserved3 = reserved3 - @reserved4 = reserved4 - @reserved5 = reserved5 - @reserved6 = reserved6 - end + field :reserved6, :uint32 # @return [Hash] a hash representation of this {RoutinesCommand} def to_h @@ -766,34 +657,37 @@ def to_h # initialization routine and an index into the module table for the module # that defines the routine. Corresponds to LC_ROUTINES_64. class RoutinesCommand64 < RoutinesCommand - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Q=8" + # @return [Integer] the address of the initialization routine + field :init_address, :uint64 - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 72 + # @return [Integer] the index into the module table that the init routine + # is defined in + field :init_module, :uint64 + + # @return [void] + field :reserved1, :uint64 + + # @return [void] + field :reserved2, :uint64 + + # @return [void] + field :reserved3, :uint64 + + # @return [void] + field :reserved4, :uint64 + + # @return [void] + field :reserved5, :uint64 + + # @return [void] + field :reserved6, :uint64 end # A load command signifying membership of a subframework containing the name # of an umbrella framework. Corresponds to LC_SUB_FRAMEWORK. class SubFrameworkCommand < LoadCommand # @return [LCStr] the umbrella framework name as an LCStr - attr_reader :umbrella - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, umbrella) - super(view, cmd, cmdsize) - @umbrella = LCStr.new(self, umbrella) - end + field :umbrella, :lcstr, :to_s => true # @return [Hash] a hash representation of this {SubFrameworkCommand} def to_h @@ -807,21 +701,7 @@ def to_h # of an umbrella framework. Corresponds to LC_SUB_UMBRELLA. class SubUmbrellaCommand < LoadCommand # @return [LCStr] the subumbrella framework name as an LCStr - attr_reader :sub_umbrella - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, sub_umbrella) - super(view, cmd, cmdsize) - @sub_umbrella = LCStr.new(self, sub_umbrella) - end + field :sub_umbrella, :lcstr, :to_s => true # @return [Hash] a hash representation of this {SubUmbrellaCommand} def to_h @@ -835,21 +715,7 @@ def to_h # to LC_SUB_LIBRARY. class SubLibraryCommand < LoadCommand # @return [LCStr] the sublibrary name as an LCStr - attr_reader :sub_library - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, sub_library) - super(view, cmd, cmdsize) - @sub_library = LCStr.new(self, sub_library) - end + field :sub_library, :lcstr, :to_s => true # @return [Hash] a hash representation of this {SubLibraryCommand} def to_h @@ -863,21 +729,7 @@ def to_h # an umbrella framework. Corresponds to LC_SUB_CLIENT. class SubClientCommand < LoadCommand # @return [LCStr] the subclient name as an LCStr - attr_reader :sub_client - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, sub_client) - super(view, cmd, cmdsize) - @sub_client = LCStr.new(self, sub_client) - end + field :sub_client, :lcstr, :to_s => true # @return [Hash] a hash representation of this {SubClientCommand} def to_h @@ -891,33 +743,16 @@ def to_h # "stab" style symbol table information. Corresponds to LC_SYMTAB. class SymtabCommand < LoadCommand # @return [Integer] the symbol table's offset - attr_reader :symoff + field :symoff, :uint32 # @return [Integer] the number of symbol table entries - attr_reader :nsyms + field :nsyms, :uint32 # @return [Integer] the string table's offset - attr_reader :stroff + field :stroff, :uint32 # @return [Integer] the string table size in bytes - attr_reader :strsize - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=6" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 24 - - # @api private - def initialize(view, cmd, cmdsize, symoff, nsyms, stroff, strsize) - super(view, cmd, cmdsize) - @symoff = symoff - @nsyms = nsyms - @stroff = stroff - @strsize = strsize - end + field :strsize, :uint32 # @return [Hash] a hash representation of this {SymtabCommand} def to_h @@ -934,93 +769,58 @@ def to_h # structures used by the dynamic link editor. Corresponds to LC_DYSYMTAB. class DysymtabCommand < LoadCommand # @return [Integer] the index to local symbols - attr_reader :ilocalsym + field :ilocalsym, :uint32 # @return [Integer] the number of local symbols - attr_reader :nlocalsym + field :nlocalsym, :uint32 # @return [Integer] the index to externally defined symbols - attr_reader :iextdefsym + field :iextdefsym, :uint32 # @return [Integer] the number of externally defined symbols - attr_reader :nextdefsym + field :nextdefsym, :uint32 # @return [Integer] the index to undefined symbols - attr_reader :iundefsym + field :iundefsym, :uint32 # @return [Integer] the number of undefined symbols - attr_reader :nundefsym + field :nundefsym, :uint32 # @return [Integer] the file offset to the table of contents - attr_reader :tocoff + field :tocoff, :uint32 # @return [Integer] the number of entries in the table of contents - attr_reader :ntoc + field :ntoc, :uint32 # @return [Integer] the file offset to the module table - attr_reader :modtaboff + field :modtaboff, :uint32 # @return [Integer] the number of entries in the module table - attr_reader :nmodtab + field :nmodtab, :uint32 # @return [Integer] the file offset to the referenced symbol table - attr_reader :extrefsymoff + field :extrefsymoff, :uint32 # @return [Integer] the number of entries in the referenced symbol table - attr_reader :nextrefsyms + field :nextrefsyms, :uint32 # @return [Integer] the file offset to the indirect symbol table - attr_reader :indirectsymoff + field :indirectsymoff, :uint32 # @return [Integer] the number of entries in the indirect symbol table - attr_reader :nindirectsyms + field :nindirectsyms, :uint32 # @return [Integer] the file offset to the external relocation entries - attr_reader :extreloff + field :extreloff, :uint32 # @return [Integer] the number of external relocation entries - attr_reader :nextrel + field :nextrel, :uint32 # @return [Integer] the file offset to the local relocation entries - attr_reader :locreloff + field :locreloff, :uint32 # @return [Integer] the number of local relocation entries - attr_reader :nlocrel - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=20" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 80 - - # ugh - # @api private - def initialize(view, cmd, cmdsize, ilocalsym, nlocalsym, iextdefsym, - nextdefsym, iundefsym, nundefsym, tocoff, ntoc, modtaboff, - nmodtab, extrefsymoff, nextrefsyms, indirectsymoff, - nindirectsyms, extreloff, nextrel, locreloff, nlocrel) - super(view, cmd, cmdsize) - @ilocalsym = ilocalsym - @nlocalsym = nlocalsym - @iextdefsym = iextdefsym - @nextdefsym = nextdefsym - @iundefsym = iundefsym - @nundefsym = nundefsym - @tocoff = tocoff - @ntoc = ntoc - @modtaboff = modtaboff - @nmodtab = nmodtab - @extrefsymoff = extrefsymoff - @nextrefsyms = nextrefsyms - @indirectsymoff = indirectsymoff - @nindirectsyms = nindirectsyms - @extreloff = extreloff - @nextrel = nextrel - @locreloff = locreloff - @nlocrel = nlocrel - end + field :nlocrel, :uint32 # @return [Hash] a hash representation of this {DysymtabCommand} def to_h @@ -1051,30 +851,14 @@ def to_h # namespace lookup hints table. Corresponds to LC_TWOLEVEL_HINTS. class TwolevelHintsCommand < LoadCommand # @return [Integer] the offset to the hint table - attr_reader :htoffset + field :htoffset, :uint32 # @return [Integer] the number of hints in the hint table - attr_reader :nhints + field :nhints, :uint32 # @return [TwolevelHintsTable] # the hint table - attr_reader :table - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=4" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 16 - - # @api private - def initialize(view, cmd, cmdsize, htoffset, nhints) - super(view, cmd, cmdsize) - @htoffset = htoffset - @nhints = nhints - @table = TwolevelHintsTable.new(view, htoffset, nhints) - end + field :table, :two_level_hints_table # @return [Hash] a hash representation of this {TwolevelHintsCommand} def to_h @@ -1133,21 +917,7 @@ def to_h # files, or zero. Corresponds to LC_PREBIND_CKSUM. class PrebindCksumCommand < LoadCommand # @return [Integer] the checksum or 0 - attr_reader :cksum - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, cksum) - super(view, cmd, cmdsize) - @cksum = cksum - end + field :cksum, :uint32 # @return [Hash] a hash representation of this {PrebindCksumCommand} def to_h @@ -1162,31 +932,17 @@ def to_h # Corresponds to LC_RPATH. class RpathCommand < LoadCommand # @return [LCStr] the path to add to the run path as an LCStr - attr_reader :path - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, path) - super(view, cmd, cmdsize) - @path = LCStr.new(self, path) - end + field :path, :lcstr, :to_s => true # @param context [SerializationContext] the context # @return [String] the serialized fields of the load command # @api private def serialize(context) - format = Utils.specialize_format(FORMAT, context.endianness) - string_payload, string_offsets = Utils.pack_strings(SIZEOF, + format = Utils.specialize_format(self.class.format, context.endianness) + string_payload, string_offsets = Utils.pack_strings(self.class.bytesize, context.alignment, :path => path.to_s) - cmdsize = SIZEOF + string_payload.bytesize + cmdsize = self.class.bytesize + string_payload.bytesize [cmd, cmdsize, string_offsets[:path]].pack(format) + string_payload end @@ -1205,25 +961,10 @@ def to_h # or LC_DYLD_CHAINED_FIXUPS. class LinkeditDataCommand < LoadCommand # @return [Integer] offset to the data in the __LINKEDIT segment - attr_reader :dataoff + field :dataoff, :uint32 # @return [Integer] size of the data in the __LINKEDIT segment - attr_reader :datasize - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=4" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 16 - - # @api private - def initialize(view, cmd, cmdsize, dataoff, datasize) - super(view, cmd, cmdsize) - @dataoff = dataoff - @datasize = datasize - end + field :datasize, :uint32 # @return [Hash] a hash representation of this {LinkeditDataCommand} def to_h @@ -1238,29 +979,13 @@ def to_h # segment. Corresponds to LC_ENCRYPTION_INFO. class EncryptionInfoCommand < LoadCommand # @return [Integer] the offset to the encrypted segment - attr_reader :cryptoff + field :cryptoff, :uint32 # @return [Integer] the size of the encrypted segment - attr_reader :cryptsize + field :cryptsize, :uint32 # @return [Integer] the encryption system, or 0 if not encrypted yet - attr_reader :cryptid - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=5" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 20 - - # @api private - def initialize(view, cmd, cmdsize, cryptoff, cryptsize, cryptid) - super(view, cmd, cmdsize) - @cryptoff = cryptoff - @cryptsize = cryptsize - @cryptid = cryptid - end + field :cryptid, :uint32 # @return [Hash] a hash representation of this {EncryptionInfoCommand} def to_h @@ -1276,21 +1001,7 @@ def to_h # segment. Corresponds to LC_ENCRYPTION_INFO_64. class EncryptionInfoCommand64 < EncryptionInfoCommand # @return [Integer] 64-bit padding value - attr_reader :pad - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=6" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 24 - - # @api private - def initialize(view, cmd, cmdsize, cryptoff, cryptsize, cryptid, pad) - super(view, cmd, cmdsize, cryptoff, cryptsize, cryptid) - @pad = pad - end + field :pad, :uint32 # @return [Hash] a hash representation of this {EncryptionInfoCommand64} def to_h @@ -1305,25 +1016,10 @@ def to_h # LC_VERSION_MIN_IPHONEOS. class VersionMinCommand < LoadCommand # @return [Integer] the version X.Y.Z packed as x16.y8.z8 - attr_reader :version + field :version, :uint32 # @return [Integer] the SDK version X.Y.Z packed as x16.y8.z8 - attr_reader :sdk - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=4" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 16 - - # @api private - def initialize(view, cmd, cmdsize, version, sdk) - super(view, cmd, cmdsize) - @version = version - @sdk = sdk - end + field :sdk, :uint32 # A string representation of the binary's minimum OS version. # @return [String] a string representing the minimum OS version. @@ -1363,33 +1059,16 @@ def to_h # Corresponds to LC_BUILD_VERSION. class BuildVersionCommand < LoadCommand # @return [Integer] - attr_reader :platform + field :platform, :uint32 # @return [Integer] the minimum OS version X.Y.Z packed as x16.y8.z8 - attr_reader :minos + field :minos, :uint32 # @return [Integer] the SDK version X.Y.Z packed as x16.y8.z8 - attr_reader :sdk + field :sdk, :uint32 # @return [ToolEntries] tool entries - attr_reader :tool_entries - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=6" - - # @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 + field :tool_entries, :tool_entries # A string representation of the binary's minimum OS version. # @return [String] a string representing the minimum OS version. @@ -1474,59 +1153,34 @@ def to_h # Corresponds to LC_DYLD_INFO and LC_DYLD_INFO_ONLY. class DyldInfoCommand < LoadCommand # @return [Integer] the file offset to the rebase information - attr_reader :rebase_off + field :rebase_off, :uint32 # @return [Integer] the size of the rebase information - attr_reader :rebase_size + field :rebase_size, :uint32 # @return [Integer] the file offset to the binding information - attr_reader :bind_off + field :bind_off, :uint32 # @return [Integer] the size of the binding information - attr_reader :bind_size + field :bind_size, :uint32 # @return [Integer] the file offset to the weak binding information - attr_reader :weak_bind_off + field :weak_bind_off, :uint32 # @return [Integer] the size of the weak binding information - attr_reader :weak_bind_size + field :weak_bind_size, :uint32 # @return [Integer] the file offset to the lazy binding information - attr_reader :lazy_bind_off + field :lazy_bind_off, :uint32 # @return [Integer] the size of the lazy binding information - attr_reader :lazy_bind_size + field :lazy_bind_size, :uint32 # @return [Integer] the file offset to the export information - attr_reader :export_off + field :export_off, :uint32 # @return [Integer] the size of the export information - attr_reader :export_size - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=12" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 48 - - # @api private - def initialize(view, cmd, cmdsize, rebase_off, rebase_size, bind_off, - bind_size, weak_bind_off, weak_bind_size, lazy_bind_off, - lazy_bind_size, export_off, export_size) - super(view, cmd, cmdsize) - @rebase_off = rebase_off - @rebase_size = rebase_size - @bind_off = bind_off - @bind_size = bind_size - @weak_bind_off = weak_bind_off - @weak_bind_size = weak_bind_size - @lazy_bind_off = lazy_bind_off - @lazy_bind_size = lazy_bind_size - @export_off = export_off - @export_size = export_size - end + field :export_size, :uint32 # @return [Hash] a hash representation of this {DyldInfoCommand} def to_h @@ -1549,21 +1203,7 @@ def to_h # Corresponds to LC_LINKER_OPTION. class LinkerOptionCommand < LoadCommand # @return [Integer] the number of strings - attr_reader :count - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=3" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 12 - - # @api private - def initialize(view, cmd, cmdsize, count) - super(view, cmd, cmdsize) - @count = count - end + field :count, :uint32 # @return [Hash] a hash representation of this {LinkerOptionCommand} def to_h @@ -1576,25 +1216,10 @@ def to_h # A load command specifying the offset of main(). Corresponds to LC_MAIN. class EntryPointCommand < LoadCommand # @return [Integer] the file (__TEXT) offset of main() - attr_reader :entryoff + field :entryoff, :uint64 # @return [Integer] if not 0, the initial stack size. - attr_reader :stacksize - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Q=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 24 - - # @api private - def initialize(view, cmd, cmdsize, entryoff, stacksize) - super(view, cmd, cmdsize) - @entryoff = entryoff - @stacksize = stacksize - end + field :stacksize, :uint64 # @return [Hash] a hash representation of this {EntryPointCommand} def to_h @@ -1609,21 +1234,7 @@ def to_h # binary. Corresponds to LC_SOURCE_VERSION. class SourceVersionCommand < LoadCommand # @return [Integer] the version packed as a24.b10.c10.d10.e10 - attr_reader :version - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Q=1" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 16 - - # @api private - def initialize(view, cmd, cmdsize, version) - super(view, cmd, cmdsize) - @version = version - end + field :version, :uint64 # A string representation of the sources used to build the binary. # @return [String] a string representation of the version @@ -1650,25 +1261,10 @@ def to_h # symbol table information. Corresponds to LC_SYMSEG. class SymsegCommand < LoadCommand # @return [Integer] the offset to the symbol segment - attr_reader :offset + field :offset, :uint32 # @return [Integer] the size of the symbol segment in bytes - attr_reader :size - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=4" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 16 - - # @api private - def initialize(view, cmd, cmdsize, offset, size) - super(view, cmd, cmdsize) - @offset = offset - @size = size - end + field :size, :uint32 # @return [Hash] a hash representation of this {SymsegCommand} def to_h @@ -1683,37 +1279,16 @@ def to_h # string is null-terminated and the command is zero-padded to a multiple of # 4. Corresponds to LC_IDENT. class IdentCommand < LoadCommand - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 8 end # An obsolete load command containing the path to a file to be loaded into # memory. Corresponds to LC_FVMFILE. class FvmfileCommand < LoadCommand # @return [LCStr] the pathname of the file being loaded - attr_reader :name + field :name, :lcstr, :to_s => true # @return [Integer] the virtual address being loaded at - attr_reader :header_addr - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=4" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 16 - - def initialize(view, cmd, cmdsize, name, header_addr) - super(view, cmd, cmdsize) - @name = LCStr.new(self, name) - @header_addr = header_addr - end + field :header_addr, :uint32 # @return [Hash] a hash representation of this {FvmfileCommand} def to_h @@ -1728,28 +1303,13 @@ def to_h # into memory. Corresponds to LC_LOADFVMLIB and LC_IDFVMLIB. class FvmlibCommand < LoadCommand # @return [LCStr] the library's target pathname - attr_reader :name + field :name, :lcstr, :to_s => true # @return [Integer] the library's minor version number - attr_reader :minor_version + field :minor_version, :uint32 # @return [Integer] the library's header address - attr_reader :header_addr - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=5" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 20 - - def initialize(view, cmd, cmdsize, name, minor_version, header_addr) - super(view, cmd, cmdsize) - @name = LCStr.new(self, name) - @minor_version = minor_version - @header_addr = header_addr - end + field :header_addr, :uint32 # @return [Hash] a hash representation of this {FvmlibCommand} def to_h @@ -1765,28 +1325,13 @@ def to_h # Corresponds to LC_NOTE. class NoteCommand < LoadCommand # @return [String] the name of the owner for this note - attr_reader :data_owner + field :data_owner, :string, :padding => :null, :size => 16, :to_s => true # @return [Integer] the offset, within the file, of the note - attr_reader :offset + field :offset, :uint64 # @return [Integer] the size, in bytes, of the note - attr_reader :size - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Z16Q=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 48 - - def initialize(view, cmd, cmdsize, data_owner, offset, size) - super(view, cmd, cmdsize) - @data_owner = data_owner - @offset = offset - @size = size - end + field :size, :uint64 # @return [Hash] a hash representation of this {NoteCommand} def to_h @@ -1803,32 +1348,16 @@ def to_h # Corresponds to LC_FILESET_ENTRY. class FilesetEntryCommand < LoadCommand # @return [Integer] the virtual memory address of the entry - attr_reader :vmaddr + field :vmaddr, :uint64 # @return [Integer] the file offset of the entry - attr_reader :fileoff + field :fileoff, :uint64 # @return [LCStr] the entry's ID - attr_reader :entry_id + field :entry_id, :lcstr, :to_s => true # @return [void] - attr_reader :reserved - - # @see MachOStructure::FORMAT - # @api private - FORMAT = "L=2Q=2L=2" - - # @see MachOStructure::SIZEOF - # @api private - SIZEOF = 28 - - def initialize(view, cmd, cmdsize, vmaddr, fileoff, entry_id, reserved) - super(view, cmd, cmdsize) - @vmaddr = vmaddr - @fileoff = fileoff - @entry_id = LCStr.new(self, entry_id) - @reserved = reserved - end + field :reserved, :uint32 # @return [Hash] a hash representation of this {FilesetEntryCommand} def to_h @@ -1839,6 +1368,11 @@ def to_h "reserved" => reserved, }.merge super end + + # @return [SegmentCommand64, nil] the matching segment command or nil if nothing matches + def segment + view.macho_file.command(:LC_SEGMENT_64).select { |cmd| cmd.fileoff == fileoff }.first + end end end end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/macho_file.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/macho_file.rb similarity index 97% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/macho_file.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/macho_file.rb index af9df10956ca3..f48bfa5eb2a46 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/macho_file.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/macho_file.rb @@ -381,11 +381,9 @@ def rpaths # rpaths simultaneously. # @return [void] # @raise [RpathUnknownError] if no such old runtime path exists - # @raise [RpathExistsError] if the new runtime path already exists def change_rpath(old_path, new_path, options = {}) old_lc = command(:LC_RPATH).find { |r| r.path.to_s == old_path } raise RpathUnknownError, old_path if old_lc.nil? - raise RpathExistsError, new_path if rpaths.include?(new_path) new_lc = LoadCommands::LoadCommand.create(:LC_RPATH, new_path) @@ -420,15 +418,24 @@ def add_rpath(path, _options = {}) # @param options [Hash] # @option options [Boolean] :uniq (false) if true, also delete # duplicates of the requested path. If false, delete the first - # instance (by offset) of the requested path. + # instance (by offset) of the requested path, unless :last is true. + # Incompatible with :last. + # @option options [Boolean] :last (false) if true, delete the last + # instance (by offset) of the requested path. Incompatible with :uniq. # @return void # @raise [RpathUnknownError] if no such runtime path exists + # @raise [ArgumentError] if both :uniq and :last are true def delete_rpath(path, options = {}) uniq = options.fetch(:uniq, false) - search_method = uniq ? :select : :find + last = options.fetch(:last, false) + raise ArgumentError, "Cannot set both :uniq and :last to true" if uniq && last + + search_method = uniq || last ? :select : :find + rpath_cmds = command(:LC_RPATH).public_send(search_method) { |r| r.path.to_s == path } + rpath_cmds = rpath_cmds.last if last # Cast rpath_cmds into an Array so we can handle the uniq and non-uniq cases the same way - rpath_cmds = Array(command(:LC_RPATH).method(search_method).call { |r| r.path.to_s == path }) + rpath_cmds = Array(rpath_cmds) raise RpathUnknownError, path if rpath_cmds.empty? # delete the commands in reverse order, offset descending. @@ -592,7 +599,7 @@ def populate_load_commands LoadCommands::LoadCommand end - view = MachOView.new(@raw_data, endianness, offset) + view = MachOView.new(self, @raw_data, endianness, offset) command = klass.new_from_bin(view) load_commands << command diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/sections.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/sections.rb similarity index 81% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/sections.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/sections.rb index ab9650ad67b07..0b48808de22fa 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/sections.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/sections.rb @@ -89,61 +89,38 @@ module Sections # Represents a section of a segment for 32-bit architectures. class Section < MachOStructure # @return [String] the name of the section, including null pad bytes - attr_reader :sectname + field :sectname, :string, :padding => :null, :size => 16 # @return [String] the name of the segment's section, including null # pad bytes - attr_reader :segname + field :segname, :string, :padding => :null, :size => 16 # @return [Integer] the memory address of the section - attr_reader :addr + field :addr, :uint32 # @return [Integer] the size, in bytes, of the section - attr_reader :size + field :size, :uint32 # @return [Integer] the file offset of the section - attr_reader :offset + field :offset, :uint32 # @return [Integer] the section alignment (power of 2) of the section - attr_reader :align + field :align, :uint32 # @return [Integer] the file offset of the section's relocation entries - attr_reader :reloff + field :reloff, :uint32 # @return [Integer] the number of relocation entries - attr_reader :nreloc + field :nreloc, :uint32 # @return [Integer] flags for type and attributes of the section - attr_reader :flags + field :flags, :uint32 # @return [void] reserved (for offset or index) - attr_reader :reserved1 + field :reserved1, :uint32 # @return [void] reserved (for count or sizeof) - attr_reader :reserved2 - - # @see MachOStructure::FORMAT - FORMAT = "Z16Z16L=9" - - # @see MachOStructure::SIZEOF - SIZEOF = 68 - - # @api private - def initialize(sectname, segname, addr, size, offset, align, reloff, - nreloc, flags, reserved1, reserved2) - super() - @sectname = sectname - @segname = segname - @addr = addr - @size = size - @offset = offset - @align = align - @reloff = reloff - @nreloc = nreloc - @flags = flags - @reserved1 = reserved1 - @reserved2 = reserved2 - end + field :reserved2, :uint32 # @return [String] the section's name def section_name @@ -219,22 +196,14 @@ def to_h # Represents a section of a segment for 64-bit architectures. class Section64 < Section - # @return [void] reserved - attr_reader :reserved3 - - # @see MachOStructure::FORMAT - FORMAT = "Z16Z16Q=2L=8" + # @return [Integer] the memory address of the section + field :addr, :uint64 - # @see MachOStructure::SIZEOF - SIZEOF = 80 + # @return [Integer] the size, in bytes, of the section + field :size, :uint64 - # @api private - def initialize(sectname, segname, addr, size, offset, align, reloff, - nreloc, flags, reserved1, reserved2, reserved3) - super(sectname, segname, addr, size, offset, align, reloff, - nreloc, flags, reserved1, reserved2) - @reserved3 = reserved3 - end + # @return [void] reserved + field :reserved3, :uint32 # @return [Hash] a hash representation of this {Section64} def to_h diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/structure.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/structure.rb new file mode 100644 index 0000000000000..06949a937685c --- /dev/null +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/structure.rb @@ -0,0 +1,284 @@ +# frozen_string_literal: true + +module MachO + # A general purpose pseudo-structure. Described in detail in docs/machostructure-dsl.md. + # @abstract + class MachOStructure + # Constants used for parsing MachOStructure fields + module Fields + # 1. All fields with empty strings and zeros aren't used + # to calculate the format and sizeof variables. + # 2. All fields with nil should provide those values manually + # via the :size parameter. + + # association of field types to byte size + # @api private + BYTE_SIZE = { + # Binary slices + :string => nil, + :null_padded_string => nil, + :int32 => 4, + :uint32 => 4, + :uint64 => 8, + # Classes + :view => 0, + :lcstr => 4, + :two_level_hints_table => 0, + :tool_entries => 4, + }.freeze + + # association of field types with ruby format codes + # Binary format codes can be found here: + # https://docs.ruby-lang.org/en/2.6.0/String.html#method-i-unpack + # + # The equals sign is used to manually change endianness using + # the Utils#specialize_format() method. + # @api private + FORMAT_CODE = { + # Binary slices + :string => "a", + :null_padded_string => "Z", + :int32 => "l=", + :uint32 => "L=", + :uint64 => "Q=", + # Classes + :view => "", + :lcstr => "L=", + :two_level_hints_table => "", + :tool_entries => "L=", + }.freeze + + # A list of classes that must get initialized + # To add a new class append it here and add the init method to the def_class_reader method + # @api private + CLASSES_TO_INIT = %i[lcstr tool_entries two_level_hints_table].freeze + + # A list of fields that don't require arguments in the initializer + # Used to calculate MachOStructure#min_args + # @api private + NO_ARG_REQUIRED = %i[two_level_hints_table].freeze + end + + # map of field names to indices + @field_idxs = {} + + # array of fields sizes + @size_list = [] + + # array of field format codes + @fmt_list = [] + + # minimum number of required arguments + @min_args = 0 + + # @param args [Array[Value]] list of field parameters + def initialize(*args) + raise ArgumentError, "Invalid number of arguments" if args.size < self.class.min_args + + @values = args + end + + # @return [Hash] a hash representation of this {MachOStructure}. + def to_h + { + "structure" => { + "format" => self.class.format, + "bytesize" => self.class.bytesize, + }, + } + end + + class << self + attr_reader :min_args + + # @param endianness [Symbol] either `:big` or `:little` + # @param bin [String] the string to be unpacked into the new structure + # @return [MachO::MachOStructure] the resulting structure + # @api private + def new_from_bin(endianness, bin) + format = Utils.specialize_format(self.format, endianness) + + new(*bin.unpack(format)) + end + + def format + @format ||= @fmt_list.join + end + + def bytesize + @bytesize ||= @size_list.sum + end + + private + + # @param subclass [Class] subclass type + # @api private + def inherited(subclass) # rubocop:disable Lint/MissingSuper + # Clone all class instance variables + field_idxs = @field_idxs.dup + size_list = @size_list.dup + fmt_list = @fmt_list.dup + min_args = @min_args.dup + + # Add those values to the inheriting class + subclass.class_eval do + @field_idxs = field_idxs + @size_list = size_list + @fmt_list = fmt_list + @min_args = min_args + end + end + + # @param name [Symbol] name of internal field + # @param type [Symbol] type of field in terms of binary size + # @param options [Hash] set of additonal options + # Expected options + # :size [Integer] size in bytes + # :mask [Integer] bitmask + # :unpack [String] string format + # :default [Value] default value + # :to_s [Boolean] flag for generating #to_s + # :endian [Symbol] optionally specify :big or :little endian + # :padding [Symbol] optionally specify :null padding + # @api private + def field(name, type, **options) + raise ArgumentError, "Invalid field type #{type}" unless Fields::FORMAT_CODE.key?(type) + + # Get field idx for size_list and fmt_list + idx = if @field_idxs.key?(name) + @field_idxs[name] + else + @min_args += 1 unless options.key?(:default) || Fields::NO_ARG_REQUIRED.include?(type) + @field_idxs[name] = @field_idxs.size + @size_list << nil + @fmt_list << nil + @field_idxs.size - 1 + end + + # Update string type if padding is specified + type = :null_padded_string if type == :string && options[:padding] == :null + + # Add to size_list and fmt_list + @size_list[idx] = Fields::BYTE_SIZE[type] || options[:size] + @fmt_list[idx] = if options[:endian] + Utils.specialize_format(Fields::FORMAT_CODE[type], options[:endian]) + else + Fields::FORMAT_CODE[type] + end + @fmt_list[idx] += options[:size].to_s if options.key?(:size) + + # Generate methods + if Fields::CLASSES_TO_INIT.include?(type) + def_class_reader(name, type, idx) + elsif options.key?(:mask) + def_mask_reader(name, idx, options[:mask]) + elsif options.key?(:unpack) + def_unpack_reader(name, idx, options[:unpack]) + elsif options.key?(:default) + def_default_reader(name, idx, options[:default]) + else + def_reader(name, idx) + end + + def_to_s(name) if options[:to_s] + end + + # + # Method Generators + # + + # Generates a reader method for classes that need to be initialized. + # These classes are defined in the Fields::CLASSES_TO_INIT array. + # @param name [Symbol] name of internal field + # @param type [Symbol] type of field in terms of binary size + # @param idx [Integer] the index of the field value in the @values array + # @api private + def def_class_reader(name, type, idx) + case type + when :lcstr + define_method(name) do + instance_variable_defined?("@#{name}") || + instance_variable_set("@#{name}", LoadCommands::LoadCommand::LCStr.new(self, @values[idx])) + + instance_variable_get("@#{name}") + end + when :two_level_hints_table + define_method(name) do + instance_variable_defined?("@#{name}") || + instance_variable_set("@#{name}", LoadCommands::TwolevelHintsCommand::TwolevelHintsTable.new(view, htoffset, nhints)) + + instance_variable_get("@#{name}") + end + when :tool_entries + define_method(name) do + instance_variable_defined?("@#{name}") || + instance_variable_set("@#{name}", LoadCommands::BuildVersionCommand::ToolEntries.new(view, @values[idx])) + + instance_variable_get("@#{name}") + end + end + end + + # Generates a reader method for fields that need to be bitmasked. + # @param name [Symbol] name of internal field + # @param idx [Integer] the index of the field value in the @values array + # @param mask [Integer] the bitmask + # @api private + def def_mask_reader(name, idx, mask) + define_method(name) do + instance_variable_defined?("@#{name}") || + instance_variable_set("@#{name}", @values[idx] & ~mask) + + instance_variable_get("@#{name}") + end + end + + # Generates a reader method for fields that need further unpacking. + # @param name [Symbol] name of internal field + # @param idx [Integer] the index of the field value in the @values array + # @param unpack [String] the format code used for futher binary unpacking + # @api private + def def_unpack_reader(name, idx, unpack) + define_method(name) do + instance_variable_defined?("@#{name}") || + instance_variable_set("@#{name}", @values[idx].unpack(unpack)) + + instance_variable_get("@#{name}") + end + end + + # Generates a reader method for fields that have default values. + # @param name [Symbol] name of internal field + # @param idx [Integer] the index of the field value in the @values array + # @param default [Value] the default value + # @api private + def def_default_reader(name, idx, default) + define_method(name) do + instance_variable_defined?("@#{name}") || + instance_variable_set("@#{name}", @values.size > idx ? @values[idx] : default) + + instance_variable_get("@#{name}") + end + end + + # Generates an attr_reader like method for a field. + # @param name [Symbol] name of internal field + # @param idx [Integer] the index of the field value in the @values array + # @api private + def def_reader(name, idx) + define_method(name) do + @values[idx] + end + end + + # Generates the to_s method based on the named field. + # @param name [Symbol] name of the field + # @api private + def def_to_s(name) + define_method(:to_s) do + send(name).to_s + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/tools.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/tools.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/tools.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/tools.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/utils.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/utils.rb similarity index 100% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/utils.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/utils.rb diff --git a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/view.rb b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/view.rb similarity index 67% rename from Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/view.rb rename to Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/view.rb index ad68ee30ed611..3b1c36d9544d2 100644 --- a/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib/macho/view.rb +++ b/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-4.0.0/lib/macho/view.rb @@ -3,6 +3,9 @@ module MachO # A representation of some unspecified Mach-O data. class MachOView + # @return [MachOFile] that this view belongs to + attr_reader :macho_file + # @return [String] the raw Mach-O data attr_reader :raw_data @@ -13,10 +16,12 @@ class MachOView attr_reader :offset # Creates a new MachOView. + # @param macho_file [MachOFile] the file this view slice is from # @param raw_data [String] the raw Mach-O data # @param endianness [Symbol] the endianness of the data # @param offset [Integer] the offset of the relevant data - def initialize(raw_data, endianness, offset) + def initialize(macho_file, raw_data, endianness, offset) + @macho_file = macho_file @raw_data = raw_data @endianness = endianness @offset = offset @@ -29,5 +34,9 @@ def to_h "offset" => offset, } end + + def inspect + "#<#{self.class}:0x#{(object_id << 1).to_s(16)} @endianness=#{@endianness.inspect}, @offset=#{@offset.inspect}, length=#{@raw_data.length}>" + end end end From 08152647e4d30c3bb9b4780f87f1fc061e1b66e9 Mon Sep 17 00:00:00 2001 From: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> Date: Tue, 25 Jul 2023 18:30:55 +0000 Subject: [PATCH 3/3] Update RBI files for ruby-macho. Autogenerated by the [vendor-gems](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/vendor-gems.yml) workflow. --- ...y-macho@3.0.0.rbi => ruby-macho@4.0.0.rbi} | 260 +++++------------- .../sorbet/rbi/hidden-definitions/hidden.rbi | 5 + 2 files changed, 71 insertions(+), 194 deletions(-) rename Library/Homebrew/sorbet/rbi/gems/{ruby-macho@3.0.0.rbi => ruby-macho@4.0.0.rbi} (71%) diff --git a/Library/Homebrew/sorbet/rbi/gems/ruby-macho@3.0.0.rbi b/Library/Homebrew/sorbet/rbi/gems/ruby-macho@4.0.0.rbi similarity index 71% rename from Library/Homebrew/sorbet/rbi/gems/ruby-macho@3.0.0.rbi rename to Library/Homebrew/sorbet/rbi/gems/ruby-macho@4.0.0.rbi index d271ed05e1f0a..6fac85083c08a 100644 --- a/Library/Homebrew/sorbet/rbi/gems/ruby-macho@3.0.0.rbi +++ b/Library/Homebrew/sorbet/rbi/gems/ruby-macho@4.0.0.rbi @@ -19,6 +19,10 @@ class MachO::CPUTypeError < ::MachO::MachOError def initialize(cputype); end end +class MachO::CPUTypeMismatchError < ::MachO::NotAMachOError + def initialize(fat_cputype, fat_cpusubtype, macho_cputype, macho_cpusubtype); end +end + class MachO::CodeSigningError < ::MachO::MachOError; end class MachO::CompressedMachOError < ::MachO::MachOError; end class MachO::DecompressionError < ::MachO::MachOError; end @@ -181,8 +185,6 @@ MachO::Headers::FAT_MAGIC = T.let(T.unsafe(nil), Integer) MachO::Headers::FAT_MAGIC_64 = T.let(T.unsafe(nil), Integer) class MachO::Headers::FatArch < ::MachO::MachOStructure - def initialize(cputype, cpusubtype, offset, size, align); end - def align; end def cpusubtype; end def cputype; end @@ -193,29 +195,20 @@ class MachO::Headers::FatArch < ::MachO::MachOStructure end class MachO::Headers::FatArch64 < ::MachO::Headers::FatArch - def initialize(cputype, cpusubtype, offset, size, align, reserved = T.unsafe(nil)); end - + def offset; end def reserved; end def serialize; end + def size; end def to_h; end end -MachO::Headers::FatArch64::FORMAT = T.let(T.unsafe(nil), String) -MachO::Headers::FatArch64::SIZEOF = T.let(T.unsafe(nil), Integer) -MachO::Headers::FatArch::FORMAT = T.let(T.unsafe(nil), String) -MachO::Headers::FatArch::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::Headers::FatHeader < ::MachO::MachOStructure - def initialize(magic, nfat_arch); end - def magic; end def nfat_arch; end def serialize; end def to_h; end end -MachO::Headers::FatHeader::FORMAT = T.let(T.unsafe(nil), String) -MachO::Headers::FatHeader::SIZEOF = T.let(T.unsafe(nil), Integer) MachO::Headers::MH_BUNDLE = T.let(T.unsafe(nil), Integer) MachO::Headers::MH_CIGAM = T.let(T.unsafe(nil), Integer) MachO::Headers::MH_CIGAM_64 = T.let(T.unsafe(nil), Integer) @@ -237,8 +230,6 @@ MachO::Headers::MH_OBJECT = T.let(T.unsafe(nil), Integer) MachO::Headers::MH_PRELOAD = T.let(T.unsafe(nil), Integer) class MachO::Headers::MachHeader < ::MachO::MachOStructure - def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags); end - def alignment; end def bundle?; end def core?; end @@ -265,20 +256,11 @@ class MachO::Headers::MachHeader < ::MachO::MachOStructure end class MachO::Headers::MachHeader64 < ::MachO::Headers::MachHeader - def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags, reserved); end - def reserved; end def to_h; end end -MachO::Headers::MachHeader64::FORMAT = T.let(T.unsafe(nil), String) -MachO::Headers::MachHeader64::SIZEOF = T.let(T.unsafe(nil), Integer) -MachO::Headers::MachHeader::FORMAT = T.let(T.unsafe(nil), String) -MachO::Headers::MachHeader::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::Headers::PrelinkedKernelHeader < ::MachO::MachOStructure - def initialize(signature, compress_type, adler32, uncompressed_size, compressed_size, prelink_version, reserved, platform_name, root_path); end - def adler32; end def compress_type; end def compressed_size; end @@ -294,9 +276,6 @@ class MachO::Headers::PrelinkedKernelHeader < ::MachO::MachOStructure def uncompressed_size; end end -MachO::Headers::PrelinkedKernelHeader::FORMAT = T.let(T.unsafe(nil), String) -MachO::Headers::PrelinkedKernelHeader::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::JavaClassFileError < ::MachO::NotAMachOError def initialize; end end @@ -324,8 +303,6 @@ end module MachO::LoadCommands; end class MachO::LoadCommands::BuildVersionCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, platform, minos, sdk, ntools); end - def minos; end def minos_string; end def platform; end @@ -335,9 +312,6 @@ class MachO::LoadCommands::BuildVersionCommand < ::MachO::LoadCommands::LoadComm def tool_entries; end end -MachO::LoadCommands::BuildVersionCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::BuildVersionCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::BuildVersionCommand::ToolEntries def initialize(view, ntools); end @@ -356,8 +330,6 @@ MachO::LoadCommands::CREATABLE_LOAD_COMMANDS = T.let(T.unsafe(nil), Array) MachO::LoadCommands::DYLIB_LOAD_COMMANDS = T.let(T.unsafe(nil), Array) class MachO::LoadCommands::DyldInfoCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, rebase_off, rebase_size, bind_off, bind_size, weak_bind_off, weak_bind_size, lazy_bind_off, lazy_bind_size, export_off, export_size); end - def bind_off; end def bind_size; end def export_off; end @@ -371,37 +343,24 @@ class MachO::LoadCommands::DyldInfoCommand < ::MachO::LoadCommands::LoadCommand def weak_bind_size; end end -MachO::LoadCommands::DyldInfoCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::DyldInfoCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::DylibCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, name, timestamp, current_version, compatibility_version); end - def compatibility_version; end def current_version; end def name; end def serialize(context); end def timestamp; end def to_h; end + def to_s; end end -MachO::LoadCommands::DylibCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::DylibCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::DylinkerCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, name); end - def name; end def serialize(context); end def to_h; end + def to_s; end end -MachO::LoadCommands::DylinkerCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::DylinkerCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::DysymtabCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, ilocalsym, nlocalsym, iextdefsym, nextdefsym, iundefsym, nundefsym, tocoff, ntoc, modtaboff, nmodtab, extrefsymoff, nextrefsyms, indirectsymoff, nindirectsyms, extreloff, nextrel, locreloff, nlocrel); end - def extrefsymoff; end def extreloff; end def iextdefsym; end @@ -423,12 +382,7 @@ class MachO::LoadCommands::DysymtabCommand < ::MachO::LoadCommands::LoadCommand def tocoff; end end -MachO::LoadCommands::DysymtabCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::DysymtabCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::EncryptionInfoCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, cryptoff, cryptsize, cryptid); end - def cryptid; end def cryptoff; end def cryptsize; end @@ -436,95 +390,59 @@ class MachO::LoadCommands::EncryptionInfoCommand < ::MachO::LoadCommands::LoadCo end class MachO::LoadCommands::EncryptionInfoCommand64 < ::MachO::LoadCommands::EncryptionInfoCommand - def initialize(view, cmd, cmdsize, cryptoff, cryptsize, cryptid, pad); end - def pad; end def to_h; end end -MachO::LoadCommands::EncryptionInfoCommand64::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::EncryptionInfoCommand64::SIZEOF = T.let(T.unsafe(nil), Integer) -MachO::LoadCommands::EncryptionInfoCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::EncryptionInfoCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::EntryPointCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, entryoff, stacksize); end - def entryoff; end def stacksize; end def to_h; end end -MachO::LoadCommands::EntryPointCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::EntryPointCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::FilesetEntryCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, vmaddr, fileoff, entry_id, reserved); end - def entry_id; end def fileoff; end def reserved; end + def segment; end def to_h; end + def to_s; end def vmaddr; end end -MachO::LoadCommands::FilesetEntryCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::FilesetEntryCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::FvmfileCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, name, header_addr); end - def header_addr; end def name; end def to_h; end + def to_s; end end -MachO::LoadCommands::FvmfileCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::FvmfileCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::FvmlibCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, name, minor_version, header_addr); end - def header_addr; end def minor_version; end def name; end def to_h; end + def to_s; end end -MachO::LoadCommands::FvmlibCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::FvmlibCommand::SIZEOF = T.let(T.unsafe(nil), Integer) class MachO::LoadCommands::IdentCommand < ::MachO::LoadCommands::LoadCommand; end -MachO::LoadCommands::IdentCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::IdentCommand::SIZEOF = T.let(T.unsafe(nil), Integer) MachO::LoadCommands::LC_REQ_DYLD = T.let(T.unsafe(nil), Integer) MachO::LoadCommands::LC_STRUCTURES = T.let(T.unsafe(nil), Hash) MachO::LoadCommands::LOAD_COMMANDS = T.let(T.unsafe(nil), Hash) MachO::LoadCommands::LOAD_COMMAND_CONSTANTS = T.let(T.unsafe(nil), Hash) class MachO::LoadCommands::LinkeditDataCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, dataoff, datasize); end - def dataoff; end def datasize; end def to_h; end end -MachO::LoadCommands::LinkeditDataCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::LinkeditDataCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::LinkerOptionCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, count); end - def count; end def to_h; end end -MachO::LoadCommands::LinkerOptionCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::LinkerOptionCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::LoadCommand < ::MachO::MachOStructure - def initialize(view, cmd, cmdsize); end - def cmd; end def cmdsize; end def offset; end @@ -542,8 +460,6 @@ class MachO::LoadCommands::LoadCommand < ::MachO::MachOStructure end end -MachO::LoadCommands::LoadCommand::FORMAT = T.let(T.unsafe(nil), String) - class MachO::LoadCommands::LoadCommand::LCStr def initialize(lc, lc_str); end @@ -552,8 +468,6 @@ class MachO::LoadCommands::LoadCommand::LCStr def to_s; end end -MachO::LoadCommands::LoadCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::LoadCommand::SerializationContext def initialize(endianness, alignment); end @@ -566,42 +480,27 @@ class MachO::LoadCommands::LoadCommand::SerializationContext end class MachO::LoadCommands::NoteCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, data_owner, offset, size); end - def data_owner; end def offset; end def size; end def to_h; end + def to_s; end end -MachO::LoadCommands::NoteCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::NoteCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::PrebindCksumCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, cksum); end - def cksum; end def to_h; end end -MachO::LoadCommands::PrebindCksumCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::PrebindCksumCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::PreboundDylibCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, name, nmodules, linked_modules); end - def linked_modules; end def name; end def nmodules; end def to_h; end + def to_s; end end -MachO::LoadCommands::PreboundDylibCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::PreboundDylibCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::RoutinesCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, init_address, init_module, reserved1, reserved2, reserved3, reserved4, reserved5, reserved6); end - def init_address; end def init_module; end def reserved1; end @@ -613,28 +512,28 @@ class MachO::LoadCommands::RoutinesCommand < ::MachO::LoadCommands::LoadCommand def to_h; end end -class MachO::LoadCommands::RoutinesCommand64 < ::MachO::LoadCommands::RoutinesCommand; end -MachO::LoadCommands::RoutinesCommand64::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::RoutinesCommand64::SIZEOF = T.let(T.unsafe(nil), Integer) -MachO::LoadCommands::RoutinesCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::RoutinesCommand::SIZEOF = T.let(T.unsafe(nil), Integer) +class MachO::LoadCommands::RoutinesCommand64 < ::MachO::LoadCommands::RoutinesCommand + def init_address; end + def init_module; end + def reserved1; end + def reserved2; end + def reserved3; end + def reserved4; end + def reserved5; end + def reserved6; end +end class MachO::LoadCommands::RpathCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, path); end - def path; end def serialize(context); end def to_h; end + def to_s; end end -MachO::LoadCommands::RpathCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::RpathCommand::SIZEOF = T.let(T.unsafe(nil), Integer) MachO::LoadCommands::SEGMENT_FLAGS = T.let(T.unsafe(nil), Hash) MachO::LoadCommands::SEGMENT_NAMES = T.let(T.unsafe(nil), Hash) class MachO::LoadCommands::SegmentCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, segname, vmaddr, vmsize, fileoff, filesize, maxprot, initprot, nsects, flags); end - def fileoff; end def filesize; end def flag?(flag); end @@ -646,81 +545,55 @@ class MachO::LoadCommands::SegmentCommand < ::MachO::LoadCommands::LoadCommand def sections; end def segname; end def to_h; end + def to_s; end def vmaddr; end def vmsize; end end -class MachO::LoadCommands::SegmentCommand64 < ::MachO::LoadCommands::SegmentCommand; end -MachO::LoadCommands::SegmentCommand64::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SegmentCommand64::SIZEOF = T.let(T.unsafe(nil), Integer) -MachO::LoadCommands::SegmentCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SegmentCommand::SIZEOF = T.let(T.unsafe(nil), Integer) +class MachO::LoadCommands::SegmentCommand64 < ::MachO::LoadCommands::SegmentCommand + def fileoff; end + def filesize; end + def vmaddr; end + def vmsize; end +end class MachO::LoadCommands::SourceVersionCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, version); end - def to_h; end def version; end def version_string; end end -MachO::LoadCommands::SourceVersionCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SourceVersionCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::SubClientCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, sub_client); end - def sub_client; end def to_h; end + def to_s; end end -MachO::LoadCommands::SubClientCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SubClientCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::SubFrameworkCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, umbrella); end - def to_h; end + def to_s; end def umbrella; end end -MachO::LoadCommands::SubFrameworkCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SubFrameworkCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::SubLibraryCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, sub_library); end - def sub_library; end def to_h; end + def to_s; end end -MachO::LoadCommands::SubLibraryCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SubLibraryCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::SubUmbrellaCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, sub_umbrella); end - def sub_umbrella; end def to_h; end + def to_s; end end -MachO::LoadCommands::SubUmbrellaCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SubUmbrellaCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::SymsegCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, offset, size); end - def offset; end def size; end def to_h; end end -MachO::LoadCommands::SymsegCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SymsegCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::SymtabCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, symoff, nsyms, stroff, strsize); end - def nsyms; end def stroff; end def strsize; end @@ -728,24 +601,15 @@ class MachO::LoadCommands::SymtabCommand < ::MachO::LoadCommands::LoadCommand def to_h; end end -MachO::LoadCommands::SymtabCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::SymtabCommand::SIZEOF = T.let(T.unsafe(nil), Integer) class MachO::LoadCommands::ThreadCommand < ::MachO::LoadCommands::LoadCommand; end -MachO::LoadCommands::ThreadCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::ThreadCommand::SIZEOF = T.let(T.unsafe(nil), Integer) class MachO::LoadCommands::TwolevelHintsCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, htoffset, nhints); end - def htoffset; end def nhints; end def table; end def to_h; end end -MachO::LoadCommands::TwolevelHintsCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::TwolevelHintsCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::TwolevelHintsCommand::TwolevelHintsTable def initialize(view, htoffset, nhints); end @@ -761,19 +625,13 @@ class MachO::LoadCommands::TwolevelHintsCommand::TwolevelHintsTable::TwolevelHin end class MachO::LoadCommands::UUIDCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, uuid); end - def to_h; end + def to_s; end def uuid; end def uuid_string; end end -MachO::LoadCommands::UUIDCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::UUIDCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::LoadCommands::VersionMinCommand < ::MachO::LoadCommands::LoadCommand - def initialize(view, cmd, cmdsize, version, sdk); end - def sdk; end def sdk_string; end def to_h; end @@ -781,9 +639,6 @@ class MachO::LoadCommands::VersionMinCommand < ::MachO::LoadCommands::LoadComman def version_string; end end -MachO::LoadCommands::VersionMinCommand::FORMAT = T.let(T.unsafe(nil), String) -MachO::LoadCommands::VersionMinCommand::SIZEOF = T.let(T.unsafe(nil), Integer) - class MachO::MachOBinaryError < ::MachO::MachOError def initialize; end end @@ -868,21 +723,41 @@ class MachO::MachOFile end class MachO::MachOStructure + def initialize(*args); end + def to_h; end class << self def bytesize; end + def format; end + def min_args; end def new_from_bin(endianness, bin); end + + private + + def def_class_reader(name, type, idx); end + def def_default_reader(name, idx, default); end + def def_mask_reader(name, idx, mask); end + def def_reader(name, idx); end + def def_to_s(name); end + def def_unpack_reader(name, idx, unpack); end + def field(name, type, **options); end + def inherited(subclass); end end end -MachO::MachOStructure::FORMAT = T.let(T.unsafe(nil), String) -MachO::MachOStructure::SIZEOF = T.let(T.unsafe(nil), Integer) +module MachO::MachOStructure::Fields; end +MachO::MachOStructure::Fields::BYTE_SIZE = T.let(T.unsafe(nil), Hash) +MachO::MachOStructure::Fields::CLASSES_TO_INIT = T.let(T.unsafe(nil), Array) +MachO::MachOStructure::Fields::FORMAT_CODE = T.let(T.unsafe(nil), Hash) +MachO::MachOStructure::Fields::NO_ARG_REQUIRED = T.let(T.unsafe(nil), Array) class MachO::MachOView - def initialize(raw_data, endianness, offset); end + def initialize(macho_file, raw_data, endianness, offset); end def endianness; end + def inspect; end + def macho_file; end def offset; end def raw_data; end def to_h; end @@ -925,8 +800,6 @@ MachO::Sections::SECTION_TYPES = T.let(T.unsafe(nil), Hash) MachO::Sections::SECTION_TYPE_MASK = T.let(T.unsafe(nil), Integer) class MachO::Sections::Section < ::MachO::MachOStructure - def initialize(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2); end - def addr; end def align; end def attribute?(attr_sym); end @@ -950,17 +823,12 @@ class MachO::Sections::Section < ::MachO::MachOStructure end class MachO::Sections::Section64 < ::MachO::Sections::Section - def initialize(sectname, segname, addr, size, offset, align, reloff, nreloc, flags, reserved1, reserved2, reserved3); end - + def addr; end def reserved3; end + def size; end def to_h; end end -MachO::Sections::Section64::FORMAT = T.let(T.unsafe(nil), String) -MachO::Sections::Section64::SIZEOF = T.let(T.unsafe(nil), Integer) -MachO::Sections::Section::FORMAT = T.let(T.unsafe(nil), String) -MachO::Sections::Section::SIZEOF = T.let(T.unsafe(nil), Integer) - module MachO::Tools class << self def add_rpath(filename, new_path, options = T.unsafe(nil)); end @@ -1001,3 +869,7 @@ module MachO::Utils end MachO::VERSION = T.let(T.unsafe(nil), String) + +class MachO::ZeroArchitectureError < ::MachO::NotAMachOError + def initialize; end +end diff --git a/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi b/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi index 9c4ea19d6f247..6002464cd0785 100644 --- a/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi +++ b/Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi @@ -4319,6 +4319,11 @@ module Homebrew::API extend ::T::Private::Methods::SingletonMethodHooks end +class Homebrew::BumpVersionParser + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + class Homebrew::BundleVersion extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks