mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2026-06-13 11:23:07 +00:00
The bss → parent text section remap was happening AFTER the target_relocatable check. Bss sections are not themselves marked relocatable; their parent text sections are. So a HI16/LO16 pair targeting a bss section (e.g. .fragment34_bss) hit target_relocatable=false and the reloc was silently dropped — the lui/addiu emitted as link-time literals. Symptom: producer/consumer asymmetry across fragments. fragment62's func_8432D5B0 writes to D_8140E720 (in fragment34's bss) using emitted literal `S32(0x8141 << 16)` — i.e., the canonical link addr 0x8140E720. fragment34's func_8140C204 reads D_8140E720 via RELOC_HI16(147, 0xE720) against the RUNTIME base. When fragment34 is loaded at a non-canonical runtime address (e.g. 0x80114C10), the writer hits canonical RDRAM[0x40E720] while the reader hits runtime+0xE720 = RDRAM[0x123330] — different locations. Reader sees uninitialized memory (observed value 3, near-NULL deref at 0xD3 in func_8140C204). Two changes: 1. Hoist the bss-remap above the target_relocatable check so the parent's relocatable flag is what gates emit, not the bss section's. 2. When remapping, add (bss_vram - parent_vram) to target_section_offset so it stays relative to the new (parent) base. The reloc's stored target_section_offset is computed relative to the bss section's vram in elf.cpp; the parent text section starts before bss in the link layout, so the offset needs the bss-vs-parent vram delta added (typically equal to the parent text size). Verified: Stadium attract demo now runs without the func_8140C204:0xD3 crash. Reaches frame 2138 cleanly through fragment62 + fragment34 dispatch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| analysis.cpp | ||
| analysis.h | ||
| cgenerator.cpp | ||
| config.cpp | ||
| config.h | ||
| elf.cpp | ||
| main.cpp | ||
| mdebug.cpp | ||
| mdebug.h | ||
| mod_symbols.cpp | ||
| operations.cpp | ||
| recompilation.cpp | ||
| symbol_lists.cpp | ||