import struct from fileformat import * CPU_TYPE_X86 = 7 CPU_SUBTYPE_LITTLE_ENDIAN = 0 MH_EXECUTE = 2 MH_DYLIB = 6 class MachO(FileFormat): capabilities = (FILEFORMAT_WRITE, ) def write(self, fp): """ Write file to given file pointer @param fp: File pointer to output file @type fp: C{file} """ cputype = CPU_TYPE_X86 cpusubtype = CPU_SUBTYPE_LITTLE_ENDIAN if self.is_shared: filetype = MH_DYLIB else: filetype = MH_EXECUTE flags = 0x20000 ncmds = len(self.sections) cmds = self.commands() sizeofcmds = len(cmds) reserved = 0 fp.write(struct.pack('