Skip to content

Handle both bugged and unbugged __sinit_ behaviors#39

Merged
mkst merged 1 commit intomkst:mainfrom
tclamb:main
Mar 8, 2026
Merged

Handle both bugged and unbugged __sinit_ behaviors#39
mkst merged 1 commit intomkst:mainfrom
tclamb:main

Conversation

@tclamb
Copy link
Contributor

@tclamb tclamb commented Mar 8, 2026

After making some progress in my decomp project, I found some of these symbols had different lengths of padding. After a bit of poking around in ghidra, I figured out what's actually going on.

The code that generates the static init symbol is similar to this line from the mac decomp:

sprintf(buf, "__sinit_%*.*s", -fname[0], fname[0], &fname[1]);

So fname is a length-prefixed dynamic string, right? But looking at mwccpsp.exe in Ghidra, its code is equivalent to something like:

sprintf(buf, "__sinit_%*.*s", -fname[0], fname[0], fname);

Lo and behold, debugging the process, I see that fname is indeed not length-prefixed. It's padding these symbols based on the first character of the filename.

This change updates mwccgap to work for non-bugged versions, and to reproduce the bug when present.

@mkst mkst merged commit 0d6b545 into mkst:main Mar 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants