Skip to content

Commit 29f631c

Browse files
author
Seva Alekseyev
committed
For DSYM files, don't load any segments except __DWARF
1 parent ed0bfc5 commit 29f631c

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

filebytes/mach_o.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232
from binascii import hexlify
3333
############# MachO General ######################
3434

35+
class MH(Enum):
36+
OBJECT = 0x1
37+
EXECUTE = 0x2
38+
FVMLIB = 0x3
39+
CORE = 0x4
40+
PRELOAD = 0x5
41+
DYLIB = 0x6
42+
DYLINKER = 0x7
43+
BUNDLE = 0x8
44+
DYLIB_STUB = 0x9
45+
DSYM = 0xa
46+
KEXT_BUNDLE = 0xb
47+
3548
class VM_PROT(Enum):
3649
READ = 0x1
3750
WRITE = 0x2
@@ -519,8 +532,13 @@ def __parseSections(self, data, segment, offset):
519532
else:
520533
offset += sizeof(self._classes.Section)
521534

522-
raw = (c_ubyte * sec.size).from_buffer(data, sec.offset)
523-
sections.append(SectionData(header=sec, name=sec.sectname.decode('ASCII'),bytes=bytearray(raw), raw=raw))
535+
if self.machHeader.header.filetype != MH.DSYM or segment.segname == "__DWARF":
536+
raw = bytearray((c_ubyte * sec.size).from_buffer(data, sec.offset))
537+
bytes = bytearray(raw)
538+
else:
539+
raw = None
540+
bytes = None
541+
sections.append(SectionData(header=sec, name=sec.sectname.decode('ASCII'), bytes=bytes, raw=raw))
524542

525543
return sections
526544

0 commit comments

Comments
 (0)