diff --git a/librw_x64/loader.py b/librw_x64/loader.py index 55f0b712..238875d8 100644 --- a/librw_x64/loader.py +++ b/librw_x64/loader.py @@ -57,30 +57,31 @@ def load_functions(self, fnlist): self.container.add_function(function) section = self.elffile.get_section_by_name(".init_array") - data = section.data() - # section = self.elffile.get_section_by_name(".fini_array") - # data += section.data() - for e,i in enumerate(range(0, len(data), 8)): - address = data[i:i+8] - addr_int = struct.unpack(" addr_int: - min_next_func = min(min_next_func, func) - if min_next_func != 0xffffffffffffffff: - sz = min_next_func - addr_int - func_bytes = text_data[addr_int - text_base:addr_int - text_base + sz] - if e == 0: - # skip first initial array and just do ret (problems with _ITM_registerTMClone... begin unlinkable) - self.container.add_function(Function(f"entry_{hex(addr_int)}", addr_int, sz, b"\xc3")) - else: - self.container.add_function(Function(f"entry_{hex(addr_int)}", addr_int, sz, func_bytes)) + if hasattr(section, "data"): + data = section.data() + # section = self.elffile.get_section_by_name(".fini_array") + # data += section.data() + for e,i in enumerate(range(0, len(data), 8)): + address = data[i:i+8] + addr_int = struct.unpack(" addr_int: + min_next_func = min(min_next_func, func) + if min_next_func != 0xffffffffffffffff: + sz = min_next_func - addr_int + func_bytes = text_data[addr_int - text_base:addr_int - text_base + sz] + if e == 0: + # skip first initial array and just do ret (problems with _ITM_registerTMClone... begin unlinkable) + self.container.add_function(Function(f"entry_{hex(addr_int)}", addr_int, sz, b"\xc3")) + else: + self.container.add_function(Function(f"entry_{hex(addr_int)}", addr_int, sz, func_bytes)) # fill gaps # functions = list(sorted(self.container.functions.items()))