Skip to content

Conversation

@freeqaz
Copy link

@freeqaz freeqaz commented Jan 24, 2026

Summary

Fixes two bugs that caused "Failed to write" errors during dtk xex split:

Before (13 failures)

Failed to write build/373307D9/asm/system/char/CharClip.s!
Failed to write build/373307D9/asm/system/synth/StandardStream.s!
Failed to write build/373307D9/asm/system/ui/PanelDir.s!
Failed to write build/373307D9/asm/lazer/meta_ham/LoadingPanel.s!
Failed to write build/373307D9/asm/xdk/nuiapi/nuiimagecameraproperties.s!
Failed to write build/373307D9/asm/xdk/nuiapi/neuralnet.s!
Failed to write build/373307D9/asm/xdk/nuiaudio/qwidoassl.s!
Failed to write build/373307D9/asm/xdk/ST/modelfittingstage.s!
Failed to write build/373307D9/asm/xdk/xaudio2/msaudiodec.s!
Failed to write build/373307D9/asm/xdk/xaudio2/entropydec.s!
Failed to write build/373307D9/asm/xdk/xaudio2/entropydecpro.s!
Failed to write build/373307D9/asm/lib/binkxenon/expand.s!
Failed to write build/373307D9/asm/lib/binkxenon/win32_rrthreads.s!
INFO Done!

After (0 failures)

INFO Done!

Total ASM files generated: 2223

Previously failing files now working:
  ✓ CharClip.s (16875 lines)
  ✓ StandardStream.s (8247 lines)
  ✓ PanelDir.s (8846 lines)
  ✓ LoadingPanel.s (2306 lines)
  ✓ nuiimagecameraproperties.s (2415 lines)
  ✓ neuralnet.s (2065 lines)
  ✓ qwidoassl.s (1594 lines)
  ✓ modelfittingstage.s (17060 lines)
  ✓ msaudiodec.s (13079 lines)
  ✓ entropydec.s (1816 lines)
  ✓ entropydecpro.s (2430 lines)
  ✓ expand.s (4491 lines)
  ✓ win32_rrthreads.s (943 lines)

Bug #1: Relocation Address Alignment

Problem: ObjRelocations::new() and insert() forced 4-byte alignment via address & !3. When splits start at unaligned addresses (e.g., 0x82F0ABD3), relocations at relative offset 1 were corrupted to offset 0, causing "Unaligned symbol entry" errors.

Fix: Remove forced alignment. The to_elf() method already handles alignment appropriately per relocation type (using R_PPC_UADDR32 for unaligned Absolute relocations).

Files fixed: CharClip.s, StandardStream.s, PanelDir.s, LoadingPanel.s

Bug #2: Symbol Kind Persistence

Problem: find_symbol_kind() ignored SymbolEntryKind::End entries. When a jump table (Object kind) ended in a Code section, the Object kind persisted and subsequent code was incorrectly processed as data, causing "Unsupported data relocation type PpcRel14/PpcRel24" errors.

Fix: Process End entries first to reset kind to Unknown, allowing the section default (Function for Code sections) to take effect.

Files fixed: nuiimagecameraproperties.s, neuralnet.s, qwidoassl.s, modelfittingstage.s, msaudiodec.s, entropydec.s, entropydecpro.s, expand.s, win32_rrthreads.s

Test plan

This fixes two bugs that caused "Failed to write" errors during XEX splitting:

Bug rjkiv#1: Relocation address alignment in ObjRelocations
- ObjRelocations::new() and insert() forced 4-byte alignment via `address & !3`
- When splits start at unaligned addresses (e.g., 0x82F0ABD3), relocations
  at relative offset 1 were corrupted to offset 0
- Fix: Remove forced alignment; to_elf() already handles alignment per type

Bug rjkiv#2: Symbol kind persistence after jump tables end
- find_symbol_kind() ignored End entries, so when a jump table (Object kind)
  ended in a Code section, subsequent code was incorrectly processed as data
- This caused "Unsupported data relocation type PpcRel14" errors for branch
  instructions after jump tables
- Fix: Process End entries to reset kind to Unknown, allowing section default

Both fixes include comprehensive unit tests.
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