ruby-macho 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/macho.rb +1 -1
- data/lib/macho/fat_file.rb +13 -13
- data/lib/macho/load_commands.rb +12 -2
- data/lib/macho/macho_file.rb +20 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f149c2c7085b336a2447513e28f10d59afc88062
|
4
|
+
data.tar.gz: 1f938c11b54535cc8b92a625235bff9a34572ceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09cd628c568572c632897f1799e784a2668b41ef1c476a84db7c8a438b96832cd54f85050fd4aef593def43b82c90af4cdacdf5a607eb56b4c607390ffdcaddf
|
7
|
+
data.tar.gz: f58bc28a331f6d9ec3d7c98e98d3d1d630788a31ec0fa7d82eef0bc43d254126726f8198581eb11c14f626078c92475fcf6de4742f5170008aa0553db9ffffc6
|
data/lib/macho.rb
CHANGED
data/lib/macho/fat_file.rb
CHANGED
@@ -32,60 +32,62 @@ module MachO
|
|
32
32
|
@raw_data
|
33
33
|
end
|
34
34
|
|
35
|
-
# @return [Boolean] true if the
|
35
|
+
# @return [Boolean] true if the file is of type `MH_OBJECT`, false otherwise
|
36
36
|
def object?
|
37
37
|
machos.first.object?
|
38
38
|
end
|
39
39
|
|
40
|
-
# @return [Boolean] true if the
|
40
|
+
# @return [Boolean] true if the file is of type `MH_EXECUTE`, false otherwise
|
41
41
|
def executable?
|
42
42
|
machos.first.executable?
|
43
43
|
end
|
44
44
|
|
45
|
-
# @return [Boolean] true if the
|
45
|
+
# @return [Boolean] true if the file is of type `MH_FVMLIB`, false otherwise
|
46
46
|
def fvmlib?
|
47
47
|
machos.first.fvmlib?
|
48
48
|
end
|
49
49
|
|
50
|
-
# @return [Boolean] true if the
|
50
|
+
# @return [Boolean] true if the file is of type `MH_CORE`, false otherwise
|
51
51
|
def core?
|
52
52
|
machos.first.core?
|
53
53
|
end
|
54
54
|
|
55
|
-
# @return [Boolean] true if the
|
55
|
+
# @return [Boolean] true if the file is of type `MH_PRELOAD`, false otherwise
|
56
56
|
def preload?
|
57
57
|
machos.first.preload?
|
58
58
|
end
|
59
59
|
|
60
|
-
# @return [Boolean] true if the
|
60
|
+
# @return [Boolean] true if the file is of type `MH_DYLIB`, false otherwise
|
61
61
|
def dylib?
|
62
62
|
machos.first.dylib?
|
63
63
|
end
|
64
64
|
|
65
|
-
# @return [Boolean] true if the
|
65
|
+
# @return [Boolean] true if the file is of type `MH_DYLINKER`, false otherwise
|
66
66
|
def dylinker?
|
67
67
|
machos.first.dylinker?
|
68
68
|
end
|
69
69
|
|
70
|
-
# @return [Boolean] true if the
|
70
|
+
# @return [Boolean] true if the file is of type `MH_BUNDLE`, false otherwise
|
71
71
|
def bundle?
|
72
72
|
machos.first.bundle?
|
73
73
|
end
|
74
74
|
|
75
|
-
# @return [Boolean] true if the
|
75
|
+
# @return [Boolean] true if the file is of type `MH_DSYM`, false otherwise
|
76
76
|
def dsym?
|
77
77
|
machos.first.dsym?
|
78
78
|
end
|
79
79
|
|
80
|
-
# @return [Boolean] true if the
|
80
|
+
# @return [Boolean] true if the file is of type `MH_KEXT_BUNDLE`, false otherwise
|
81
81
|
def kext?
|
82
82
|
machos.first.kext?
|
83
83
|
end
|
84
84
|
|
85
|
+
# @return [Fixnum] the file's magic number
|
85
86
|
def magic
|
86
87
|
header.magic
|
87
88
|
end
|
88
89
|
|
90
|
+
# @return [String] a string representation of the file's magic number
|
89
91
|
def magic_string
|
90
92
|
MH_MAGICS[magic]
|
91
93
|
end
|
@@ -129,10 +131,8 @@ module MachO
|
|
129
131
|
# All shared libraries linked to the file's Mach-Os.
|
130
132
|
# @return [Array<String>] an array of all shared libraries
|
131
133
|
def linked_dylibs
|
132
|
-
dylibs = machos.map(&:linked_dylibs).flatten
|
133
|
-
|
134
134
|
# can machos inside fat binaries have different dylibs?
|
135
|
-
|
135
|
+
machos.flat_map(&:linked_dylibs).uniq
|
136
136
|
end
|
137
137
|
|
138
138
|
# Changes all dependent shared library install names from `old_name` to `new_name`.
|
data/lib/macho/load_commands.rb
CHANGED
@@ -55,6 +55,16 @@ module MachO
|
|
55
55
|
0x2e => :LC_LINKER_OPTIMIZATION_HINT
|
56
56
|
}
|
57
57
|
|
58
|
+
# load commands responsible for loading dylibs
|
59
|
+
# @api private
|
60
|
+
DYLIB_LOAD_COMMANDS = [
|
61
|
+
:LC_LOAD_DYLIB,
|
62
|
+
:LC_LOAD_WEAK_DYLIB,
|
63
|
+
:LC_REEXPORT_DYLIB,
|
64
|
+
:LC_LAZY_LOAD_DYLIB,
|
65
|
+
:LC_LOAD_UPWARD_DYLIB,
|
66
|
+
].freeze
|
67
|
+
|
58
68
|
# association of load command symbols to string representations of classes
|
59
69
|
# @api private
|
60
70
|
LC_STRUCTURES = {
|
@@ -89,11 +99,11 @@ module MachO
|
|
89
99
|
:LC_CODE_SIGNATURE => "LinkeditDataCommand",
|
90
100
|
:LC_SEGMENT_SPLIT_INFO => "LinkeditDataCommand",
|
91
101
|
:LC_REEXPORT_DYLIB => "DylibCommand",
|
92
|
-
:LC_LAZY_LOAD_DYLIB => "
|
102
|
+
:LC_LAZY_LOAD_DYLIB => "DylibCommand",
|
93
103
|
:LC_ENCRYPTION_INFO => "EncryptionInfoCommand",
|
94
104
|
:LC_DYLD_INFO => "DyldInfoCommand",
|
95
105
|
:LC_DYLD_INFO_ONLY => "DyldInfoCommand",
|
96
|
-
:LC_LOAD_UPWARD_DYLIB => "
|
106
|
+
:LC_LOAD_UPWARD_DYLIB => "DylibCommand",
|
97
107
|
:LC_VERSION_MIN_MACOSX => "VersionMinCommand",
|
98
108
|
:LC_VERSION_MIN_IPHONEOS => "VersionMinCommand",
|
99
109
|
:LC_FUNCTION_STARTS => "LinkeditDataCommand",
|
data/lib/macho/macho_file.rb
CHANGED
@@ -58,62 +58,62 @@ module MachO
|
|
58
58
|
MachO.magic64?(header.magic)
|
59
59
|
end
|
60
60
|
|
61
|
-
# @return [Boolean] true if the
|
61
|
+
# @return [Boolean] true if the file is of type `MH_OBJECT`, false otherwise
|
62
62
|
def object?
|
63
63
|
header.filetype == MH_OBJECT
|
64
64
|
end
|
65
65
|
|
66
|
-
# @return [Boolean] true if the
|
66
|
+
# @return [Boolean] true if the file is of type `MH_EXECUTE`, false otherwise
|
67
67
|
def executable?
|
68
68
|
header.filetype == MH_EXECUTE
|
69
69
|
end
|
70
70
|
|
71
|
-
# @return [Boolean] true if the
|
71
|
+
# @return [Boolean] true if the file is of type `MH_FVMLIB`, false otherwise
|
72
72
|
def fvmlib?
|
73
73
|
header.filetype == MH_FVMLIB
|
74
74
|
end
|
75
75
|
|
76
|
-
# @return [Boolean] true if the
|
76
|
+
# @return [Boolean] true if the file is of type `MH_CORE`, false otherwise
|
77
77
|
def core?
|
78
78
|
header.filetype == MH_CORE
|
79
79
|
end
|
80
80
|
|
81
|
-
# @return [Boolean] true if the
|
81
|
+
# @return [Boolean] true if the file is of type `MH_PRELOAD`, false otherwise
|
82
82
|
def preload?
|
83
83
|
header.filetype == MH_PRELOAD
|
84
84
|
end
|
85
85
|
|
86
|
-
# @return [Boolean] true if the
|
86
|
+
# @return [Boolean] true if the file is of type `MH_DYLIB`, false otherwise
|
87
87
|
def dylib?
|
88
88
|
header.filetype == MH_DYLIB
|
89
89
|
end
|
90
90
|
|
91
|
-
# @return [Boolean] true if the
|
91
|
+
# @return [Boolean] true if the file is of type `MH_DYLINKER`, false otherwise
|
92
92
|
def dylinker?
|
93
93
|
header.filetype == MH_DYLINKER
|
94
94
|
end
|
95
95
|
|
96
|
-
# @return [Boolean] true if the
|
96
|
+
# @return [Boolean] true if the file is of type `MH_BUNDLE`, false otherwise
|
97
97
|
def bundle?
|
98
98
|
header.filetype == MH_BUNDLE
|
99
99
|
end
|
100
100
|
|
101
|
-
# @return [Boolean] true if the
|
101
|
+
# @return [Boolean] true if the file is of type `MH_DSYM`, false otherwise
|
102
102
|
def dsym?
|
103
103
|
header.filetype == MH_DSYM
|
104
104
|
end
|
105
105
|
|
106
|
-
# @return [Boolean] true if the
|
106
|
+
# @return [Boolean] true if the file is of type `MH_KEXT_BUNDLE`, false otherwise
|
107
107
|
def kext?
|
108
108
|
header.filetype == MH_KEXT_BUNDLE
|
109
109
|
end
|
110
110
|
|
111
|
-
# @return [Fixnum] the
|
111
|
+
# @return [Fixnum] the file's magic number
|
112
112
|
def magic
|
113
113
|
header.magic
|
114
114
|
end
|
115
115
|
|
116
|
-
# @return [String] a string representation of the
|
116
|
+
# @return [String] a string representation of the file's magic number
|
117
117
|
def magic_string
|
118
118
|
MH_MAGICS[magic]
|
119
119
|
end
|
@@ -160,6 +160,12 @@ module MachO
|
|
160
160
|
|
161
161
|
alias :[] :command
|
162
162
|
|
163
|
+
# All load commands responsible for loading dylibs.
|
164
|
+
# @return [Array<MachO::DylibCommand>] an array of DylibCommands
|
165
|
+
def dylib_load_commands
|
166
|
+
load_commands.select { |lc| DYLIB_LOAD_COMMANDS.include?(lc.type) }
|
167
|
+
end
|
168
|
+
|
163
169
|
# All segment load commands in the Mach-O.
|
164
170
|
# @return [Array<MachO::SegmentCommand>] if the Mach-O is 32-bit
|
165
171
|
# @return [Array<MachO::SegmentCommand64>] if the Mach-O is 64-bit
|
@@ -209,7 +215,7 @@ module MachO
|
|
209
215
|
# All shared libraries linked to the Mach-O.
|
210
216
|
# @return [Array<String>] an array of all shared libraries
|
211
217
|
def linked_dylibs
|
212
|
-
|
218
|
+
dylib_load_commands.map(&:name).map(&:to_s)
|
213
219
|
end
|
214
220
|
|
215
221
|
# Changes the shared library `old_name` to `new_name`
|
@@ -220,7 +226,7 @@ module MachO
|
|
220
226
|
# @return [void]
|
221
227
|
# @raise [MachO::DylibUnknownError] if no shared library has the old name
|
222
228
|
def change_install_name(old_name, new_name)
|
223
|
-
dylib_cmd =
|
229
|
+
dylib_cmd = dylib_load_commands.find { |d| d.name.to_s == old_name }
|
224
230
|
raise DylibUnknownError.new(old_name) if dylib_cmd.nil?
|
225
231
|
|
226
232
|
set_name_in_dylib(dylib_cmd, old_name, new_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-macho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for viewing and manipulating Mach-O files in Ruby.
|
14
14
|
email: william@tuffbizz.com
|