mirror of
https://github.com/libretro/RetroArch.git
synced 2026-04-06 00:01:06 +08:00
Change the direct bl initSystem to a register-indirect call f724cc370f added -ffunction-sections -fdata-sections and -Wl,--gc-sections to Makefile.ctr. While this saves ~160KB RAM by enabling dead code elimination, it has a side effect: every function now gets its own ELF section (e.g. initSystem goes into .text.initSystem). The linker is free to place these sections in any order, and with a large core like ScummVM, initSystem ends up >32MB from the .crt0 section at the start of the binary. The ARM bl (branch-with-link) instruction at line 43 of 3dsx_custom_crt0.s only has a +/- 32MB range. When initSystem is beyond that range, the linker emits relocation truncated to fit: R_ARM_CALL. This fix uses the same pattern already used for main (lines 52-54: ldr r3, =main; bx r3). The ldr r2, =initSystem loads the absolute address from a literal pool, and blx r2 branches to it with no range limitation. The bl ClearMem call is fine because ClearMem is defined locally within the .crt0 section.