Skip to content

Commit baba2fe

Browse files
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

File tree

ctr/3dsx_custom_crt0.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ startup:
4040

4141
@ System initialization
4242
mov r0, r4
43-
bl initSystem
43+
ldr r2, =initSystem
44+
blx r2
4445

4546
@ Set up argc/argv arguments for main()
4647
ldr r0, =__system_argc

0 commit comments

Comments
 (0)