mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:44:43 +01:00
start: Set up the gp register on mips and mips64.
This commit is contained in:
parent
66b71273a2
commit
77fc3b88fb
1 changed files with 13 additions and 0 deletions
|
|
@ -329,6 +329,11 @@ fn _start() callconv(.Naked) noreturn {
|
|||
\\ jsr (%%pc, %%a0)
|
||||
,
|
||||
.mips, .mipsel =>
|
||||
\\ bal 1f
|
||||
\\ .gpword .
|
||||
\\ 1:
|
||||
\\ lw $gp, 0($ra)
|
||||
\\ subu $gp, $ra, $gp
|
||||
\\ move $fp, $0
|
||||
\\ move $ra, $0
|
||||
\\ move $a0, $sp
|
||||
|
|
@ -336,6 +341,14 @@ fn _start() callconv(.Naked) noreturn {
|
|||
\\ j %[posixCallMainAndExit]
|
||||
,
|
||||
.mips64, .mips64el =>
|
||||
\\ bal 1f
|
||||
\\ .gpdword .
|
||||
\\ 1:
|
||||
// The `gp` register on MIPS serves a similar purpose to `r2` (ToC pointer) on PPC64.
|
||||
// We need to set it up in order for dynamically-linked / position-independent code to
|
||||
// work.
|
||||
\\ ld $gp, 0($ra)
|
||||
\\ dsubu $gp, $ra, $gp
|
||||
\\ move $fp, $0
|
||||
\\ move $ra, $0
|
||||
\\ move $a0, $sp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue