Add support for Mach-O universal binaries.

If the detected file is a Mach-O fat file, the arch specified to Ropper
will be selected from the slice of Mach-O images within the fat file. If
no arch is specified, the first slice is used.

Closes sashs/filebytes#9.
This commit is contained in:
Robert Sesek 2019-10-03 10:14:02 -04:00
parent 285a086853
commit f9be1845a1
2 changed files with 10 additions and 2 deletions

@ -1 +1 @@
Subproject commit dafdbe6ab642041bfdedd8d09676944e80e13ce2 Subproject commit f95a315a8c0082dd6249d7d7a2e948653e6e268a

View File

@ -98,7 +98,15 @@ class MachO(Loader):
return {} return {}
def _loadFile(self, fileName, bytes=None): def _loadFile(self, fileName, bytes=None):
return macho.MachO(fileName, bytes) mf = macho.MachO(fileName, bytes)
if mf.isFat:
if not self._arch:
return mf.fatArches[0]
for arch in mf.fatArches:
if ARCH[arch.machHeader.header.cputype] == self._arch:
return arch
return mf
@classmethod @classmethod
def isSupportedFile(cls, fileName, bytes=None): def isSupportedFile(cls, fileName, bytes=None):