Skip to content

Restore card globals to extern in hsd_3A94, rematching 4 functions - #3031

Open
Danny-Dasilva wants to merge 3 commits into
doldecomp:masterfrom
Danny-Dasilva:fix-hsd3a94-card-globals
Open

Restore card globals to extern in hsd_3A94, rematching 4 functions#3031
Danny-Dasilva wants to merge 3 commits into
doldecomp:masterfrom
Danny-Dasilva:fix-hsd3a94-card-globals

Conversation

@Danny-Dasilva

@Danny-Dasilva Danny-Dasilva commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

#3029 turned the shared card work-area globals into in-TU definitions, several of them static. MWCC addresses static arrays through anonymous section anchors instead of named symbol relocations, which regressed four functions that were fully matched before the merge. Restoring the declarations to extern (as the pre-merge TU had them) brings them back:

Function Before After
hsd_803AAA48 99.13% 100.00%
fn_803ADE4C 95.44% 100.00%
fn_803B1F78 98.36% 100.00%
fn_803B21E8 95.86% 100.00%

Since defining this data anywhere in hsd_3A94.c re-triggers the anchor addressing, the definitions live in a new data-only TU hsd_4D11.c (same pattern as efdata.c/gmvsdata.c), which links and keeps the DOL verifying. Two data fixes fall out of sizing it correctly:

  • hsd_804D2648 is really 0x828 bytes (a JpegWork per hsd_3B34.c, not just the __jmp_buf it's declared as).
  • hsd_804D79AC..hsd_804D79C8 were declared but never defined; hsd_804D79B0 is a byte scalar whose symbols.txt size was covering an alignment gap.

Both units' data sections now report 100% matched (.bss was 89.08% before this PR):

Unit Section Before After
hsd_4D11 .bss 100%
hsd_4D11 .sbss 100%
hsd_3A94 .sbss 75.86% 100%

Verified with objdiff-cli report changes against the base build: the four functions above and the data split are the only changes.


Reading the report: the diff will show hsd_3A94 .bss 89.08% → 0%. No data was lost — the .bss range moved to hsd_4D11, where it now matches 100% (it never fully matched before). The report just renders "this unit no longer has a .bss section" as 0%. Net effect across both units is about +1 KiB of newly matched data.

The hsd_3AA7 merge (doldecomp#3029 upstream) turned the shared card work-area
globals into in-TU definitions (several static). MWCC then addresses
the static arrays through anonymous section anchors instead of named
symbol relocations, which regressed previously-matched functions.
Declaring them extern (as the pre-merge TU did) restores:

  hsd_803AAA48  99.13 -> 100.00
  fn_803ADE4C   95.44 -> 100.00
  fn_803B1F78   98.36 -> 100.00
  fn_803B21E8   95.86 -> 100.00

No other function changes (verified with objdiff report changes
against the merge-base build).
@decomp-dev

decomp-dev Bot commented Aug 9, 2026

Copy link
Copy Markdown

Report for GALE01 (013091a - 9425610)

📈 Matched code: 85.51% (+0.19%, +7264 bytes)
📈 Matched data: 88.84% (+0.80%, +9637 bytes)
📈 Linked data: 57.73% (+0.79%, +9596 bytes)

✅ 7 new matches
Unit Item Bytes Before After
main/sysdolphin/baselib/hsd_4D11 .bss +9564 0.00% 100.00%
main/sysdolphin/baselib/hsd_3A94 hsd_803AAA48 +52 99.13% 100.00%
main/sysdolphin/baselib/hsd_4D11 .sbss +32 0.00% 100.00%
main/sysdolphin/baselib/hsd_3A94 fn_803B21E8 +17 95.86% 100.00%
main/sysdolphin/baselib/hsd_3A94 fn_803ADE4C +15 95.44% 100.00%
main/sysdolphin/baselib/hsd_3A94 fn_803B1F78 +11 98.36% 100.00%
main/sysdolphin/baselib/hsd_3A94 .sbss -14 75.86% 100.00%
📉 1 regression in an unmatched item
Unit Item Bytes Before After
main/sysdolphin/baselib/hsd_3A94 .bss -8520 89.08% 0.00%

Defining this data inside hsd_3A94.c makes mwcc use anchor-form
addressing there, which is what regressed the card functions in the
first place — so it gets its own data-only TU instead, following the
efdata.c/gmvsdata.c pattern.

Sizing hsd_804D2648 at its real 0x828 bytes (a JpegWork, not just the
__jmp_buf it is declared as by users) brings the unit's data to
9596/9596 matched, above the 89% the in-TU definitions achieved.
hsd_804D79AC..hsd_804D79C8 were declared in hsd_3A94.h but never
defined anywhere. hsd_804D79B0 is a byte scalar (see its uses in
hsd_3B34.c); its symbols.txt size covered the 7-byte alignment gap to
hsd_804D79B8, which no source definition can reproduce. Both unit data
sections now report 100%.
@Danny-Dasilva
Danny-Dasilva marked this pull request as ready for review August 9, 2026 06:05
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.

1 participant