Skip to content

Commit

Permalink
Set thunks for functions within the same binary as well
Browse files Browse the repository at this point in the history
  • Loading branch information
TSRBerry committed Nov 1, 2024
1 parent c053579 commit a3ba3f2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/adubbz/nx/loader/common/NXProgramBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ else if (reloc.r_type == R_FAKE_RELR) {
if (extLoc != null) {
func.setThunkedFunction(extLoc.getFunction());
}
else {
// The function could still be in the same binary
// TODO: Ideally we should just calculate the destination address and use that instead of searching for the function name.
List<Symbol> symbols = program.getSymbolTable().getLabelOrFunctionSymbols(name, null).stream().filter(symbol -> addr != symbol.getAddress()).toList();
if (symbols.isEmpty()) {
continue;
}
if (symbols.size() > 1) {
Msg.error(this, String.format("Couldn't identify thunked function for: %s (%s)", name, addr));
continue;
}
func.setThunkedFunction(program.getFunctionManager().getFunctionAt(symbols.getFirst().getAddress()));
}
}
}
}
Expand Down

0 comments on commit a3ba3f2

Please sign in to comment.