The task of "splitting" consists of reconstructing translation units using C/C++ source files using inline assembly. The resulting object files should be relocatable.
To facilitate splitting, we use a set of scripts that auto-generate missing C files based on the global symbol table (symbols.txt).
Problem
The splitting script's outputs is dumb and emits direct data references to absolute addresses. This results in non-relocatable code that will crash when recompiling in a context that differs from the original game.
Examples of violating patterns.
[ ] lis/addi data reference
Wrong:
lis r3, 0x8021;
addi r3, r3, -812;
Correct:
lis r3, _my_symbol@ha;
addi r3, r3, _my_symbol@l;
[x] sdata reference
Wrong:
lwz r3, -0x5e70(r13);
Correct:
lwz r3, _my_smol_symbol;
[x] sdata2 reference
Wrong:
lfs f0, -0x72c4(r2);
Correct:
lfs f0, 1.0f;
Work to be done
Create a script that scans through source files with violating patterns.
Background
The task of "splitting" consists of reconstructing translation units using C/C++ source files using inline assembly. The resulting object files should be relocatable.
To facilitate splitting, we use a set of scripts that auto-generate missing C files based on the global symbol table (symbols.txt).
Problem
The splitting script's outputs is dumb and emits direct data references to absolute addresses. This results in non-relocatable code that will crash when recompiling in a context that differs from the original game.
Examples of violating patterns.
Wrong:
Correct:
Wrong:
Correct:
Wrong:
Correct:
Work to be done
Create a script that scans through source files with violating patterns.
A bunch of regex is likely more than enough.