Module: MachO::Tools

Defined in:
lib/macho/tools.rb

Overview

A collection of convenient methods for common operations on Mach-O and Fat binaries.

Class Method Summary collapse

Class Method Details

.add_rpath(filename, new_path) ⇒ void

TODO:

unstub

This method returns an undefined value.

Add a runtime path to a Mach-O or Fat binary, overwriting the source file.

Parameters:

  • filename (String)

    the Mach-O or Fat binary being modified

  • new_path (String)

    the new runtime path



59
60
61
# File 'lib/macho/tools.rb', line 59

def self.add_rpath(filename, new_path)
	raise "stub"
end

.change_dylib_id(filename, new_id) ⇒ void

TODO:

unstub for fat files

This method returns an undefined value.

Changes the dylib ID of a Mach-O or Fat binary, overwriting the source file.

Parameters:

  • filename (String)

    the Mach-O or Fat binary being modified

  • new_id (String)

    the new dylib ID for the binary



17
18
19
20
21
22
23
24
25
26
# File 'lib/macho/tools.rb', line 17

def self.change_dylib_id(filename, new_id)
	file = MachO.open(filename)

	if File.is_a? MachO::MachOFile
		file.dylib_id = new_id
		file.write!
	else
		raise MachOError.new("changing dylib ids for fat binaries is incomplete")
	end
end

.change_install_name(filename, old_name, new_name) ⇒ void

TODO:

unstub for fat files

This method returns an undefined value.

Changes a shared library install name in a Mach-O or Fat binary, overwriting the source file.

Parameters:

  • filename (String)

    the Mach-O or Fat binary being modified

  • old_name (String)

    the old shared library name

  • new_name (String)

    the new shared library name



34
35
36
37
38
39
40
41
42
# File 'lib/macho/tools.rb', line 34

def self.change_install_name(filename, old_name, new_name)
	file = MachO.open(filename)

	if File.is_a? MachO::MachOFile
		file.change_install_name(old_name, new_name)
	else
		raise MachOError.new("changing install names for fat binaries is incomplete")
	end
end

.change_rpath(filename, old_path, new_path) ⇒ void

TODO:

unstub

This method returns an undefined value.

Changes a runtime path in a Mach-O or Fat binary, overwriting the source file.

Parameters:

  • filename (String)

    the Mach-O or Fat binary being modified

  • old_path (String)

    the old runtime path

  • new_path (String)

    the new runtime path



50
51
52
# File 'lib/macho/tools.rb', line 50

def self.change_rpath(filename, old_path, new_path)
	raise "stub"
end

.delete_rpath(filename, old_path) ⇒ void

TODO:

unstub

This method returns an undefined value.

Delete a runtime path from a Mach-O or Fat binary, overwriting the source file.

Parameters:

  • filename (String)

    the Mach-O or Fat binary being modified

  • old_path (String)

    the old runtime path



68
69
70
# File 'lib/macho/tools.rb', line 68

def self.delete_rpath(filename, old_path)
	raise "stub"
end

.dylibs(filename) ⇒ Array<String>

Returns an array of all dylibs linked to the binary.

Parameters:

  • filename (String)

    the Mach-O or Fat binary being read

Returns:

  • (Array<String>)

    an array of all dylibs linked to the binary



6
7
8
9
10
# File 'lib/macho/tools.rb', line 6

def self.dylibs(filename)
	file = MachO.open(filename)

	file.linked_dylibs
end