Add orig thunk when recomp is not thunked

This commit is contained in:
disinvite 2024-04-18 17:39:19 -04:00
parent b2a0638f93
commit f8b870d79b
2 changed files with 21 additions and 0 deletions

View File

@ -324,6 +324,7 @@ def _match_thunks(self):
# Check whether the thunk destination is a matched symbol # Check whether the thunk destination is a matched symbol
recomp_thunk = recomp_thunks.get(orig_func.recomp_addr) recomp_thunk = recomp_thunks.get(orig_func.recomp_addr)
if recomp_thunk is None: if recomp_thunk is None:
self._db.create_orig_thunk(orig_thunk, orig_func.name)
continue continue
self._db.set_function_pair(orig_thunk, recomp_thunk) self._db.set_function_pair(orig_thunk, recomp_thunk)

View File

@ -221,6 +221,26 @@ def set_function_pair(self, orig: int, recomp: int) -> bool:
"""For lineref match or _entry""" """For lineref match or _entry"""
return self.set_pair(orig, recomp, SymbolType.FUNCTION) 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: def create_recomp_thunk(self, addr: int, name: str) -> bool:
"""Create a thunk function reference using the recomp address. """Create a thunk function reference using the recomp address.
We start from the recomp side for this because we are guaranteed We start from the recomp side for this because we are guaranteed