ruby-macho 0.1.5 → 0.1.6
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/headers.rb +45 -33
- data/lib/macho/load_commands.rb +53 -53
- data/lib/macho/sections.rb +7 -67
- data/lib/macho/structure.rb +7 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 804e6a31dedb8f86966c6e53366730c1ac87c2c2
|
4
|
+
data.tar.gz: 3a4f11ddc1807e34f158f22f446b561cbc5e9e07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c430de85ed1154fe02a70a0443535fdc5fd3e4a5b3a4d16e857dad770784977d0dfe73f6a75879408877b44ba86c73b4d1755ae782420f2364a1dd4acc3eb0
|
7
|
+
data.tar.gz: d4877cb5eea705217b930175167a7f2330ef255e51cf403d12f13f174b61ad6e91f57bfdf554f379a0a8cb7651093128456a639f77fad874b66fdcb6f788cde1
|
data/lib/macho/headers.rb
CHANGED
@@ -234,30 +234,47 @@ module MachO
|
|
234
234
|
}
|
235
235
|
|
236
236
|
# Fat binary header structure
|
237
|
+
# @see MachO::FatArch
|
237
238
|
class FatHeader < MachOStructure
|
239
|
+
# @return [Fixnum] the magic number of the header (and file)
|
238
240
|
attr_reader :magic
|
239
|
-
attr_reader :nfat_arch # number of FatArchs that follow
|
240
241
|
|
241
|
-
@
|
242
|
-
|
242
|
+
# @return [Fixnum] the number of fat architecture structures following the header
|
243
|
+
attr_reader :nfat_arch
|
243
244
|
|
245
|
+
FORMAT = "VV"
|
246
|
+
SIZEOF = 8
|
247
|
+
|
248
|
+
# @api private
|
244
249
|
def initialize(magic, nfat_arch)
|
245
250
|
@magic = magic
|
246
251
|
@nfat_arch = nfat_arch
|
247
252
|
end
|
248
253
|
end
|
249
254
|
|
250
|
-
# Fat binary header architecture structure
|
255
|
+
# Fat binary header architecture structure. A Fat binary has one or more of
|
256
|
+
# these, representing one or more internal Mach-O blobs.
|
257
|
+
# @see MachO::FatHeader
|
251
258
|
class FatArch < MachOStructure
|
259
|
+
# @return [Fixnum] the CPU type of the Mach-O
|
252
260
|
attr_reader :cputype
|
261
|
+
|
262
|
+
# @return [Fixnum] the CPU subtype of the Mach-O
|
253
263
|
attr_reader :cpusubtype
|
264
|
+
|
265
|
+
# @return [Fixnum] the file offset to the beginning of the Mach-O data
|
254
266
|
attr_reader :offset
|
267
|
+
|
268
|
+
# @return [Fixnum] the size, in bytes, of the Mach-O data
|
255
269
|
attr_reader :size
|
270
|
+
|
271
|
+
# @return [Fixnum] the alignment, as a power of 2
|
256
272
|
attr_reader :align
|
257
273
|
|
258
|
-
|
259
|
-
|
274
|
+
FORMAT = "VVVVV"
|
275
|
+
SIZEOF = 20
|
260
276
|
|
277
|
+
# @api private
|
261
278
|
def initialize(cputype, cpusubtype, offset, size, align)
|
262
279
|
@cputype = cputype
|
263
280
|
@cpusubtype = cpusubtype
|
@@ -269,17 +286,31 @@ module MachO
|
|
269
286
|
|
270
287
|
# 32-bit Mach-O file header structure
|
271
288
|
class MachHeader < MachOStructure
|
289
|
+
# @return [Fixnum] the magic number
|
272
290
|
attr_reader :magic
|
291
|
+
|
292
|
+
# @return [Fixnum] the CPU type of the Mach-O
|
273
293
|
attr_reader :cputype
|
294
|
+
|
295
|
+
# @return [Fixnum] the CPU subtype of the Mach-O
|
274
296
|
attr_reader :cpusubtype
|
297
|
+
|
298
|
+
# @return [Fixnum] the file type of the Mach-O
|
275
299
|
attr_reader :filetype
|
300
|
+
|
301
|
+
# @return [Fixnum] the number of load commands in the Mach-O
|
276
302
|
attr_reader :ncmds
|
303
|
+
|
304
|
+
# @return [Fixnum] the size of all load commands, in bytes, in the Mach-O
|
277
305
|
attr_reader :sizeofcmds
|
306
|
+
|
307
|
+
# @return [Fixnum] the header flags associated with the Mach-O
|
278
308
|
attr_reader :flags
|
279
309
|
|
280
|
-
|
281
|
-
|
310
|
+
FORMAT = "VVVVVVV"
|
311
|
+
SIZEOF = 28
|
282
312
|
|
313
|
+
# @api private
|
283
314
|
def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds,
|
284
315
|
flags)
|
285
316
|
@magic = magic
|
@@ -301,37 +332,18 @@ module MachO
|
|
301
332
|
end
|
302
333
|
|
303
334
|
# 64-bit Mach-O file header structure
|
304
|
-
class MachHeader64 <
|
305
|
-
|
306
|
-
attr_reader :cputype
|
307
|
-
attr_reader :cpusubtype
|
308
|
-
attr_reader :filetype
|
309
|
-
attr_reader :ncmds
|
310
|
-
attr_reader :sizeofcmds
|
311
|
-
attr_reader :flags
|
335
|
+
class MachHeader64 < MachHeader
|
336
|
+
# @return [void]
|
312
337
|
attr_reader :reserved
|
313
338
|
|
314
|
-
|
315
|
-
|
339
|
+
FORMAT = "VVVVVVVV"
|
340
|
+
SIZEOF = 32
|
316
341
|
|
342
|
+
# @api private
|
317
343
|
def initialize(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds,
|
318
344
|
flags, reserved)
|
319
|
-
|
320
|
-
@cputype = cputype
|
321
|
-
@cpusubtype = cpusubtype
|
322
|
-
@filetype = filetype
|
323
|
-
@ncmds = ncmds
|
324
|
-
@sizeofcmds = sizeofcmds
|
325
|
-
@flags = flags
|
345
|
+
super(magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags)
|
326
346
|
@reserved = reserved
|
327
347
|
end
|
328
|
-
|
329
|
-
# @example
|
330
|
-
# puts "this mach-o has position-independent execution" if header.flag?(MH_PIE)
|
331
|
-
# @param flag [Fixnum] a mach header flag constant
|
332
|
-
# @return [Boolean] true if `flag` is present in the header's flag section
|
333
|
-
def flag?(flag)
|
334
|
-
flags & flag == flag
|
335
|
-
end
|
336
348
|
end
|
337
349
|
end
|
data/lib/macho/load_commands.rb
CHANGED
@@ -296,8 +296,8 @@ module MachO
|
|
296
296
|
# @return [Fixnum] the size of the load command, in bytes
|
297
297
|
attr_reader :cmdsize
|
298
298
|
|
299
|
-
|
300
|
-
|
299
|
+
FORMAT = "VV"
|
300
|
+
SIZEOF = 8
|
301
301
|
|
302
302
|
# Creates a new LoadCommand given an offset and binary string
|
303
303
|
# @param offset [Fixnum] the offset to initialize with
|
@@ -305,7 +305,7 @@ module MachO
|
|
305
305
|
# @return [MachO::LoadCommand] the new load command
|
306
306
|
# @api private
|
307
307
|
def self.new_from_bin(raw_data, offset, bin)
|
308
|
-
self.new(raw_data, offset, *bin.unpack(
|
308
|
+
self.new(raw_data, offset, *bin.unpack(self::FORMAT))
|
309
309
|
end
|
310
310
|
|
311
311
|
# @param offset [Fixnum] the offset to initialize with
|
@@ -358,8 +358,8 @@ module MachO
|
|
358
358
|
# @return [Array<Fixnum>] the UUID
|
359
359
|
attr_reader :uuid
|
360
360
|
|
361
|
-
|
362
|
-
|
361
|
+
FORMAT = "VVa16"
|
362
|
+
SIZEOF = 24
|
363
363
|
|
364
364
|
# @api private
|
365
365
|
def initialize(raw_data, offset, cmd, cmdsize, uuid)
|
@@ -409,8 +409,8 @@ module MachO
|
|
409
409
|
# @return [Fixnum] any flags associated with the segment
|
410
410
|
attr_reader :flags
|
411
411
|
|
412
|
-
|
413
|
-
|
412
|
+
FORMAT = "VVa16VVVVVVVV"
|
413
|
+
SIZEOF = 56
|
414
414
|
|
415
415
|
# @api private
|
416
416
|
def initialize(raw_data, offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff,
|
@@ -463,8 +463,8 @@ module MachO
|
|
463
463
|
# @return [Fixnum] any flags associated with the segment
|
464
464
|
attr_reader :flags
|
465
465
|
|
466
|
-
|
467
|
-
|
466
|
+
FORMAT = "VVa16QQQQVVVV"
|
467
|
+
SIZEOF = 72
|
468
468
|
|
469
469
|
# @api private
|
470
470
|
def initialize(raw_data, offset, cmd, cmdsize, segname, vmaddr, vmsize, fileoff,
|
@@ -503,8 +503,8 @@ module MachO
|
|
503
503
|
# @return [Fixnum] the library's compatibility version number
|
504
504
|
attr_reader :compatibility_version
|
505
505
|
|
506
|
-
|
507
|
-
|
506
|
+
FORMAT = "VVVVVV"
|
507
|
+
SIZEOF = 24
|
508
508
|
|
509
509
|
# @api private
|
510
510
|
def initialize(raw_data, offset, cmd, cmdsize, name, timestamp, current_version,
|
@@ -524,8 +524,8 @@ module MachO
|
|
524
524
|
# @return [MachO::LoadCommand::LCStr] the dynamic linker's path name as an LCStr
|
525
525
|
attr_reader :name
|
526
526
|
|
527
|
-
|
528
|
-
|
527
|
+
FORMAT = "VVV"
|
528
|
+
SIZEOF = 12
|
529
529
|
|
530
530
|
# @api private
|
531
531
|
def initialize(raw_data, offset, cmd, cmdsize, name)
|
@@ -546,8 +546,8 @@ module MachO
|
|
546
546
|
# @return [Fixnum] a bit vector of linked modules
|
547
547
|
attr_reader :linked_modules
|
548
548
|
|
549
|
-
|
550
|
-
|
549
|
+
FORMAT = "VVVVV"
|
550
|
+
SIZEOF = 20
|
551
551
|
|
552
552
|
# @api private
|
553
553
|
def initialize(raw_data, offset, cmd, cmdsize, name, nmodules, linked_modules)
|
@@ -592,8 +592,8 @@ module MachO
|
|
592
592
|
# @return [void]
|
593
593
|
attr_reader :reserved6
|
594
594
|
|
595
|
-
|
596
|
-
|
595
|
+
FORMAT = "VVVVVVVVVV"
|
596
|
+
SIZEOF = 40
|
597
597
|
|
598
598
|
# @api private
|
599
599
|
def initialize(raw_data, offset, cmd, cmdsize, init_address, init_module,
|
@@ -639,8 +639,8 @@ module MachO
|
|
639
639
|
# @return [void]
|
640
640
|
attr_reader :reserved6
|
641
641
|
|
642
|
-
|
643
|
-
|
642
|
+
FORMAT = "VVQQQQQQQQ"
|
643
|
+
SIZEOF = 72
|
644
644
|
|
645
645
|
# @api private
|
646
646
|
def initialize(raw_data, offset, cmd, cmdsize, init_address, init_module,
|
@@ -664,8 +664,8 @@ module MachO
|
|
664
664
|
# @return [MachO::LoadCommand::LCStr] the umbrella framework name as an LCStr
|
665
665
|
attr_reader :umbrella
|
666
666
|
|
667
|
-
|
668
|
-
|
667
|
+
FORMAT = "VVV"
|
668
|
+
SIZEOF = 12
|
669
669
|
|
670
670
|
# @api private
|
671
671
|
def initialize(raw_data, offset, cmd, cmdsize, umbrella)
|
@@ -680,8 +680,8 @@ module MachO
|
|
680
680
|
# @return [MachO::LoadCommand::LCStr] the subumbrella framework name as an LCStr
|
681
681
|
attr_reader :sub_umbrella
|
682
682
|
|
683
|
-
|
684
|
-
|
683
|
+
FORMAT = "VVV"
|
684
|
+
SIZEOF = 12
|
685
685
|
|
686
686
|
# @api private
|
687
687
|
def initialize(raw_data, offset, cmd, cmdsize, sub_umbrella)
|
@@ -696,8 +696,8 @@ module MachO
|
|
696
696
|
# @return [MachO::LoadCommand::LCStr] the sublibrary name as an LCStr
|
697
697
|
attr_reader :sub_library
|
698
698
|
|
699
|
-
|
700
|
-
|
699
|
+
FORMAT = "VVV"
|
700
|
+
SIZEOF = 12
|
701
701
|
|
702
702
|
# @api private
|
703
703
|
def initialize(raw_data, offset, cmd, cmdsize, sub_library)
|
@@ -712,8 +712,8 @@ module MachO
|
|
712
712
|
# @return [MachO::LoadCommand::LCStr] the subclient name as an LCStr
|
713
713
|
attr_reader :sub_client
|
714
714
|
|
715
|
-
|
716
|
-
|
715
|
+
FORMAT = "VVV"
|
716
|
+
SIZEOF = 12
|
717
717
|
|
718
718
|
# @api private
|
719
719
|
def initialize(raw_data, offset, cmd, cmdsize, sub_client)
|
@@ -737,8 +737,8 @@ module MachO
|
|
737
737
|
# @return the string table size in bytes
|
738
738
|
attr_reader :strsize
|
739
739
|
|
740
|
-
|
741
|
-
|
740
|
+
FORMAT = "VVVVVV"
|
741
|
+
SIZEOF = 24
|
742
742
|
|
743
743
|
# @api private
|
744
744
|
def initialize(raw_data, offset, cmd, cmdsize, symoff, nsyms, stroff, strsize)
|
@@ -808,8 +808,8 @@ module MachO
|
|
808
808
|
attr_reader :nlocrel
|
809
809
|
|
810
810
|
|
811
|
-
|
812
|
-
|
811
|
+
FORMAT = "VVVVVVVVVVVVVVVVVVVV"
|
812
|
+
SIZEOF = 80
|
813
813
|
|
814
814
|
# ugh
|
815
815
|
# @api private
|
@@ -848,8 +848,8 @@ module MachO
|
|
848
848
|
# @return [Fixnum] the number of hints in the hint table
|
849
849
|
attr_reader :nhints
|
850
850
|
|
851
|
-
|
852
|
-
|
851
|
+
FORMAT = "VVVV"
|
852
|
+
SIZEOF = 16
|
853
853
|
|
854
854
|
# @api private
|
855
855
|
def initialize(raw_data, offset, cmd, cmdsize, htoffset, nhints)
|
@@ -865,8 +865,8 @@ module MachO
|
|
865
865
|
# @return [Fixnum] the checksum or 0
|
866
866
|
attr_reader :cksum
|
867
867
|
|
868
|
-
|
869
|
-
|
868
|
+
FORMAT = "VVV"
|
869
|
+
SIZEOF = 12
|
870
870
|
|
871
871
|
# @api private
|
872
872
|
def initialize(raw_data, offset, cmd, cmdsize, cksum)
|
@@ -882,8 +882,8 @@ module MachO
|
|
882
882
|
# @return [MachO::LoadCommand::LCStr] the path to add to the run path as an LCStr
|
883
883
|
attr_reader :path
|
884
884
|
|
885
|
-
|
886
|
-
|
885
|
+
FORMAT = "VVV"
|
886
|
+
SIZEOF = 12
|
887
887
|
|
888
888
|
# @api private
|
889
889
|
def initialize(raw_data, offset, cmd, cmdsize, path)
|
@@ -902,8 +902,8 @@ module MachO
|
|
902
902
|
# @return [Fixnum] size of the data in the __LINKEDIT segment
|
903
903
|
attr_reader :datasize
|
904
904
|
|
905
|
-
|
906
|
-
|
905
|
+
FORMAT = "VVVV"
|
906
|
+
SIZEOF = 16
|
907
907
|
|
908
908
|
# @api private
|
909
909
|
def initialize(raw_data, offset, cmd, cmdsize, dataoff, datasize)
|
@@ -925,8 +925,8 @@ module MachO
|
|
925
925
|
# @return [Fixnum] the encryption system, or 0 if not encrypted yet
|
926
926
|
attr_reader :cryptid
|
927
927
|
|
928
|
-
|
929
|
-
|
928
|
+
FORMAT = "VVVVV"
|
929
|
+
SIZEOF = 20
|
930
930
|
|
931
931
|
# @api private
|
932
932
|
def initialize(raw_data, offset, cmd, cmdsize, cryptoff, cryptsize, cryptid)
|
@@ -952,8 +952,8 @@ module MachO
|
|
952
952
|
# @return [Fixnum] 64-bit padding value
|
953
953
|
attr_reader :pad
|
954
954
|
|
955
|
-
|
956
|
-
|
955
|
+
FORMAT = "VVVVVV"
|
956
|
+
SIZEOF = 24
|
957
957
|
|
958
958
|
# @api private
|
959
959
|
def initialize(raw_data, offset, cmd, cmdsize, cryptoff, cryptsize, cryptid)
|
@@ -974,8 +974,8 @@ module MachO
|
|
974
974
|
# @return [Fixnum] the SDK version X.Y.Z packed as x16.y8.z8
|
975
975
|
attr_reader :sdk
|
976
976
|
|
977
|
-
|
978
|
-
|
977
|
+
FORMAT = "VVVV"
|
978
|
+
SIZEOF = 16
|
979
979
|
|
980
980
|
# @api private
|
981
981
|
def initialize(raw_data, offset, cmd, cmdsize, version, sdk)
|
@@ -1041,8 +1041,8 @@ module MachO
|
|
1041
1041
|
# @return [Fixnum] the size of the export information
|
1042
1042
|
attr_reader :export_size
|
1043
1043
|
|
1044
|
-
|
1045
|
-
|
1044
|
+
FORMAT = "VVVVVVVVVVVV"
|
1045
|
+
SIZEOF = 48
|
1046
1046
|
|
1047
1047
|
# @api private
|
1048
1048
|
def initialize(raw_data, offset, cmd, cmdsize, rebase_off, rebase_size, bind_off,
|
@@ -1068,8 +1068,8 @@ module MachO
|
|
1068
1068
|
# @return [Fixnum] the number of strings
|
1069
1069
|
attr_reader :count
|
1070
1070
|
|
1071
|
-
|
1072
|
-
|
1071
|
+
FORMAT = "VVV"
|
1072
|
+
SIZEOF = 12
|
1073
1073
|
|
1074
1074
|
# @api private
|
1075
1075
|
def initialize(raw_data, offset, cmd, cmdsize, count)
|
@@ -1086,8 +1086,8 @@ module MachO
|
|
1086
1086
|
# @return [Fixnum] if not 0, the initial stack size.
|
1087
1087
|
attr_reader :stacksize
|
1088
1088
|
|
1089
|
-
|
1090
|
-
|
1089
|
+
FORMAT = "VVQQ"
|
1090
|
+
SIZEOF = 24
|
1091
1091
|
|
1092
1092
|
# @api private
|
1093
1093
|
def initialize(raw_data, offset, cmd, cmdsize, entryoff, stacksize)
|
@@ -1103,8 +1103,8 @@ module MachO
|
|
1103
1103
|
# @return [Fixnum] the version packed as a24.b10.c10.d10.e10
|
1104
1104
|
attr_reader :version
|
1105
1105
|
|
1106
|
-
|
1107
|
-
|
1106
|
+
FORMAT = "VVQ"
|
1107
|
+
SIZEOF = 16
|
1108
1108
|
|
1109
1109
|
# @api private
|
1110
1110
|
def initialize(raw_data, offset, cmd, cmdsize, version)
|
data/lib/macho/sections.rb
CHANGED
@@ -91,8 +91,8 @@ module MachO
|
|
91
91
|
# @return [void] reserved (for count or sizeof)
|
92
92
|
attr_reader :reserved2
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
FORMAT = "a16a16VVVVVVVVV"
|
95
|
+
SIZEOF = 68
|
96
96
|
|
97
97
|
# @api private
|
98
98
|
def initialize(sectname, segname, addr, size, offset, align, reloff,
|
@@ -130,79 +130,19 @@ module MachO
|
|
130
130
|
end
|
131
131
|
|
132
132
|
# Represents a section of a segment for 64-bit architectures.
|
133
|
-
class Section64 <
|
134
|
-
# @return [String] the name of the section, including null pad bytes
|
135
|
-
attr_reader :sectname
|
136
|
-
|
137
|
-
# @return [String] the name of the segment's section, including null pad bytes
|
138
|
-
attr_reader :segname
|
139
|
-
|
140
|
-
# @return [Fixnum] the memory address of the section
|
141
|
-
attr_reader :addr
|
142
|
-
|
143
|
-
# @return [Fixnum] the size, in bytes, of the section
|
144
|
-
attr_reader :size
|
145
|
-
|
146
|
-
# @return [Fixnum] the file offset of the section
|
147
|
-
attr_reader :offset
|
148
|
-
|
149
|
-
# @return [Fixnum] the section alignment (power of 2) of the section
|
150
|
-
attr_reader :align
|
151
|
-
|
152
|
-
# @return [Fixnum] the file offset of the section's relocation entries
|
153
|
-
attr_reader :reloff
|
154
|
-
|
155
|
-
# @return [Fixnum] the number of relocation entries
|
156
|
-
attr_reader :nreloc
|
157
|
-
|
158
|
-
# @return [Fixnum] flags for type and addrributes of the section
|
159
|
-
attr_reader :flags
|
160
|
-
|
161
|
-
# @return [void] reserved (for offset or index)
|
162
|
-
attr_reader :reserved1
|
163
|
-
|
164
|
-
# @return [void] reserved (for count or sizeof)
|
165
|
-
attr_reader :reserved2
|
166
|
-
|
133
|
+
class Section64 < Section
|
167
134
|
# @return [void] reserved
|
168
135
|
attr_reader :reserved3
|
169
136
|
|
170
|
-
|
171
|
-
|
137
|
+
FORMAT = "a16a16QQVVVVVVVV"
|
138
|
+
SIZEOF = 80
|
172
139
|
|
173
140
|
# @api private
|
174
141
|
def initialize(sectname, segname, addr, size, offset, align, reloff,
|
175
142
|
nreloc, flags, reserved1, reserved2, reserved3)
|
176
|
-
|
177
|
-
|
178
|
-
@addr = addr
|
179
|
-
@size = size
|
180
|
-
@offset = offset
|
181
|
-
@align = align
|
182
|
-
@reloff = reloff
|
183
|
-
@nreloc = nreloc
|
184
|
-
@flags = flags
|
185
|
-
@reserved1 = reserved1
|
186
|
-
@reserved2 = reserved2
|
143
|
+
super(sectname, segname, addr, size, offset, align, reloff,
|
144
|
+
nreloc, flags, reserved1, reserved2)
|
187
145
|
@reserved3 = reserved3
|
188
146
|
end
|
189
|
-
|
190
|
-
# @return [String] the section's name, with any trailing NULL characters removed
|
191
|
-
def section_name
|
192
|
-
@sectname.delete("\x00")
|
193
|
-
end
|
194
|
-
|
195
|
-
# @return [String] the parent segment's name, with any trailing NULL characters removed
|
196
|
-
def segment_name
|
197
|
-
@segname.delete("\x00")
|
198
|
-
end
|
199
|
-
|
200
|
-
# @example
|
201
|
-
# puts "this section is regular" if sect.flag?(S_REGULAR)
|
202
|
-
# @param flag [Fixnum] a section flag constant
|
203
|
-
# @return [Boolean] true if `flag` is present in the sections's flag field
|
204
|
-
def flag?(flag)
|
205
|
-
flags & flag == flag
|
206
|
-
end
|
207
147
|
end
|
208
148
|
end
|
data/lib/macho/structure.rb
CHANGED
@@ -2,19 +2,21 @@ module MachO
|
|
2
2
|
# A general purpose pseudo-structure.
|
3
3
|
# @abstract
|
4
4
|
class MachOStructure
|
5
|
-
#
|
6
|
-
|
7
|
-
|
5
|
+
# The format of the data structure, in String#unpack format.
|
6
|
+
FORMAT = ""
|
7
|
+
|
8
|
+
# The size of the data structure, in bytes.
|
9
|
+
SIZEOF = 0
|
8
10
|
|
9
11
|
# @return [Fixnum] the size, in bytes, of the represented structure.
|
10
12
|
def self.bytesize
|
11
|
-
|
13
|
+
self::SIZEOF
|
12
14
|
end
|
13
15
|
|
14
16
|
# @return [MachO::MachOStructure] a new MachOStructure initialized with `bin`
|
15
17
|
# @api private
|
16
18
|
def self.new_from_bin(bin)
|
17
|
-
self.new(*bin.unpack(
|
19
|
+
self.new(*bin.unpack(self::FORMAT))
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|