ethteck / splat

A binary splitting tool to assist with decompilation and modding projects
MIT License
159 stars 42 forks source link

Failed to symbolize address <addr> for %gp_rel #410

Open apstygo opened 21 hours ago

apstygo commented 21 hours ago

Hello!

I am trying to decompile a PS2 binary and I'm getting a lot of errors in the assembly files similar to this one:

/* E2668 001E25E8 E0018393 */  lbu        $v1, 0x1E0($gp) /* Failed to symbolize address 0x000001E0 for %gp_rel. Make sure this address is within the recognized valid address space */

What am I supposed to do about this error? How do I tell splat what the valid address space is? I know the heap and stack sizes at runtime but there seems to be no way of configuring them in splat.

AngheloAlf commented 17 hours ago

This issue means the disassembler tried to symbolize the address 0x000001E0 but that address isn't valid according to your yaml.

The address space of PS2 games usually start around 0x00100000, which is way bigger than 0x000001E0.

Did you specify a gp_value in your yaml? If you didn't, then try to look anywhere in code where the assembly is setting the value for the $gp register. Look for patterns that have that register as the destination: Pattern one:

lui         $gp, %hi(D_XXXXYYYY)
// There may be extra instructions in the middle
addiu       $gp, $gp, %lo(D_XXXXYYYY)

Pattern two:

lui         $a0, %hi(D_XXXXYYYY)
addiu       $a0, $a0, %lo(D_XXXXYYYY)
daddu       $gp, $a0, $zero

etc. You are looking for instructions that have the $gp register as the leftmost register (usually the dst register).

Once you have found this value, you have to specify it on your yaml and run splat again:

options:
  # Other options...
  gp_value: 0xXXXXYYYY

If this doesn't fix the issue then please post your yaml and/or a link to a repo so we can try debug this issue.