Commit baba2fe
committed
3ds: fix scummvm core build
Change the direct bl initSystem to a register-indirect call
f724cc3 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.1 parent 28f206a commit baba2fe
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
0 commit comments