32,37d31 < def byte_check(fmt, ei_data): < if ei_data == 2: < fmt = ">" +fmt < return fmt < < 72,76d65 < < self.ei_data = 0 < self.ei_class = 0 < < 83c72 < bytes = self.check_get_initstr(initstr) --- > bytes = initstr 86,88d74 < # the initial check above should put us in the right state to parse < if len(bytes) == 0: < return 90,99c76,80 < self.ei_class = ord(bytes[4]) < self.ei_data = ord(bytes[5]) < < #if the data is MSB format, need to switch up < # how we read everything.. < # if the fmt is meant to be in MSB, then re-read < # the bytes < self.fmt = byte_check(self.fmt, self.ei_data) < < if len(bytes) > 0: --- > if len(initstr) > 0: > if os.path.exists(initstr): > bytes = file(initstr, "rb").read() > self.myname = initstr > 148,160d128 < < def check_get_initstr(self, initstr): < if len(initstr) == 0: < return initstr < printable_chars = set([chr(i) for i in xrange(32,127)]) < for i in initstr: < if not i in printable_chars: < return initstr < if os.path.exists(initstr): < bytes = file(initstr, "rb").read() < self.myname = initstr < return bytes < return initstr 248c216 < if self.ei_class == 1 and self.e_machine in e_machine_32: --- > if self.e_machine in e_machine_32: 250c218 < elif sself.ei_class == 2 and elf.e_machine in e_machine_64: --- > elif self.e_machine in e_machine_64: 469c437 < reloc = Elf32Reloc(bytes, self.ei_data) --- > reloc = Elf32Reloc(bytes) 471c439 < reloc = Elf64Reloc(bytes, self.ei_data) --- > reloc = Elf64Reloc(bytes) 485c453 < reloc = Elf32Reloca(bytes, self.ei_data) --- > reloc = Elf32Reloca(bytes) 508c476 < newsym = Elf32Symbol(symtab, self.ei_data) --- > newsym = Elf32Symbol(symtab) 510c478 < newsym = Elf64Symbol(symtab, self.ei_data) --- > newsym = Elf64Symbol(symtab) 521c489 < dyn = Elf32Dynamic(dynbytes, self.ei_data) --- > dyn = Elf32Dynamic(dynbytes) 523c491 < dyn = Elf64Dynamic(dynbytes, self.ei_data) --- > dyn = Elf64Dynamic(dynbytes) 552c520 < def __init__(self, bytes=None, data_class=1): --- > def __init__(self, bytes=None): 556d523 < self.ei_data = data_class 567,568c534 < fmt = byte_check("2L",self.ei_data) < self.d_tag,self.d_value = struct.unpack(fmt, bytes[:len(self)]) --- > self.d_tag,self.d_value = struct.unpack("2L", bytes[:len(self)]) 593c559 < def __init__(self, bytes=None, ei_data=1): --- > def __init__(self, bytes=None): 597d562 < self.ei_data = ei_data 605,606c570 < fmt = byte_check("2L", self.ei_data) < (self.r_offset, self.r_info) = struct.unpack(fmt,bytes[:len(self)]) --- > (self.r_offset, self.r_info) = struct.unpack("2L",bytes[:len(self)]) 627c591 < def __init__(self, bytes=None, ei_data = 1): --- > def __init__(self, bytes=None): 629c593 < Elf32Reloc.__init__(self, bytes, ei_data) --- > Elf32Reloc.__init__(self, bytes) 632,633c596 < fmt = byte_check("3L", self.ei_data) < (self.r_offset, self.r_info, self.r_addend) = struct.unpack(fmt, bytes[:len(self)]) --- > (self.r_offset, self.r_info, self.r_addend) = struct.unpack("3L", bytes[:len(self)]) 653c616 < def __init__(self, bytes=None, ei_data=1): --- > def __init__(self, bytes=None): 661c624 < self.ei_data = ei_data --- > 677d639 < fmt = byte_check("3L2BH", self.ei_data) 686,687c648 < fmt = byte_check("3L2BH", self.ei_data) < return struct.pack(fmt, --- > return struct.pack("3L2BH", 710c671 < fmt = byte_check("IBBHLL", self.ei_data) --- > fmt = "IBBHLL" 720,721c681 < fmt = byte_check("IBBHLL", self.ei_data) < return struct.pack(fmt, --- > return struct.pack("IBBHLL", 747,749c707 < self.ei_data = 1 < if not elf is None: < self.ei_data = elf.ei_data --- > 767d724 < fmt = byte_check("8L", self.ei_data) 777c734 < ) = struct.unpack(fmt,bytes[:32]) --- > ) = struct.unpack("8L",bytes[:32]) 780d736 < fmt = byte_check("8L", self.ei_data) 798c754 < fmt = byte_check("2I6L", self.ei_data) --- > fmt = "2I6L" 811c767 < fmt = byte_check("2I6L", self.ei_data) --- > fmt = "2I6L" 858,860d813 < self.ei_data = 1 < if not elf is None: < self.ei_data = elf.ei_data 889d841 < fmt = byte_check("10L", self.ei_data) 901c853 < ) = struct.unpack(fmt, bytes[:40]) --- > ) = struct.unpack("10L", bytes[:40]) 907,908c859 < fmt = byte_check("10L", self.ei_data) < hdr = struct.pack(fmt, --- > hdr = struct.pack("10L", 965c916,917 < fmt = byte_check("2I4L2I2L", self.ei_data) --- > > fmt = "2I4L2I2L" 983c935 < fmt = byte_check("2I4L2I2L", self.ei_data) --- > fmt = "2I4L2I2L"