ruby-macho 0.0.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 +7 -0
- data/lib/cstruct.rb +346 -0
- data/lib/int_helpers.rb +17 -0
- data/lib/macho.rb +14 -0
- data/lib/macho/exceptions.rb +54 -0
- data/lib/macho/file.rb +351 -0
- data/lib/macho/headers.rb +122 -0
- data/lib/macho/load_commands.rb +588 -0
- data/lib/macho/sections.rb +114 -0
- data/lib/macho/structure.rb +15 -0
- data/lib/macho/utils.rb +28 -0
- data/lib/otool_helpers.rb +3 -0
- metadata +55 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
module MachO
|
2
|
+
# magic numbers used in Mach-O files
|
3
|
+
FAT_MAGIC = 0xcafebabe # big-endian fat magic
|
4
|
+
FAT_CIGAM = 0xbebafeca # little-endian fat magic
|
5
|
+
MH_MAGIC = 0xfeedface # 32-bit big-endian magic
|
6
|
+
MH_CIGAM = 0xcefaedfe # 32-bit little-endian magic
|
7
|
+
MH_MAGIC_64 = 0xfeedfacf # 64-bit big-endian magic
|
8
|
+
MH_CIGAM_64 = 0xcffaedfe # 64-bit little-endian magic
|
9
|
+
|
10
|
+
MH_MAGICS = {
|
11
|
+
FAT_MAGIC => "FAT_MAGIC",
|
12
|
+
FAT_CIGAM => "FAT_CIGAM",
|
13
|
+
MH_MAGIC => "MH_MAGIC",
|
14
|
+
MH_CIGAM => "MH_CIGAM",
|
15
|
+
MH_MAGIC_64 => "MH_MAGIC_64",
|
16
|
+
MH_CIGAM_64 => "MH_CIGAM_64"
|
17
|
+
}
|
18
|
+
|
19
|
+
# capability bits used in the definition of cputype
|
20
|
+
CPU_ARCH_MASK = 0xff000000
|
21
|
+
CPU_ARCH_ABI64 = 0x01000000
|
22
|
+
|
23
|
+
# (select) values for cputype in MachHeader/MachHeader64
|
24
|
+
CPU_TYPE_ANY = -1
|
25
|
+
CPU_TYPE_X86 = 0x07
|
26
|
+
CPU_TYPE_I386 = CPU_TYPE_X86
|
27
|
+
CPU_TYPE_X86_64 = (CPU_TYPE_X86 | CPU_ARCH_ABI64)
|
28
|
+
CPU_TYPE_POWERPC = 0x24
|
29
|
+
CPU_TYPE_POWERPC64 = (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
|
30
|
+
|
31
|
+
CPU_TYPES = {
|
32
|
+
CPU_TYPE_ANY => "CPU_TYPE_ANY",
|
33
|
+
CPU_TYPE_X86 => "CPU_TYPE_X86",
|
34
|
+
CPU_TYPE_I386 => "CPU_TYPE_I386",
|
35
|
+
CPU_TYPE_X86_64 => "CPU_TYPE_X86_64",
|
36
|
+
CPU_TYPE_POWERPC => "CPU_TYPE_POWERPC",
|
37
|
+
CPU_TYPE_POWERPC64 => "CPU_TYPE_POWERPC64"
|
38
|
+
}
|
39
|
+
|
40
|
+
# capability bits used in the definition of cpusubtype
|
41
|
+
# http://llvm.org/docs/doxygen/html/Support_2MachO_8h_source.html
|
42
|
+
CPU_SUBTYPE_MASK = 0xff000000
|
43
|
+
CPU_SUBTYPE_LIB64 = 0x80000000
|
44
|
+
|
45
|
+
# (select) cpusubtypes
|
46
|
+
CPU_SUBTYPE_X86_ALL = 3
|
47
|
+
CPU_SUBTYPE_X86_ARCH1 = 4
|
48
|
+
|
49
|
+
CPU_SUBTYPES = {
|
50
|
+
CPU_SUBTYPE_X86_ALL => "CPU_SUBTYPE_X86_ALL",
|
51
|
+
CPU_SUBTYPE_X86_ARCH1 => "CPU_SUBTYPE_X86_ARCH1"
|
52
|
+
}
|
53
|
+
|
54
|
+
# values for filetype in MachHeader/MachHeader64
|
55
|
+
MH_OBJECT = 0x1 # relocatable object file
|
56
|
+
MH_EXECUTE = 0x2 # demand paged executable file
|
57
|
+
MH_FVMLIB = 0x3 # fixed VM shared library file
|
58
|
+
MH_CORE = 0x4 # core file
|
59
|
+
MH_PRELOAD = 0x5 # preloaded executable file
|
60
|
+
MH_DYLIB = 0x6 # dynamically bound shared library
|
61
|
+
MH_DYLINKER = 0x7 # dynamic link editor
|
62
|
+
MH_BUNDLE = 0x8 # dynamically bound bundle file
|
63
|
+
MH_DYLIB_STUB = 0x9 # shared library stub for static linking only no,
|
64
|
+
# section contents
|
65
|
+
MH_DSYM = 0xa # companion file with only debug sections
|
66
|
+
MH_KEXT_BUNDLE = 0xb # x86_64 lexts
|
67
|
+
|
68
|
+
MH_FILETYPES = {
|
69
|
+
MH_OBJECT => "MH_OBJECT",
|
70
|
+
MH_EXECUTE => "MH_EXECUTE",
|
71
|
+
MH_FVMLIB => "MH_FVMLIB",
|
72
|
+
MH_CORE => "MH_CORE",
|
73
|
+
MH_PRELOAD => "MH_PRELOAD",
|
74
|
+
MH_DYLIB => "MH_DYLIB",
|
75
|
+
MH_DYLINKER => "MH_DYLINKER",
|
76
|
+
MH_BUNDLE => "MH_BUNDLE",
|
77
|
+
MH_DYLIB_STUB => "MH_DYLIB_STUB",
|
78
|
+
MH_DSYM => "MH_DSYM",
|
79
|
+
MH_KEXT_BUNDLE => "MH_KEXT_BUNDLE"
|
80
|
+
}
|
81
|
+
|
82
|
+
# TODO: declare values for flags in MachHeader/MachHeader64
|
83
|
+
|
84
|
+
# 'Fat' binaries envelop Mach-O binaries so include them for completeness,
|
85
|
+
# Fat binary header structure
|
86
|
+
class FatHeader < CStruct
|
87
|
+
uint32 :magic
|
88
|
+
uint32 :nfat_arch # number of FatArchs that follow
|
89
|
+
end
|
90
|
+
|
91
|
+
# Fat binary header architecture structure
|
92
|
+
class FatArch < CStruct
|
93
|
+
int32 :cputype
|
94
|
+
int32 :cpusubtype
|
95
|
+
uint32 :offset
|
96
|
+
uint32 :size
|
97
|
+
uint32 :align
|
98
|
+
end
|
99
|
+
|
100
|
+
# 32-bit Mach-O file header structure
|
101
|
+
class MachHeader < CStruct
|
102
|
+
uint32 :magic
|
103
|
+
int32 :cputype
|
104
|
+
int32 :cpusubtype
|
105
|
+
uint32 :filetype
|
106
|
+
uint32 :ncmds
|
107
|
+
uint32 :sizeofcmds
|
108
|
+
uint32 :flags
|
109
|
+
end
|
110
|
+
|
111
|
+
# 64-bit Mach-O file header structure
|
112
|
+
class MachHeader64 < CStruct
|
113
|
+
uint32 :magic
|
114
|
+
int32 :cputype
|
115
|
+
int32 :cpusubtype
|
116
|
+
uint32 :filetype
|
117
|
+
uint32 :ncmds
|
118
|
+
uint32 :sizeofcmds
|
119
|
+
uint32 :flags
|
120
|
+
uint32 :reserved
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,588 @@
|
|
1
|
+
module MachO
|
2
|
+
# load commands added after OS X 10.1 need to be bitwise ORed with
|
3
|
+
# LC_REQ_DYLD to be recognized by the dynamic linder (dyld)
|
4
|
+
LC_REQ_DYLD = 0x80000000
|
5
|
+
|
6
|
+
# values for cmd in LoadCommand
|
7
|
+
LC_SEGMENT = 0x1
|
8
|
+
LC_SYMTAB = 0x2
|
9
|
+
LC_SYMSEG = 0x3
|
10
|
+
LC_THREAD = 0x4
|
11
|
+
LC_UNIXTHREAD = 0x5
|
12
|
+
LC_LOADFVMLIB = 0x6
|
13
|
+
LC_IDFVMLIB = 0x7
|
14
|
+
LC_IDENT = 0x8
|
15
|
+
LC_FVMFILE = 0x9
|
16
|
+
LC_PREPAGE = 0xa
|
17
|
+
LC_DYSYMTAB = 0xb
|
18
|
+
LC_LOAD_DYLIB = 0xc
|
19
|
+
LC_ID_DYLIB = 0xd
|
20
|
+
LC_LOAD_DYLINKER = 0xe
|
21
|
+
LC_ID_DYLINKER = 0xf
|
22
|
+
LC_PREBOUND_DYLIB = 0x10
|
23
|
+
LC_ROUTINES = 0x11
|
24
|
+
LC_SUB_FRAMEWORK = 0x12
|
25
|
+
LC_SUB_UMBRELLA = 0x13
|
26
|
+
LC_SUB_CLIENT = 0x14
|
27
|
+
LC_SUB_LIBRARY = 0x15
|
28
|
+
LC_TWOLEVEL_HINTS = 0x16
|
29
|
+
LC_PREBIND_CKSUM = 0x17
|
30
|
+
LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD)
|
31
|
+
LC_SEGMENT_64 = 0x19
|
32
|
+
LC_ROUTINES_64 = 0x1a
|
33
|
+
LC_UUID = 0x1b
|
34
|
+
LC_RPATH = (0x1c | LC_REQ_DYLD)
|
35
|
+
LC_CODE_SIGNATURE = 0x1d
|
36
|
+
LC_SEGMENT_SPLIT_INFO = 0x1e
|
37
|
+
LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD)
|
38
|
+
LC_LAZY_LOAD_DYLIB = 0x20
|
39
|
+
LC_ENCRYPTION_INFO = 0x21
|
40
|
+
LC_DYLD_INFO = 0x22
|
41
|
+
LC_DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD)
|
42
|
+
LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD)
|
43
|
+
LC_VERSION_MIN_MACOSX = 0x24
|
44
|
+
LC_VERSION_MIN_IPHONEOS = 0x25
|
45
|
+
LC_FUNCTION_STARTS = 0x26
|
46
|
+
LC_DYLD_ENVIRONMENT = 0x27
|
47
|
+
LC_MAIN = (0x28 | LC_REQ_DYLD)
|
48
|
+
LC_DATA_IN_CODE = 0x29
|
49
|
+
LC_SOURCE_VERSION = 0x2a
|
50
|
+
LC_DYLIB_CODE_SIGN_DRS = 0x2b
|
51
|
+
LC_ENCRYPTION_INFO_64 = 0x2c
|
52
|
+
LC_LINKER_OPTION = 0x2d
|
53
|
+
LC_LINKER_OPTIMIZATION_HINT = 0x2e
|
54
|
+
|
55
|
+
LOAD_COMMANDS = {
|
56
|
+
LC_SEGMENT => "LC_SEGMENT",
|
57
|
+
LC_SYMTAB => "LC_SYMTAB",
|
58
|
+
LC_SYMSEG => "LC_SYMSEG",
|
59
|
+
LC_THREAD => "LC_THREAD",
|
60
|
+
LC_UNIXTHREAD => "LC_UNIXTHREAD",
|
61
|
+
LC_LOADFVMLIB => "LC_LOADFVMLIB",
|
62
|
+
LC_IDFVMLIB => "LC_IDFVMLIB",
|
63
|
+
LC_IDENT => "LC_IDENT",
|
64
|
+
LC_FVMFILE => "LC_FVMFILE",
|
65
|
+
LC_PREPAGE => "LC_PREPAGE",
|
66
|
+
LC_DYSYMTAB => "LC_DYSYMTAB",
|
67
|
+
LC_LOAD_DYLIB => "LC_LOAD_DYLIB",
|
68
|
+
LC_ID_DYLIB => "LC_ID_DYLIB",
|
69
|
+
LC_LOAD_DYLINKER => "LC_LOAD_DYLINKER",
|
70
|
+
LC_ID_DYLINKER => "LC_ID_DYLINKER",
|
71
|
+
LC_PREBOUND_DYLIB => "LC_PREBOUND_DYLIB",
|
72
|
+
LC_ROUTINES => "LC_ROUTINES",
|
73
|
+
LC_SUB_FRAMEWORK => "LC_SUB_FRAMEWORK",
|
74
|
+
LC_SUB_UMBRELLA => "LC_SUB_UMBRELLA",
|
75
|
+
LC_SUB_CLIENT => "LC_SUB_CLIENT",
|
76
|
+
LC_SUB_LIBRARY => "LC_SUB_LIBRARY",
|
77
|
+
LC_TWOLEVEL_HINTS => "LC_TWOLEVEL_HINTS",
|
78
|
+
LC_PREBIND_CKSUM => "LC_PREBIND_CKSUM",
|
79
|
+
LC_LOAD_WEAK_DYLIB => "LC_LOAD_WEAK_DYLIB",
|
80
|
+
LC_SEGMENT_64 => "LC_SEGMENT_64",
|
81
|
+
LC_ROUTINES_64 => "LC_ROUTINES_64",
|
82
|
+
LC_UUID => "LC_UUID",
|
83
|
+
LC_RPATH => "LC_RPATH",
|
84
|
+
LC_CODE_SIGNATURE => "LC_CODE_SIGNATURE",
|
85
|
+
LC_SEGMENT_SPLIT_INFO => "LC_SEGMENT_SPLIT_INFO",
|
86
|
+
LC_REEXPORT_DYLIB => "LC_REEXPORT_DYLIB",
|
87
|
+
LC_LAZY_LOAD_DYLIB => "LC_LAZY_LOAD_DYLIB",
|
88
|
+
LC_ENCRYPTION_INFO => "LC_ENCRYPTION_INFO",
|
89
|
+
LC_DYLD_INFO => "LC_DYLD_INFO",
|
90
|
+
LC_DYLD_INFO_ONLY => "LC_DYLD_INFO_ONLY",
|
91
|
+
LC_LOAD_UPWARD_DYLIB => "LC_LOAD_UPWARD_DYLIB",
|
92
|
+
LC_VERSION_MIN_MACOSX => "LC_VERSION_MIN_MACOSX",
|
93
|
+
LC_VERSION_MIN_IPHONEOS => "LC_VERSION_MIN_IPHONEOS",
|
94
|
+
LC_FUNCTION_STARTS => "LC_FUNCTION_STARTS",
|
95
|
+
LC_DYLD_ENVIRONMENT => "LC_DYLD_ENVIRONMENT",
|
96
|
+
LC_MAIN => "LC_MAIN",
|
97
|
+
LC_DATA_IN_CODE => "LC_DATA_IN_CODE",
|
98
|
+
LC_SOURCE_VERSION => "LC_SOURCE_VERSION",
|
99
|
+
LC_DYLIB_CODE_SIGN_DRS => "LC_DYLIB_CODE_SIGN_DRS",
|
100
|
+
LC_ENCRYPTION_INFO_64 => "LC_ENCRYPTION_INFO_64",
|
101
|
+
LC_LINKER_OPTION => "LC_LINKER_OPTION",
|
102
|
+
LC_LINKER_OPTIMIZATION_HINT => "LC_LINKER_OPTIMIZATION_HINT"
|
103
|
+
}
|
104
|
+
|
105
|
+
LC_STRUCTURES = {
|
106
|
+
LC_SEGMENT => "SegmentCommand",
|
107
|
+
LC_SYMTAB => "SymtabCommand",
|
108
|
+
LC_SYMSEG => "LoadCommand", # obsolete
|
109
|
+
LC_THREAD => "ThreadCommand",
|
110
|
+
LC_UNIXTHREAD => "ThreadCommand",
|
111
|
+
LC_LOADFVMLIB => "LoadCommand", # obsolete
|
112
|
+
LC_IDFVMLIB => "LoadCommand", # obsolete
|
113
|
+
LC_IDENT => "LoadCommand", # obsolete
|
114
|
+
LC_FVMFILE => "LoadCommand", # reserved for internal use only
|
115
|
+
LC_PREPAGE => "LoadCommand", # reserved for internal use only
|
116
|
+
LC_DYSYMTAB => "DysymtabCommand",
|
117
|
+
LC_LOAD_DYLIB => "DylibCommand",
|
118
|
+
LC_ID_DYLIB => "DylibCommand",
|
119
|
+
LC_LOAD_DYLINKER => "DylinkerCommand",
|
120
|
+
LC_ID_DYLINKER => "DylinkerCommand",
|
121
|
+
LC_PREBOUND_DYLIB => "PreboundDylibCommand",
|
122
|
+
LC_ROUTINES => "RoutinesCommand",
|
123
|
+
LC_SUB_FRAMEWORK => "SubFrameworkCommand",
|
124
|
+
LC_SUB_UMBRELLA => "SubUmbrellaCommand",
|
125
|
+
LC_SUB_CLIENT => "SubClientCommand",
|
126
|
+
LC_SUB_LIBRARY => "SubLibraryCommand",
|
127
|
+
LC_TWOLEVEL_HINTS => "TwolevelHintsCommand",
|
128
|
+
LC_PREBIND_CKSUM => "PrebindCksumCommand",
|
129
|
+
LC_LOAD_WEAK_DYLIB => "DylibCommand",
|
130
|
+
LC_SEGMENT_64 => "SegmentCommand64",
|
131
|
+
LC_ROUTINES_64 => "RoutinesCommand64",
|
132
|
+
LC_UUID => "UUIDCommand",
|
133
|
+
LC_RPATH => "RpathCommand",
|
134
|
+
LC_CODE_SIGNATURE => "LinkeditDataCommand",
|
135
|
+
LC_SEGMENT_SPLIT_INFO => "LinkeditDataCommand",
|
136
|
+
LC_REEXPORT_DYLIB => "DylibCommand",
|
137
|
+
LC_LAZY_LOAD_DYLIB => "LoadCommand", # undoc, maybe DylibCommand?
|
138
|
+
LC_ENCRYPTION_INFO => "EncryptionInfoCommand",
|
139
|
+
LC_DYLD_INFO => "DyldInfoCommand",
|
140
|
+
LC_DYLD_INFO_ONLY => "DyldInfoCommand",
|
141
|
+
LC_LOAD_UPWARD_DYLIB => "LoadCommand", # undoc, maybe DylibCommand?
|
142
|
+
LC_VERSION_MIN_MACOSX => "VersionMinCommand",
|
143
|
+
LC_VERSION_MIN_IPHONEOS => "VersionMinCommand",
|
144
|
+
LC_FUNCTION_STARTS => "LinkeditDataCommand",
|
145
|
+
LC_DYLD_ENVIRONMENT => "DylinkerCommand",
|
146
|
+
LC_MAIN => "EntryPointCommand",
|
147
|
+
LC_DATA_IN_CODE => "LinkeditDataCommand",
|
148
|
+
LC_SOURCE_VERSION => "SourceVersionCommand",
|
149
|
+
LC_DYLIB_CODE_SIGN_DRS => "LinkeditDataCommand",
|
150
|
+
LC_ENCRYPTION_INFO_64 => "EncryptionInfoCommand64",
|
151
|
+
LC_LINKER_OPTION => "LinkerOptionCommand",
|
152
|
+
LC_LINKER_OPTIMIZATION_HINT => "LinkeditDataCommand"
|
153
|
+
}
|
154
|
+
|
155
|
+
# Mach-O load command structure
|
156
|
+
# this is the most generic load command - only cmd ID and size are
|
157
|
+
# represented, and no actual data. used when a more specific class
|
158
|
+
# isn't available/implemented
|
159
|
+
class LoadCommand < MachOStructure
|
160
|
+
attr_reader :offset, :cmd, :cmdsize
|
161
|
+
|
162
|
+
@format = "VV"
|
163
|
+
@sizeof = 8
|
164
|
+
|
165
|
+
def self.new_from_bin(offset, bin)
|
166
|
+
self.new(offset, *bin.unpack(@format))
|
167
|
+
end
|
168
|
+
|
169
|
+
def initialize(offset, cmd, cmdsize)
|
170
|
+
@offset = offset
|
171
|
+
@cmd = cmd
|
172
|
+
@cmdsize = cmdsize
|
173
|
+
end
|
174
|
+
|
175
|
+
def to_s
|
176
|
+
LOAD_COMMANDS[cmd]
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class UUIDCommand < LoadCommand
|
181
|
+
attr_reader :uuid
|
182
|
+
|
183
|
+
@format = "VVa16"
|
184
|
+
@sizeof = 24
|
185
|
+
|
186
|
+
def initialize(offset, cmd, cmdsize, uuid)
|
187
|
+
super(offset, cmd, cmdsize)
|
188
|
+
@uuid = uuid.unpack("C16") # re-unpack for the actual UUID array
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
class SegmentCommand < LoadCommand
|
193
|
+
attr_reader :segname, :vmaddr, :vmsize, :fileoff, :filesize, :maxprot
|
194
|
+
attr_reader :initprot, :nsects, :flags
|
195
|
+
|
196
|
+
@format = "VVa16VVVVVVVV"
|
197
|
+
@sizeof = 56
|
198
|
+
|
199
|
+
def initialize(offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff,
|
200
|
+
filesize, maxprot, initprot, nsects, flags)
|
201
|
+
super(offset, cmd, cmdsize)
|
202
|
+
@segname = segname
|
203
|
+
@vmaddr = vmaddr
|
204
|
+
@vmsize = vmsize
|
205
|
+
@fileoff = fileoff
|
206
|
+
@filesize = filesize
|
207
|
+
@maxprot = maxprot
|
208
|
+
@initprot = initprot
|
209
|
+
@nsects = nsects
|
210
|
+
@flags = flags
|
211
|
+
end
|
212
|
+
|
213
|
+
def segment_name
|
214
|
+
@segname.delete("\x00")
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
class SegmentCommand64 < LoadCommand
|
219
|
+
attr_reader :segname, :vmaddr, :vmsize, :fileoff, :filesize, :maxprot
|
220
|
+
attr_reader :initprot, :nsects, :flags
|
221
|
+
|
222
|
+
@format = "VVa16QQQQVVVV"
|
223
|
+
@sizeof = 72
|
224
|
+
|
225
|
+
def initialize(offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff,
|
226
|
+
filesize, maxprot, initprot, nsects, flags)
|
227
|
+
super(offset, cmd, cmdsize)
|
228
|
+
@segname = segname
|
229
|
+
@vmaddr = vmaddr
|
230
|
+
@vmsize = vmsize
|
231
|
+
@fileoff = fileoff
|
232
|
+
@filesize = filesize
|
233
|
+
@maxprot = maxprot
|
234
|
+
@initprot = initprot
|
235
|
+
@nsects = nsects
|
236
|
+
@flags = flags
|
237
|
+
end
|
238
|
+
|
239
|
+
def segment_name
|
240
|
+
@segname.delete("\x00")
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
class DylibCommand < LoadCommand
|
245
|
+
attr_reader :name, :timestamp, :current_version, :compatibility_version
|
246
|
+
|
247
|
+
@format = "VVVVVV"
|
248
|
+
@sizeof = 24
|
249
|
+
|
250
|
+
def initialize(offset, cmd, cmdsize, name, timestamp, current_version,
|
251
|
+
compatibility_version)
|
252
|
+
super(offset, cmd, cmdsize)
|
253
|
+
@name = name
|
254
|
+
@timestamp = timestamp
|
255
|
+
@current_version = current_version
|
256
|
+
@compatibility_version = compatibility_version
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
class DylinkerCommand < LoadCommand
|
261
|
+
attr_reader :name
|
262
|
+
|
263
|
+
@format = "VVV"
|
264
|
+
@sizeof = 12
|
265
|
+
|
266
|
+
def initialize(offset, cmd, cmdsize, name)
|
267
|
+
super(offset, cmd, cmdsize)
|
268
|
+
@name = name
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
class PreboundDylibCommand < LoadCommand
|
273
|
+
attr_reader :name, :nmodules, :linked_modules
|
274
|
+
|
275
|
+
@format = "VVVVV"
|
276
|
+
@sizeof = 20
|
277
|
+
|
278
|
+
def initialize(offset, cmd, cmdsize, name, nmodules, linked_modules)
|
279
|
+
super(offset, cmd, cmdsize)
|
280
|
+
@name = name
|
281
|
+
@nmodules = nmodules
|
282
|
+
@linked_modules = linked_modules
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
# NOTE: cctools-870 has all fields of thread_command commented out
|
287
|
+
# except common ones (cmd, cmdsize)
|
288
|
+
class ThreadCommand < LoadCommand
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
class RoutinesCommand < LoadCommand
|
293
|
+
attr_reader :init_address, :init_module, :reserved1, :reserved2
|
294
|
+
attr_reader :reserved3, :reserved4, :reserved5, :reserved6
|
295
|
+
|
296
|
+
@format = "VVVVVVVVVV"
|
297
|
+
@sizeof = 40
|
298
|
+
|
299
|
+
def initialize(offset, cmd, cmdsize, init_address, init_module,
|
300
|
+
reserved1, reserved2, reserved3, reserved4, reserved5,
|
301
|
+
reserved6)
|
302
|
+
super(offset, cmd, cmdsize)
|
303
|
+
@init_address = init_address
|
304
|
+
@init_module = init_module
|
305
|
+
@reserved1 = reserved1
|
306
|
+
@reserved2 = reserved2
|
307
|
+
@reserved3 = reserved3
|
308
|
+
@reserved4 = reserved4
|
309
|
+
@reserved5 = reserved5
|
310
|
+
@reserved6 = reserved6
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
class RoutinesCommand64 < LoadCommand
|
315
|
+
attr_reader :init_address, :init_module, :reserved1, :reserved2
|
316
|
+
attr_reader :reserved3, :reserved4, :reserved5, :reserved6
|
317
|
+
|
318
|
+
@format = "VVQQQQQQQQ"
|
319
|
+
@sizeof = 72
|
320
|
+
|
321
|
+
def initialize(offset, cmd, cmdsize, init_address, init_module,
|
322
|
+
reserved1, reserved2, reserved3, reserved4, reserved5,
|
323
|
+
reserved6)
|
324
|
+
super(offset, cmd, cmdsize)
|
325
|
+
@init_address = init_address
|
326
|
+
@init_module = init_module
|
327
|
+
@reserved1 = reserved1
|
328
|
+
@reserved2 = reserved2
|
329
|
+
@reserved3 = reserved3
|
330
|
+
@reserved4 = reserved4
|
331
|
+
@reserved5 = reserved5
|
332
|
+
@reserved6 = reserved6
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
class SubFrameworkCommand < LoadCommand
|
337
|
+
attr_reader :umbrella
|
338
|
+
|
339
|
+
@format = "VVV"
|
340
|
+
@sizeof = 12
|
341
|
+
|
342
|
+
def initialize(offset, cmd, cmdsize, umbrella)
|
343
|
+
super(offset, cmd, cmdsize)
|
344
|
+
@umbrella = umbrella
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
class SubUmbrellaCommand < LoadCommand
|
349
|
+
attr_reader :sub_umbrella
|
350
|
+
|
351
|
+
@format = "VVV"
|
352
|
+
@sizeof = 12
|
353
|
+
|
354
|
+
def initialize(offset, cmd, cmdsize, sub_umbrella)
|
355
|
+
super(offset, cmd, cmdsize)
|
356
|
+
@sub_umbrella = sub_umbrella
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class SubLibraryCommand < LoadCommand
|
361
|
+
attr_reader :sub_library
|
362
|
+
|
363
|
+
@format = "VVV"
|
364
|
+
@sizeof = 12
|
365
|
+
|
366
|
+
def initialize(offset, cmd, cmdsize, sub_library)
|
367
|
+
super(offset, cmd, cmdsize)
|
368
|
+
@sub_library = sub_library
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
class SubClientCommand < LoadCommand
|
373
|
+
attr_reader :sub_client
|
374
|
+
|
375
|
+
@format = "VVV"
|
376
|
+
@sizeof = 12
|
377
|
+
|
378
|
+
def initialize(offset, cmd, cmdsize, sub_client)
|
379
|
+
super(offset, cmd, cmdsize)
|
380
|
+
@sub_client = sub_client
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
class SymtabCommand < LoadCommand
|
385
|
+
attr_reader :symoff, :nsyms, :stroff, :strsize
|
386
|
+
|
387
|
+
@format = "VVVVVV"
|
388
|
+
@sizeof = 24
|
389
|
+
|
390
|
+
def initialize(offset, cmd, cmdsize, symoff, nsyms, stroff, strsize)
|
391
|
+
super(offset, cmd, cmdsize)
|
392
|
+
@symoff = symoff
|
393
|
+
@nsyms = nsyms
|
394
|
+
@stroff = stroff
|
395
|
+
@strsize = strsize
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
class DysymtabCommand < LoadCommand
|
400
|
+
attr_reader :ilocalsym, :nlocalsym, :iextdefsym, :nextdefsym
|
401
|
+
attr_reader :iundefsym, :nundefsym, :tocoff, :ntoc, :modtaboff
|
402
|
+
attr_reader :nmodtab, :extrefsymoff, :nextrefsyms, :indirectsymoff
|
403
|
+
attr_reader :nindirectsyms, :extreloff, :nextrel, :locreloff, :nlocrel
|
404
|
+
|
405
|
+
@format = "VVVVVVVVVVVVVVVVVVVV"
|
406
|
+
@sizeof = 80
|
407
|
+
|
408
|
+
# ugh
|
409
|
+
def initialize(offset, cmd, cmdsize, ilocalsym, nlocalsym, iextdefsym,
|
410
|
+
nextdefsym, iundefsym, nundefsym, tocoff, ntoc, modtaboff,
|
411
|
+
nmodtab, extrefsymoff, nextrefsyms, indirectsymoff,
|
412
|
+
nindirectsyms, extreloff, nextrel, locreloff, nlocrel)
|
413
|
+
super(offset, cmd, cmdsize)
|
414
|
+
@ilocalsym = ilocalsym
|
415
|
+
@nlocalsym = nlocalsym
|
416
|
+
@iextdefsym = iextdefsym
|
417
|
+
@nextdefsym = nextdefsym
|
418
|
+
@iundefsym = iundefsym
|
419
|
+
@nundefsym = nundefsym
|
420
|
+
@tocoff = tocoff
|
421
|
+
@ntoc = ntoc
|
422
|
+
@modtaboff = modtaboff
|
423
|
+
@nmodtab = nmodtab
|
424
|
+
@extrefsymoff = extrefsymoff
|
425
|
+
@nextrefsyms = nextrefsyms
|
426
|
+
@indirectsymoff = indirectsymoff
|
427
|
+
@nindirectsyms = nindirectsyms
|
428
|
+
@extreloff = extreloff
|
429
|
+
@nextrel = nextrel
|
430
|
+
@locreloff = locreloff
|
431
|
+
@nlocrel = nlocrel
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
class TwolevelHintsCommand < LoadCommand
|
436
|
+
attr_reader :htoffset, :nhints
|
437
|
+
|
438
|
+
@format = "VVVV"
|
439
|
+
@sizeof = 16
|
440
|
+
|
441
|
+
def initialize(offset, cmd, cmdsize, htoffset, nhints)
|
442
|
+
super(offset, cmd, cmdsize)
|
443
|
+
@htoffset = htoffset
|
444
|
+
@nhints = nhints
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
class PrebindCksumCommand < LoadCommand
|
449
|
+
attr_reader :cksum
|
450
|
+
|
451
|
+
@format = "VVV"
|
452
|
+
@sizeof = 12
|
453
|
+
|
454
|
+
def initialize(offset, cmd, cmdsize, cksum)
|
455
|
+
super(offset, cmd, cmdsize)
|
456
|
+
@cksum = cksum
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
class RpathCommand < LoadCommand
|
461
|
+
attr_reader :path
|
462
|
+
|
463
|
+
@format = "VVV"
|
464
|
+
@sizeof = 12
|
465
|
+
|
466
|
+
def initialize(offset, cmd, cmdsize, path)
|
467
|
+
super(offset, cmd, cmdsize)
|
468
|
+
@path = path
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
class LinkeditDataCommand < LoadCommand
|
473
|
+
attr_reader :dataoff, :datasize
|
474
|
+
|
475
|
+
@format = "VVVV"
|
476
|
+
@sizeof = 16
|
477
|
+
|
478
|
+
def initialize(offset, cmd, cmdsize, dataoff, datasize)
|
479
|
+
super(offset, cmd, cmdsize)
|
480
|
+
@dataoff = dataoff
|
481
|
+
@datasize = datasize
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
class EncryptionInfoCommand < LoadCommand
|
486
|
+
attr_reader :cryptoff, :cryptsize, :cryptid
|
487
|
+
|
488
|
+
@format = "VVVVV"
|
489
|
+
@sizeof = 20
|
490
|
+
|
491
|
+
def initialize(offset, cmd, cmdsize, cryptoff, cryptsize, cryptid)
|
492
|
+
super(offset, cmd, cmdsize)
|
493
|
+
@cryptoff = cryptoff
|
494
|
+
@cryptsize = cryptsize
|
495
|
+
@cryptid = cryptid
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
class EncryptionInfoCommand64 < LoadCommand
|
500
|
+
attr_reader :cryptoff, :cryptsize, :cryptid, :pad
|
501
|
+
|
502
|
+
@format = "VVVVVV"
|
503
|
+
@sizeof = 24
|
504
|
+
|
505
|
+
def initialize(offset, cmd, cmdsize, cryptoff, cryptsize, cryptid)
|
506
|
+
super(offset, cmd, cmdsize)
|
507
|
+
@cryptoff = cryptoff
|
508
|
+
@cryptsize = cryptsize
|
509
|
+
@cryptid = cryptid
|
510
|
+
@pad = pad
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
class VersionMinCommand < LoadCommand
|
515
|
+
attr_reader :version, :sdk
|
516
|
+
|
517
|
+
@format = "VVVV"
|
518
|
+
@sizeof = 16
|
519
|
+
|
520
|
+
def initialize(offset, cmd, cmdsize, version, sdk)
|
521
|
+
super(offset, cmd, cmdsize)
|
522
|
+
@version = version
|
523
|
+
@sdk = sdk
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
class DyldInfoCommand < LoadCommand
|
528
|
+
attr_reader :rebase_off, :rebase_size, :bind_off, :bind_size
|
529
|
+
attr_reader :weak_bind_off, :weak_bind_size, :lazy_bind_off
|
530
|
+
attr_reader :lazy_bind_size, :export_off, :export_size
|
531
|
+
|
532
|
+
@format = "VVVVVVVVVVVV"
|
533
|
+
@sizeof = 48
|
534
|
+
|
535
|
+
def initialize(offset, cmd, cmdsize, rebase_off, rebase_size, bind_off,
|
536
|
+
bind_size, weak_bind_off, weak_bind_size, lazy_bind_off,
|
537
|
+
lazy_bind_size, export_off, export_size)
|
538
|
+
super(offset, cmd, cmdsize)
|
539
|
+
@rebase_off = rebase_off
|
540
|
+
@rebase_size = rebase_size
|
541
|
+
@bind_off = bind_off
|
542
|
+
@bind_size = bind_size
|
543
|
+
@weak_bind_off = weak_bind_off
|
544
|
+
@weak_bind_size = weak_bind_size
|
545
|
+
@lazy_bind_off = lazy_bind_off
|
546
|
+
@lazy_bind_size = lazy_bind_size
|
547
|
+
@export_off = export_off
|
548
|
+
@export_size = export_size
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
class LinkerOptionCommand < LoadCommand
|
553
|
+
attr_reader :count
|
554
|
+
|
555
|
+
@format = "VVV"
|
556
|
+
@sizeof = 12
|
557
|
+
|
558
|
+
def initialize(offset, cmd, cmdsize, count)
|
559
|
+
super(offset, cmd, cmdsize)
|
560
|
+
@count = count
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
class EntryPointCommand < LoadCommand
|
565
|
+
attr_reader :entryoff, :stacksize
|
566
|
+
|
567
|
+
@format = "VVQQ"
|
568
|
+
@sizeof = 24
|
569
|
+
|
570
|
+
def initialize(offset, cmd, cmdsize, entryoff, stacksize)
|
571
|
+
super(offset, cmd, cmdsize)
|
572
|
+
@entryoff = entryoff
|
573
|
+
@stacksize = stacksize
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
class SourceVersionCommand < LoadCommand
|
578
|
+
attr_reader :version
|
579
|
+
|
580
|
+
@format = "VVQ"
|
581
|
+
@sizeof = 16
|
582
|
+
|
583
|
+
def initialize(offset, cmd, cmdsize, version)
|
584
|
+
super(offset, cmd, cmdsize)
|
585
|
+
@version = version
|
586
|
+
end
|
587
|
+
end
|
588
|
+
end
|