chaoticgd / ghidra-emotionengine-reloaded

An extension for Ghidra that adds support for the PlayStation 2.
Apache License 2.0
118 stars 11 forks source link

some ELF get function jumps wrong (Rhapsody III JPN) #54

Closed modusc896d352 closed 5 months ago

modusc896d352 commented 5 months ago

hey.

apparently i came across an game executable (SLPS_200.66) weighing at under 2MB (1,67MB to be exact) in which your extension tries to do out-of-bounds function jumps like these SLPS_200.66 (Tenshi no Present - Marl Oukoku Monogatari) opened through GHIDRA 11.0, with ghidra-emotionengine-reloaded installed. GHIDRA has detected 3 function jump errors.

here are the error messages, from the Bookmarks section

Type | Category | Description | Location | Label | Code Unit | Mem Block -- | -- | -- | -- | -- | -- | -- Error | Bad Instruction | Could not follow disassembly flow into non-existing memory at 0020b140 (flow from 00100080) | 00100080 |   | jal SUB_0020b140 | main Error | Bad Instruction | Could not follow disassembly flow into non-existing memory at 0029ade0 (flow from 00100098) | 00100098 |   | jal SUB_0029ade0 | main Error | Bad Instruction | Could not follow disassembly flow into non-existing memory at 0020a480 (flow from 001000a0) | 001000a0 |   | j LAB_0020a480 | main

tbh to get the "correct" function jumps you have to divide out-of-bounds offset values for those jumps by 2, like so 0020b140 / 2 = 001058a0 0029ade0 / 2 = 0014d6f0 0020a480 / 2 = 00105240

but even that feels like a workaround at best, so i'm not sure if there's any way to "fix" this issue entirely without breaking stuff with other PS2 ELFs at this point

chaoticgd commented 5 months ago

Looks like this is a duplicate of #53. For now you can disable relocations during import.

modusc896d352 commented 5 months ago

oh alright disabling relocations then!

here's how the "analyzed" program looks like with "Perform Symbol Relocations" unchecked! A picture speaks a thousand words.