| ... | ... | @@ -272,13 +272,27 @@ fn _start() callconv(.Naked) noreturn { |
| 272 | 272 | \\ bstrins.d $sp, $zero, 3, 0 |
| 273 | 273 | \\ b %[posixCallMainAndExit] |
| 274 | 274 | , |
| 275 | // zig fmt: off |
| 275 | 276 | .riscv32, .riscv64 => |
| 277 | // The self-hosted riscv64 backend is not able to assemble this yet. |
| 278 | if (builtin.zig_backend != .stage2_riscv64) |
| 279 | // The RISC-V ELF ABI assumes that `gp` is set to the value of `__global_pointer$` at |
| 280 | // startup in order for GP relaxation to work, even in static builds. |
| 281 | \\ .weak __global_pointer$ |
| 282 | \\ .hidden __global_pointer$ |
| 283 | \\ .option push |
| 284 | \\ .option norelax |
| 285 | \\ lla gp, __global_pointer$ |
| 286 | \\ .option pop |
| 287 | else "" |
| 288 | ++ |
| 276 | 289 | \\ li s0, 0 |
| 277 | 290 | \\ li ra, 0 |
| 278 | 291 | \\ mv a0, sp |
| 279 | 292 | \\ andi sp, sp, -16 |
| 280 | 293 | \\ tail %[posixCallMainAndExit]@plt |
| 281 | 294 | , |
| 295 | // zig fmt: off |
| 282 | 296 | .m68k => |
| 283 | 297 | // Note that the - 8 is needed because pc in the jsr instruction points into the middle |
| 284 | 298 | // of the jsr instruction. (The lea is 6 bytes, the jsr is 4 bytes.) |
| ... | ... | @@ -293,6 +307,7 @@ fn _start() callconv(.Naked) noreturn { |
| 293 | 307 | \\ .gpword . |
| 294 | 308 | \\ .gpword %[posixCallMainAndExit] |
| 295 | 309 | \\ 1: |
| 310 | // The `gp` register on MIPS serves a similar purpose to `r2` (ToC pointer) on PPC64. |
| 296 | 311 | \\ lw $gp, 0($ra) |
| 297 | 312 | \\ subu $gp, $ra, $gp |
| 298 | 313 | \\ lw $25, 4($ra) |
| ... | ... | @@ -314,8 +329,6 @@ fn _start() callconv(.Naked) noreturn { |
| 314 | 329 | \\ .gpdword %[posixCallMainAndExit] |
| 315 | 330 | \\ 1: |
| 316 | 331 | // The `gp` register on MIPS serves a similar purpose to `r2` (ToC pointer) on PPC64. |
| 317 | | // We need to set it up in order for dynamically-linked / position-independent code to |
| 318 | | // work. |
| 319 | 332 | \\ ld $gp, 0($ra) |
| 320 | 333 | \\ dsubu $gp, $ra, $gp |
| 321 | 334 | \\ ld $25, 8($ra) |