From fe2efaf07f61a7851872a81d5c707931fcb38eb7 Mon Sep 17 00:00:00 2001 From: Leon Vak Date: Tue, 17 Feb 2026 18:59:41 +0200 Subject: [PATCH] Fix MIPS __start linker error with default relocation model Turns out `la $t9, {entry}` generates a CALL16 relocation in PIC mode, and CALL16 needs the target to be a global symbol. Since `entry` is pub(super), the linker rightfully complains. Swapped to lui/addiu which use HI16/LO16 and don't care about visibility. --- src/arch/mips32.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arch/mips32.rs b/src/arch/mips32.rs index 6716c25..201895e 100644 --- a/src/arch/mips32.rs +++ b/src/arch/mips32.rs @@ -50,8 +50,9 @@ pub(super) unsafe extern "C" fn __start() -> ! { "and $sp, $sp, -8", // Align stack to 8 bytes. "subu $sp, $sp, 16", // Reserve 16 bytes for O32 ABI argument save area. "move $ra, $zero", // Set the return address to zero. - "la $t9, {entry}", // Load entry address into $t9. - "jr $t9", // Jump to `entry` via $t9 (required for PIC). + "lui $t9, %hi({entry})", // Load entry address into $t9. + "addiu $t9, $t9, %lo({entry})", // + "jr $t9", // Jump to `entry` via $t9 (PIC convention). "nop", // Branch delay slot. ".set reorder", entry = sym super::program::entry