Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline asm linter #159

Open
2 of 3 tasks
riptl opened this issue Mar 27, 2022 · 2 comments
Open
2 of 3 tasks

Inline asm linter #159

riptl opened this issue Mar 27, 2022 · 2 comments
Labels
decompiler Improvements to decompiler tooling good first issue Good for newcomers help wanted Extra attention is needed

Comments

@riptl
Copy link
Collaborator

riptl commented Mar 27, 2022

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.

  • lis/addi data reference

Wrong:

  lis r3, 0x8021;
  addi r3, r3, -812;

Correct:

  lis r3, _my_symbol@ha;
  addi r3, r3, _my_symbol@l;
  • sdata reference

Wrong:

lwz r3, -0x5e70(r13);

Correct:

lwz r3, _my_smol_symbol;
  • 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.

A bunch of regex is likely more than enough.

@riptl riptl added help wanted Extra attention is needed good first issue Good for newcomers decompiler Improvements to decompiler tooling labels Mar 27, 2022
@riidefi
Copy link
Owner

riidefi commented Mar 28, 2022

We'll also need to be careful about unused data generated from coming from stripped functions. OGWS has some examples.

@riptl
Copy link
Collaborator Author

riptl commented Apr 4, 2022

Unused data will be caught by the data symbol differ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decompiler Improvements to decompiler tooling good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants