ruby-macho 0.1.8 → 0.1.9
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/headers.rb +33 -107
- data/lib/macho/load_commands.rb +43 -36
- data/lib/macho/macho_file.rb +2 -2
- data/lib/macho/sections.rb +58 -113
- 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: 939f8d565fc3d98bd633414e797b2f8cd70c0df6
|
4
|
+
data.tar.gz: 3ab244e120eba39d1f84a8b495de6c221f4fc8f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb2d31798f5d4b6fefd00a2c3e5c562595331015f9a44b9d3b5bcce84b43db3c473236222412bc1b26e358161df2451e15c8ea292c1c0fc433292afc9871772c
|
7
|
+
data.tar.gz: 39bd050a693d85cd48e7ce3594d5cfd199732e171df7026474af03723bdd3c1a58108df08c078333fc0304ed84691c14a76bb15b6a168f8411f993e4e7b0b5d2
|
data/lib/macho.rb
CHANGED
data/lib/macho/headers.rb
CHANGED
@@ -111,6 +111,7 @@ module MachO
|
|
111
111
|
MH_KEXT_BUNDLE = 0xb
|
112
112
|
|
113
113
|
# association of filetypes to string representations
|
114
|
+
# @api private
|
114
115
|
MH_FILETYPES = {
|
115
116
|
MH_OBJECT => "MH_OBJECT",
|
116
117
|
MH_EXECUTE => "MH_EXECUTE",
|
@@ -125,112 +126,35 @@ module MachO
|
|
125
126
|
MH_KEXT_BUNDLE => "MH_KEXT_BUNDLE"
|
126
127
|
}
|
127
128
|
|
128
|
-
#
|
129
|
-
|
130
|
-
|
131
|
-
# the object file is the output of an incremental link against a base file (flag)
|
132
|
-
MH_INCRLINK = 0x2
|
133
|
-
|
134
|
-
# the object file is input for the dynamic linker and can't be staticly link edited again (flag)
|
135
|
-
MH_DYLDLINK = 0x4
|
136
|
-
|
137
|
-
# the object file's undefined references are bound by the dynamic linker when loaded (flag)
|
138
|
-
MH_BINDATLOAD = 0x8
|
139
|
-
|
140
|
-
# the file has its dynamic undefined references prebound (flag)
|
141
|
-
MH_PREBOUND = 0x10
|
142
|
-
|
143
|
-
# the file has its read-only and read-write segments split (flag)
|
144
|
-
MH_SPLIT_SEGS = 0x20
|
145
|
-
|
146
|
-
# the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete) (flag)
|
147
|
-
MH_LAZY_INIT = 0x40
|
148
|
-
|
149
|
-
# the image is using two-level name space bindings (flag)
|
150
|
-
MH_TWOLEVEL = 0x80
|
151
|
-
|
152
|
-
# the executable is forcing all images to use flat name space bindings (flag)
|
153
|
-
MH_FORCE_FLAT = 0x100
|
154
|
-
|
155
|
-
# this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used (flag)
|
156
|
-
MH_NOMULTIDEFS = 0x200
|
157
|
-
|
158
|
-
# do not have dyld notify the prebinding agent about this executable (flag)
|
159
|
-
MH_NOPREFIXBINDING = 0x400
|
160
|
-
|
161
|
-
# the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set (flag)
|
162
|
-
MH_PREBINDABLE = 0x800
|
163
|
-
|
164
|
-
# indicates that this binary binds to all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL are both set (flag)
|
165
|
-
MH_ALLMODSBOUND = 0x1000
|
166
|
-
|
167
|
-
# safe to divide up the sections into sub-sections via symbols for dead code stripping (flag)
|
168
|
-
MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000
|
169
|
-
|
170
|
-
# the binary has been canonicalized via the unprebind operation (flag)
|
171
|
-
MH_CANONICAL = 0x4000
|
172
|
-
|
173
|
-
# the final linked image contains external weak symbols (flag)
|
174
|
-
MH_WEAK_DEFINES = 0x8000
|
175
|
-
|
176
|
-
# the final linked image uses weak symbols (flag)
|
177
|
-
MH_BINDS_TO_WEAK = 0x10000
|
178
|
-
|
179
|
-
# When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes (flag)
|
180
|
-
MH_ALLOW_STACK_EXECUTION = 0x20000
|
181
|
-
|
182
|
-
# When this bit is set, the binary declares it is safe for use in processes with uid zero (flag)
|
183
|
-
MH_ROOT_SAFE = 0x40000
|
184
|
-
|
185
|
-
# When this bit is set, the binary declares it is safe for use in processes when issetugid() is true (flag)
|
186
|
-
MH_SETUID_SAFE = 0x80000
|
187
|
-
|
188
|
-
# When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported (flag)
|
189
|
-
MH_NO_REEXPORTED_DYLIBS = 0x100000
|
190
|
-
|
191
|
-
# When this bit is set, the OS will load the main executable at a random address. Only used in MH_EXECUTE filetypes (flag)
|
192
|
-
MH_PIE = 0x200000
|
193
|
-
|
194
|
-
# Only for use on dylibs. When linking against a dylib that has this bit set, the static linker will automatically not create a LC_LOAD_DYLIB load command to the dylib if no symbols are being referenced from the dylib (flag)
|
195
|
-
MH_DEAD_STRIPPABLE_DYLIB = 0x400000
|
196
|
-
|
197
|
-
# Contains a section of type S_THREAD_LOCAL_VARIABLES (flag)
|
198
|
-
MH_HAS_TLV_DESCRIPTORS = 0x800000
|
199
|
-
|
200
|
-
# When this bit is set, the OS will run the main executable with a non-executable heap even on platforms (e.g. i386) that don't require it. Only used in MH_EXECUTE filetypes (flag)
|
201
|
-
MH_NO_HEAP_EXECUTION = 0x1000000
|
202
|
-
|
203
|
-
# The code was linked for use in an application extension (flag)
|
204
|
-
MH_APP_EXTENSION_SAFE = 0x02000000
|
205
|
-
|
206
|
-
# association of mach header flags to string representations
|
129
|
+
# association of mach header flag symbols to values
|
130
|
+
# @api private
|
207
131
|
MH_FLAGS = {
|
208
|
-
MH_NOUNDEFS =>
|
209
|
-
MH_INCRLINK =>
|
210
|
-
MH_DYLDLINK =>
|
211
|
-
MH_BINDATLOAD =>
|
212
|
-
MH_PREBOUND =>
|
213
|
-
MH_SPLIT_SEGS =>
|
214
|
-
MH_LAZY_INIT =>
|
215
|
-
MH_TWOLEVEL =>
|
216
|
-
MH_FORCE_FLAT =>
|
217
|
-
MH_NOMULTIDEFS =>
|
218
|
-
MH_NOPREFIXBINDING =>
|
219
|
-
MH_PREBINDABLE =>
|
220
|
-
MH_ALLMODSBOUND =>
|
221
|
-
MH_SUBSECTIONS_VIA_SYMBOLS =>
|
222
|
-
MH_CANONICAL =>
|
223
|
-
MH_WEAK_DEFINES =>
|
224
|
-
MH_BINDS_TO_WEAK =>
|
225
|
-
MH_ALLOW_STACK_EXECUTION =>
|
226
|
-
MH_ROOT_SAFE =>
|
227
|
-
MH_SETUID_SAFE =>
|
228
|
-
MH_NO_REEXPORTED_DYLIBS =>
|
229
|
-
MH_PIE =>
|
230
|
-
MH_DEAD_STRIPPABLE_DYLIB =>
|
231
|
-
MH_HAS_TLV_DESCRIPTORS =>
|
232
|
-
MH_NO_HEAP_EXECUTION =>
|
233
|
-
MH_APP_EXTENSION_SAFE =>
|
132
|
+
:MH_NOUNDEFS => 0x1,
|
133
|
+
:MH_INCRLINK => 0x2,
|
134
|
+
:MH_DYLDLINK => 0x4,
|
135
|
+
:MH_BINDATLOAD => 0x8,
|
136
|
+
:MH_PREBOUND => 0x10,
|
137
|
+
:MH_SPLIT_SEGS => 0x20,
|
138
|
+
:MH_LAZY_INIT => 0x40,
|
139
|
+
:MH_TWOLEVEL => 0x80,
|
140
|
+
:MH_FORCE_FLAT => 0x100,
|
141
|
+
:MH_NOMULTIDEFS => 0x200,
|
142
|
+
:MH_NOPREFIXBINDING => 0x400,
|
143
|
+
:MH_PREBINDABLE => 0x800,
|
144
|
+
:MH_ALLMODSBOUND => 0x1000,
|
145
|
+
:MH_SUBSECTIONS_VIA_SYMBOLS => 0x2000,
|
146
|
+
:MH_CANONICAL => 0x4000,
|
147
|
+
:MH_WEAK_DEFINES => 0x8000,
|
148
|
+
:MH_BINDS_TO_WEAK => 0x10000,
|
149
|
+
:MH_ALLOW_STACK_EXECUTION => 0x20000,
|
150
|
+
:MH_ROOT_SAFE => 0x40000,
|
151
|
+
:MH_SETUID_SAFE => 0x80000,
|
152
|
+
:MH_NO_REEXPORTED_DYLIBS => 0x100000,
|
153
|
+
:MH_PIE => 0x200000,
|
154
|
+
:MH_DEAD_STRIPPABLE_DYLIB => 0x400000,
|
155
|
+
:MH_HAS_TLV_DESCRIPTORS => 0x800000,
|
156
|
+
:MH_NO_HEAP_EXECUTION => 0x1000000,
|
157
|
+
:MH_APP_EXTENSION_SAFE => 0x02000000
|
234
158
|
}
|
235
159
|
|
236
160
|
# Fat binary header structure
|
@@ -323,10 +247,12 @@ module MachO
|
|
323
247
|
end
|
324
248
|
|
325
249
|
# @example
|
326
|
-
# puts "this mach-o has position-independent execution" if header.flag?(MH_PIE)
|
327
|
-
# @param flag [
|
250
|
+
# puts "this mach-o has position-independent execution" if header.flag?(:MH_PIE)
|
251
|
+
# @param flag [Symbol] a mach header flag symbol
|
328
252
|
# @return [Boolean] true if `flag` is present in the header's flag section
|
329
253
|
def flag?(flag)
|
254
|
+
flag = MH_FLAGS[flag]
|
255
|
+
return false if flag.nil?
|
330
256
|
flags & flag == flag
|
331
257
|
end
|
332
258
|
end
|
data/lib/macho/load_commands.rb
CHANGED
@@ -3,7 +3,7 @@ module MachO
|
|
3
3
|
# LC_REQ_DYLD to be recognized by the dynamic linder (dyld)
|
4
4
|
LC_REQ_DYLD = 0x80000000
|
5
5
|
|
6
|
-
# association of load commands to
|
6
|
+
# association of load commands to symbol representations
|
7
7
|
# @api private
|
8
8
|
LOAD_COMMANDS = {
|
9
9
|
0x1 => :LC_SEGMENT,
|
@@ -55,7 +55,8 @@ module MachO
|
|
55
55
|
0x2e => :LC_LINKER_OPTIMIZATION_HINT
|
56
56
|
}
|
57
57
|
|
58
|
-
# association of load
|
58
|
+
# association of load command symbols to string representations of classes
|
59
|
+
# @api private
|
59
60
|
LC_STRUCTURES = {
|
60
61
|
:LC_SEGMENT => "SegmentCommand",
|
61
62
|
:LC_SYMTAB => "SymtabCommand",
|
@@ -106,41 +107,27 @@ module MachO
|
|
106
107
|
:LC_LINKER_OPTIMIZATION_HINT => "LinkeditDataCommand"
|
107
108
|
}
|
108
109
|
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
# icon segment
|
122
|
-
SEG_ICON = "__ICON"
|
123
|
-
|
124
|
-
# link editor structures segment
|
125
|
-
SEG_LINKEDIT = "__LINKEDIT"
|
126
|
-
|
127
|
-
# unix stack segment
|
128
|
-
SEG_UNIXSTACK = "__UNIXSTACK"
|
129
|
-
|
130
|
-
# segment for self-modifying code with RWX permissions
|
131
|
-
SEG_IMPORT = "__IMPORT"
|
132
|
-
|
133
|
-
# the file contents for this segment is for the high part of the VM space, the low part is zero filled (for stacks in core files)
|
134
|
-
SG_HIGHVM = 0x1
|
135
|
-
|
136
|
-
# this segment is the VM that is allocated by a fixed VM library, for overlap checking in the link editor
|
137
|
-
SG_FVMLIB = 0x2
|
138
|
-
|
139
|
-
# this segment has nothing that was relocated in it and nothing relocated to it, that is it maybe safely replaced without relocation
|
140
|
-
SG_NORELOC = 0x4
|
110
|
+
# association of segment name symbols to names
|
111
|
+
# @api private
|
112
|
+
SEGMENT_NAMES = {
|
113
|
+
:SEG_PAGEZERO => "__PAGEZERO",
|
114
|
+
:SEG_TEXT => "__TEXT",
|
115
|
+
:SEG_DATA => "__DATA",
|
116
|
+
:SEG_OBJC => "__OBJC",
|
117
|
+
:SEG_ICON => "__ICON",
|
118
|
+
:SEG_LINKEDIT => "__LINKEDIT",
|
119
|
+
:SEG_UNIXSTACK => "__UNIXSTACK",
|
120
|
+
:SEG_IMPORT => "__IMPORT"
|
121
|
+
}
|
141
122
|
|
142
|
-
#
|
143
|
-
|
123
|
+
# association of segment flag symbols to values
|
124
|
+
# @api private
|
125
|
+
SEGMENT_FLAGS = {
|
126
|
+
:SG_HIGHVM => 0x1,
|
127
|
+
:SG_FVMLIB => 0x2,
|
128
|
+
:SG_NORELOC => 0x4,
|
129
|
+
:SG_PROTECTED_VERSION_1 => 0x8
|
130
|
+
}
|
144
131
|
|
145
132
|
# Mach-O load command structure
|
146
133
|
# This is the most generic load command - only cmd ID and size are
|
@@ -293,6 +280,16 @@ module MachO
|
|
293
280
|
@nsects = nsects
|
294
281
|
@flags = flags
|
295
282
|
end
|
283
|
+
|
284
|
+
# @example
|
285
|
+
# puts "this segment relocated in/to it" if sect.flag?(:SG_NORELOC)
|
286
|
+
# @param flag [Symbol] a segment flag symbol
|
287
|
+
# @return [Boolean] true if `flag` is present in the segment's flag field
|
288
|
+
def flag?(flag)
|
289
|
+
flag = SEGMENT_FLAGS[flag]
|
290
|
+
return false if flag.nil?
|
291
|
+
flags & flag == flag
|
292
|
+
end
|
296
293
|
end
|
297
294
|
|
298
295
|
# A load command indicating that part of this file is to be mapped into
|
@@ -342,6 +339,16 @@ module MachO
|
|
342
339
|
@nsects = nsects
|
343
340
|
@flags = flags
|
344
341
|
end
|
342
|
+
|
343
|
+
# @example
|
344
|
+
# puts "this segment relocated in/to it" if sect.flag?(:SG_NORELOC)
|
345
|
+
# @param flag [Symbol] a segment flag symbol
|
346
|
+
# @return [Boolean] true if `flag` is present in the segment's flag field
|
347
|
+
def flag?(flag)
|
348
|
+
flag = SEGMENT_FLAGS[flag]
|
349
|
+
return false if flag.nil?
|
350
|
+
flags & flag == flag
|
351
|
+
end
|
345
352
|
end
|
346
353
|
|
347
354
|
# A load command representing some aspect of shared libraries, depending
|
data/lib/macho/macho_file.rb
CHANGED
@@ -442,8 +442,8 @@ module MachO
|
|
442
442
|
# calculate the low file offset (offset to first section data)
|
443
443
|
segments.each do |seg|
|
444
444
|
sections(seg).each do |sect|
|
445
|
-
if sect.size != 0 && !sect.flag?(S_ZEROFILL) &&
|
446
|
-
!sect.flag?(S_THREAD_LOCAL_ZEROFILL) &&
|
445
|
+
if sect.size != 0 && !sect.flag?(:S_ZEROFILL) &&
|
446
|
+
!sect.flag?(:S_THREAD_LOCAL_ZEROFILL) &&
|
447
447
|
sect.offset < low_fileoff
|
448
448
|
|
449
449
|
low_fileoff = sect.offset
|
data/lib/macho/sections.rb
CHANGED
@@ -11,116 +11,59 @@ module MachO
|
|
11
11
|
# system settable attributes mask
|
12
12
|
SECTION_ATTRIBUTES_SYS = 0x00ffff00
|
13
13
|
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
# a template of initial values for thread local variables
|
69
|
-
S_THREAD_LOCAL_ZEROFILL = 0x12
|
70
|
-
|
71
|
-
# thread local variable descriptors
|
72
|
-
S_THREAD_LOCAL_VARIABLES = 0x13
|
73
|
-
|
74
|
-
# pointers to thread local variable descriptors
|
75
|
-
S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14
|
76
|
-
|
77
|
-
# functions to call to initialize thread local variable values
|
78
|
-
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15
|
79
|
-
|
80
|
-
# a section with only true machine instructions
|
81
|
-
S_ATTR_PURE_INSTRUCTIONS = 0x80000000
|
82
|
-
|
83
|
-
# a section with coalesced symbols that are not to be in a ranlib table of contents
|
84
|
-
S_ATTR_NO_TOC = 0x40000000
|
85
|
-
|
86
|
-
# static symbols in this section can be stripped in files with the MH_DYLDLINK flag
|
87
|
-
S_ATTR_STRIP_STATIC_SYMS = 0x20000000
|
88
|
-
|
89
|
-
# no dead stripping
|
90
|
-
S_ATTR_NO_DEAD_STRIP = 0x10000000
|
91
|
-
|
92
|
-
# blocks are live if they reference live blocks
|
93
|
-
S_ATTR_LIVE_SUPPORT = 0x08000000
|
94
|
-
|
95
|
-
# used with i386 code stubs written on by dyld
|
96
|
-
S_ATTR_SELF_MODIFYING_CODE = 0x04000000
|
97
|
-
|
98
|
-
# a debug section
|
99
|
-
S_ATTR_DEBUG = 0x02000000
|
100
|
-
|
101
|
-
# a section containing some machine instructions
|
102
|
-
S_ATTR_SOME_INSTRUCTIONS = 0x00000400
|
103
|
-
|
104
|
-
# a section containing external relocation entries
|
105
|
-
S_ATTR_EXT_RELOC = 0x00000200
|
106
|
-
|
107
|
-
# a section containing local relocation entries
|
108
|
-
S_ATTR_LOC_RELOC = 0x00000100
|
109
|
-
|
110
|
-
# currently known section names
|
111
|
-
# we don't use these anywhere right now, but they're good to have
|
112
|
-
SECT_TEXT = "__text"
|
113
|
-
SECT_FVMLIB_INIT0 = "__fvmlib_init0"
|
114
|
-
SECT_FVMLIB_INIT1 = "__fvmlib_init1"
|
115
|
-
SECT_DATA = "__data"
|
116
|
-
SECT_BSS = "__bss"
|
117
|
-
SECT_COMMON = "__common"
|
118
|
-
SECT_OBJC_SYMBOLS = "__symbol_table"
|
119
|
-
SECT_OBJC_MODULES = "__module_info"
|
120
|
-
SECT_OBJC_STRINGS = "__selector_strs"
|
121
|
-
SECT_OBJC_REFS = "__selector_refs"
|
122
|
-
SECT_ICON_HEADER = "__header"
|
123
|
-
SECT_ICON_TIFF = "__tiff"
|
14
|
+
# association of section flag symbols to values
|
15
|
+
# @api private
|
16
|
+
SECTION_FLAGS = {
|
17
|
+
:S_REGULAR => 0x0,
|
18
|
+
:S_ZEROFILL => 0x1,
|
19
|
+
:S_CSTRING_LITERALS => 0x2,
|
20
|
+
:S_4BYTE_LITERALS => 0x3,
|
21
|
+
:S_8BYTE_LITERALS => 0x4,
|
22
|
+
:S_LITERAL_POINTERS => 0x5,
|
23
|
+
:S_NON_LAZY_SYMBOL_POINTERS => 0x6,
|
24
|
+
:S_LAZY_SYMBOL_POINTERS => 0x7,
|
25
|
+
:S_SYMBOL_STUBS => 0x8,
|
26
|
+
:S_MOD_INIT_FUNC_POINTERS => 0x9,
|
27
|
+
:S_MOD_TERM_FUNC_POINTERS => 0xa,
|
28
|
+
:S_COALESCED => 0xb,
|
29
|
+
:S_GB_ZEROFILE => 0xc,
|
30
|
+
:S_INTERPOSING => 0xd,
|
31
|
+
:S_16BYTE_LITERALS => 0xe,
|
32
|
+
:S_DTRACE_DOF => 0xf,
|
33
|
+
:S_LAZY_DYLIB_SYMBOL_POINTERS => 0x10,
|
34
|
+
:S_THREAD_LOCAL_REGULAR => 0x11,
|
35
|
+
:S_THREAD_LOCAL_ZEROFILL => 0x12,
|
36
|
+
:S_THREAD_LOCAL_VARIABLES => 0x13,
|
37
|
+
:S_THREAD_LOCAL_VARIABLE_POINTERS => 0x14,
|
38
|
+
:S_THREAD_LOCAL_INIT_FUNCTION_POINTERS => 0x15,
|
39
|
+
:S_ATTR_PURE_INSTRUCTIONS => 0x80000000,
|
40
|
+
:S_ATTR_NO_TOC => 0x40000000,
|
41
|
+
:S_ATTR_STRIP_STATIC_SYMS => 0x20000000,
|
42
|
+
:S_ATTR_NO_DEAD_STRIP => 0x10000000,
|
43
|
+
:S_ATTR_LIVE_SUPPORT => 0x08000000,
|
44
|
+
:S_ATTR_SELF_MODIFYING_CODE => 0x04000000,
|
45
|
+
:S_ATTR_DEBUG => 0x02000000,
|
46
|
+
:S_ATTR_SOME_INSTRUCTIONS => 0x00000400,
|
47
|
+
:S_ATTR_EXT_RELOC => 0x00000200,
|
48
|
+
:S_ATTR_LOC_RELOC => 0x00000100
|
49
|
+
}
|
50
|
+
|
51
|
+
# association of section name symbols to names
|
52
|
+
# @api private
|
53
|
+
SECTION_NAMES = {
|
54
|
+
:SECT_TEXT => "__text",
|
55
|
+
:SECT_FVMLIB_INIT0 => "__fvmlib_init0",
|
56
|
+
:SECT_FVMLIB_INIT1 => "__fvmlib_init1",
|
57
|
+
:SECT_DATA => "__data",
|
58
|
+
:SECT_BSS => "__bss",
|
59
|
+
:SECT_COMMON => "__common",
|
60
|
+
:SECT_OBJC_SYMBOLS => "__symbol_table",
|
61
|
+
:SECT_OBJC_MODULES => "__module_info",
|
62
|
+
:SECT_OBJC_STRINGS => "__selector_strs",
|
63
|
+
:SECT_OBJC_REFS => "__selector_refs",
|
64
|
+
:SECT_ICON_HEADER => "__header",
|
65
|
+
:SECT_ICON_TIFF => "__tiff"
|
66
|
+
}
|
124
67
|
|
125
68
|
# Represents a section of a segment for 32-bit architectures.
|
126
69
|
class Section < MachOStructure
|
@@ -187,10 +130,12 @@ module MachO
|
|
187
130
|
end
|
188
131
|
|
189
132
|
# @example
|
190
|
-
# puts "this section is regular" if sect.flag?(S_REGULAR)
|
191
|
-
# @param flag [
|
192
|
-
# @return [Boolean] true if `flag` is present in the
|
133
|
+
# puts "this section is regular" if sect.flag?(:S_REGULAR)
|
134
|
+
# @param flag [Symbol] a section flag symbol
|
135
|
+
# @return [Boolean] true if `flag` is present in the section's flag field
|
193
136
|
def flag?(flag)
|
137
|
+
flag = SECTION_FLAGS[flag]
|
138
|
+
return false if flag.nil?
|
194
139
|
flags & flag == flag
|
195
140
|
end
|
196
141
|
end
|
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.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-07 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
|