diff options
author | Thomas Weißschuh <linux@weissschuh.net> | 2023-11-08 19:14:43 +0100 |
---|---|---|
committer | Thomas Weißschuh <linux@weissschuh.net> | 2023-12-11 22:38:30 +0100 |
commit | 544102458a8d1c33f9f5f99f9bda8e2b858bcb10 (patch) | |
tree | 5e821833ba97448624f312e81592249cbd29b060 /tools/include | |
parent | 8bcf9a485541fe0079483162496db1add932689b (diff) |
tools/nolibc: mips: add support for PIC
MIPS requires some extra instructions to set up the $gp register for the
with a pointer to the global data area.
This isn't needed for non-PIC builds, but this patch enables the code
unconditionally to prevent bitrot.
Also enable PIC in one of the test configurations for ongoing
validation.
Link: https://lore.kernel.org/r/20231108-nolibc-pic-v2-1-4fb0d6284757@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/include')
-rw-r--r-- | tools/include/nolibc/arch-mips.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 3a2c76716b83..62cc50ef3288 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -184,8 +184,13 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ __asm__ volatile ( ".set push\n" ".set noreorder\n" - ".option pic0\n" + "bal 1f\n" /* prime $ra for .cpload */ + "nop\n" + "1:\n" + ".cpload $ra\n" "move $a0, $sp\n" /* save stack pointer to $a0, as arg1 of _start_c */ + "addiu $sp, $sp, -4\n" /* space for .cprestore to store $gp */ + ".cprestore 0\n" "li $t0, -8\n" "and $sp, $sp, $t0\n" /* $sp must be 8-byte aligned */ "addiu $sp, $sp, -16\n" /* the callee expects to save a0..a3 there */ |