Module: MachO
- Defined in:
- lib/macho.rb,
lib/macho/view.rb,
lib/macho/tools.rb,
lib/macho/utils.rb,
lib/macho/headers.rb,
lib/macho/fat_file.rb,
lib/macho/sections.rb,
lib/macho/structure.rb,
lib/macho/exceptions.rb,
lib/macho/macho_file.rb,
lib/macho/load_commands.rb
Overview
The primary namespace for ruby-macho.
Defined Under Namespace
Modules: Headers, LoadCommands, Sections, Tools, Utils Classes: CPUSubtypeError, CPUTypeError, CPUTypeMismatchError, CodeSigningError, CompressedMachOError, DecompressionError, DylibIdMissingError, DylibUnknownError, FatArchOffsetOverflowError, FatBinaryError, FatFile, FiletypeError, HeaderPadError, JavaClassFileError, LCStrMalformedError, LoadCommandCreationArityError, LoadCommandError, LoadCommandNotCreatableError, LoadCommandNotSerializableError, MachOBinaryError, MachOError, MachOFile, MachOStructure, MachOView, MagicError, ModificationError, NotAMachOError, OffsetInsertionError, RecoverableModificationError, RpathExistsError, RpathUnknownError, TruncatedFileError, UnimplementedError, ZeroArchitectureError
Constant Summary collapse
- VERSION =
release version
"4.1.0"
Class Method Summary collapse
-
.codesign!(filename) ⇒ void
Signs the dylib using an ad-hoc identity.
-
.open(filename) ⇒ MachOFile, FatFile
Opens the given filename as a MachOFile or FatFile, depending on its magic.
Class Method Details
.codesign!(filename) ⇒ void
This method returns an undefined value.
Signs the dylib using an ad-hoc identity. Necessary after making any changes to a dylib, since otherwise changing a signed file invalidates its signature.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/macho.rb', line 51 def self.codesign!(filename) raise ArgumentError, "codesign binary is not available on Linux" if RUBY_PLATFORM !~ /darwin/ raise ArgumentError, "#{filename}: no such file" unless File.file?(filename) _, _, status = Open3.capture3("codesign", "--sign", "-", "--force", "--preserve-metadata=entitlements,requirements,flags,runtime", filename) raise CodeSigningError, "#{filename}: signing failed!" unless status.success? end |
.open(filename) ⇒ MachOFile, FatFile
Opens the given filename as a MachOFile or FatFile, depending on its magic.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/macho.rb', line 28 def self.open(filename) raise ArgumentError, "#{filename}: no such file" unless File.file?(filename) raise TruncatedFileError unless File.stat(filename).size >= 4 magic = File.open(filename, "rb") { |f| f.read(4) }.unpack1("N") if Utils.fat_magic?(magic) file = FatFile.new(filename) elsif Utils.magic?(magic) file = MachOFile.new(filename) else raise MagicError, magic end file end |