diff --git a/tools/isledecomp/isledecomp/compare/core.py b/tools/isledecomp/isledecomp/compare/core.py index 9db1bbcc..ce145dae 100644 --- a/tools/isledecomp/isledecomp/compare/core.py +++ b/tools/isledecomp/isledecomp/compare/core.py @@ -324,6 +324,7 @@ def _match_thunks(self): # Check whether the thunk destination is a matched symbol recomp_thunk = recomp_thunks.get(orig_func.recomp_addr) if recomp_thunk is None: + self._db.create_orig_thunk(orig_thunk, orig_func.name) continue self._db.set_function_pair(orig_thunk, recomp_thunk) diff --git a/tools/isledecomp/isledecomp/compare/db.py b/tools/isledecomp/isledecomp/compare/db.py index 05ba4e02..e912c8af 100644 --- a/tools/isledecomp/isledecomp/compare/db.py +++ b/tools/isledecomp/isledecomp/compare/db.py @@ -221,6 +221,26 @@ def set_function_pair(self, orig: int, recomp: int) -> bool: """For lineref match or _entry""" return self.set_pair(orig, recomp, SymbolType.FUNCTION) + def create_orig_thunk(self, addr: int, name: str) -> bool: + """Create a thunk function reference using the orig address. + We are here because we have a match on the thunked function, + but it is not thunked in the recomp build.""" + + if self._orig_used(addr): + return False + + thunk_name = f"Thunk of '{name}'" + + # Assuming relative jump instruction for thunks (5 bytes) + cur = self._db.execute( + """INSERT INTO `symbols` + (orig_addr, compare_type, name, size) + VALUES (?,?,?,?)""", + (addr, SymbolType.FUNCTION.value, thunk_name, 5), + ) + + return cur.rowcount > 0 + def create_recomp_thunk(self, addr: int, name: str) -> bool: """Create a thunk function reference using the recomp address. We start from the recomp side for this because we are guaranteed