Add more AI matches

This commit is contained in:
Léo Lam 2020-12-31 14:42:33 +01:00
parent 028ad38b41
commit 3dd4331fc9
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
3 changed files with 1838 additions and 1826 deletions

File diff suppressed because it is too large Load Diff

View File

@ -65,9 +65,16 @@ def main() -> None:
if functions_by_addr[vtable1[0]].status == utils.FunctionStatus.Matching:
continue
name = decomp_addr_to_symbol[vtable2[0]]
decomp_derive_fn_addr = vtable2[0]
if decomp_derive_fn_addr == 0:
decomp_derive_fn_addr = decomp_glob_data_table.get(ptr2 + 0x10, 0)
if decomp_derive_fn_addr == 0:
raise RuntimeError(f"Derive virtual function pointer is null "
f"(fn: {fn.decomp_name}, decomp vtable at {ptr2:#x})")
name = decomp_addr_to_symbol[decomp_derive_fn_addr]
new_matches[vtable1[0]] = name
utils.print_note(f"new match: {Fore.BLUE}{cxxfilt.demangle(name)}{Fore.RESET}")
utils.print_note(f"new match: {Fore.BLUE}{cxxfilt.demangle(name)}{Fore.RESET} (from {fn.decomp_name})")
# overwrite the original names because they are likely to be incorrect
utils.add_decompiled_functions(new_matches, new_orig_names=new_matches)

View File

@ -128,6 +128,7 @@ def get_fn_from_my_elf(name: str) -> Function:
R_AARCH64_GLOB_DAT = 1025
R_AARCH64_RELATIVE = 1027
def build_glob_data_table(elf: ELFFile) -> Dict[int, int]:
@ -142,7 +143,11 @@ def build_glob_data_table(elf: ELFFile) -> Dict[int, int]:
for reloc in section.iter_relocations():
symtab.stream.seek(offset + reloc["r_info_sym"] * entsize)
sym_value = _ElfSym.parse(symtab.stream.read(_ElfSymFormat.size)).st_value
if reloc["r_info_type"] == R_AARCH64_GLOB_DAT:
info_type = reloc["r_info_type"]
if info_type == R_AARCH64_GLOB_DAT:
table[reloc["r_offset"]] = sym_value + reloc["r_addend"]
elif info_type == R_AARCH64_RELATIVE:
# FIXME: this should be Delta(S) + A
table[reloc["r_offset"]] = sym_value + reloc["r_addend"]
return table