ethteck / splat

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

Support .sbss/.sdata and $gp relative data access #126

Open MrSapps opened 2 years ago

MrSapps commented 2 years ago

Most PS1 games have .sbss and .sdata for vars that have sizeof(X) <= -G 4. This also causes access to data in these sections in the same translation unit to use the $gp register.

Currently splat will output:

/* 5360 80014B60 4C00828F */  lw         $v0, 0x4c($gp)

But this need to be use a symbol e.g:

/* 5360 80014B60 4C00828F */  lw         $v0,  %gp_rel(D_deadbeef)

This will need a way to set what the GP value should be in the yaml, by default on PSX it is usually a pointer to the .sdata section. Also the generated linker script should output _gp = .data_start or similar.

For the sections .sbss can be handled the same as .bss (although .sbss tends to actually appear in the binary which I think is covered by another issue). And .sdata is the same as .data but with a different section name.

A final bonus might be a way to tell splat about the -G N size value. If splat knows this value to be 8 for instance then it will know not to output any data bigger than 8 bytes without splitting it.

Tasks:

mkst commented 1 month ago

I feel like the support is good enough that this issue can be closed.. anyone think it should be kept open?