N64Recomp/src
Matthew Stanley bc00a039f7 recompilation: remap SectionAbsolute relocs to relocatable sections
When splat marks a fragment-internal symbol as undefined (e.g.
'D_8140DD78 = 0x8140DD78;' in undefined_syms_auto.ld), the elf parser
records target_section = SectionAbsolute and target_section_offset =
the symbol's literal vram. Previously the recompilation walker treated
this as a non-relocatable reference and emitted the link-time literal
as a lui+addiu pair. At runtime the containing fragment loads at a
non-canonical address, so the access misses by the relocation delta
and lands in unwritten memory.

Same pattern as the prior bss-remap (28de57f) and unsorted-relocs
(506b9fc) fixes: producer/consumer asymmetry where some references
get RELOC and others bake in the link-time literal.

Fix: after the bss → parent remap, walk the registered relocatable
sections; if the absolute value falls inside one, redirect
reloc_section to that section index and use bss_remap_offset_adjustment
to subtract the new section's vram base. Downstream target_relocatable
check then treats it correctly and emits RELOC_HI16/LO16.

Verified on PokemonStadiumRecomp: the attract-path G_DL target
0x8140DD78 (a Gfx array in fragment34, used by fragment62) now emits
as RELOC_HI16(147, 0xDD78) instead of literal 0x8141<<16. Stadium
attract advances past the prior send_dl=1157 freeze; environment
renders.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 21:17:58 -07:00
..
analysis.cpp PIC Jump Table Support (#120) 2025-01-16 00:40:50 -05:00
analysis.h Implement live recompiler (#114) 2024-12-31 16:11:40 -05:00
cgenerator.cpp Mod function hooking (#124) 2025-01-26 21:52:46 -05:00
config.cpp Implement mdebug parsing for static symbols in IDO elfs (#155) 2025-09-06 18:44:18 -04:00
config.h Implement mdebug parsing for static symbols in IDO elfs (#155) 2025-09-06 18:44:18 -04:00
elf.cpp Fix empty bss section name mapping (#167) 2025-12-11 10:53:10 -05:00
main.cpp Fix out of bounds access when searching for statics at the end of a section (#171) 2026-01-16 20:54:43 -05:00
mdebug.cpp Implement mdebug parsing for static symbols in IDO elfs (#155) 2025-09-06 18:44:18 -04:00
mdebug.h Implement mdebug parsing for static symbols in IDO elfs (#155) 2025-09-06 18:44:18 -04:00
mod_symbols.cpp Add mod merger tool (#168) 2025-12-31 22:17:44 -05:00
operations.cpp Implement remaining float comparisons in the op table (ordered/unordered and signaling/non-signaling still unimplemented) (#144) 2025-07-17 22:50:15 -04:00
recompilation.cpp recompilation: remap SectionAbsolute relocs to relocatable sections 2026-05-05 21:17:58 -07:00
symbol_lists.cpp Add open and close to renamed function list 2025-12-03 01:41:55 -05:00