| ... | @@ -329,31 +329,43 @@ fn _start() callconv(.Naked) noreturn { | ... | @@ -329,31 +329,43 @@ fn _start() callconv(.Naked) noreturn { |
| 329 | \\ jsr (%%pc, %%a0) | 329 | \\ jsr (%%pc, %%a0) |
| 330 | , | 330 | , |
| 331 | .mips, .mipsel => | 331 | .mips, .mipsel => |
| | 332 | \\ move $fp, $0 |
| 332 | \\ bal 1f | 333 | \\ bal 1f |
| 333 | \\ .gpword . | 334 | \\ .gpword . |
| | 335 | \\ .gpword %[posixCallMainAndExit] |
| 334 | \\ 1: | 336 | \\ 1: |
| 335 | \\ lw $gp, 0($ra) | 337 | \\ lw $gp, 0($ra) |
| 336 | \\ subu $gp, $ra, $gp | 338 | \\ subu $gp, $ra, $gp |
| 337 | \\ move $fp, $0 | 339 | \\ lw $25, 4($ra) |
| | 340 | \\ addu $25, $25, $gp |
| 338 | \\ move $ra, $0 | 341 | \\ move $ra, $0 |
| 339 | \\ move $a0, $sp | 342 | \\ move $a0, $sp |
| 340 | \\ and $sp, -8 | 343 | \\ and $sp, -8 |
| 341 | \\ j %[posixCallMainAndExit] | 344 | \\ subu $sp, $sp, 16 |
| | 345 | \\ jalr $25 |
| 342 | , | 346 | , |
| 343 | .mips64, .mips64el => | 347 | .mips64, .mips64el => |
| | 348 | \\ move $fp, $0 |
| | 349 | // This is needed because early MIPS versions don't support misaligned loads. Without |
| | 350 | // this directive, the hidden `nop` inserted to fill the delay slot after `bal` would |
| | 351 | // cause the two doublewords to be aligned to 4 bytes instead of 8. |
| | 352 | \\ .balign 8 |
| 344 | \\ bal 1f | 353 | \\ bal 1f |
| 345 | \\ .gpdword . | 354 | \\ .gpdword . |
| | 355 | \\ .gpdword %[posixCallMainAndExit] |
| 346 | \\ 1: | 356 | \\ 1: |
| 347 | // The `gp` register on MIPS serves a similar purpose to `r2` (ToC pointer) on PPC64. | 357 | // The `gp` register on MIPS serves a similar purpose to `r2` (ToC pointer) on PPC64. |
| 348 | // We need to set it up in order for dynamically-linked / position-independent code to | 358 | // We need to set it up in order for dynamically-linked / position-independent code to |
| 349 | // work. | 359 | // work. |
| 350 | \\ ld $gp, 0($ra) | 360 | \\ ld $gp, 0($ra) |
| 351 | \\ dsubu $gp, $ra, $gp | 361 | \\ dsubu $gp, $ra, $gp |
| 352 | \\ move $fp, $0 | 362 | \\ ld $25, 8($ra) |
| | 363 | \\ daddu $25, $25, $gp |
| 353 | \\ move $ra, $0 | 364 | \\ move $ra, $0 |
| 354 | \\ move $a0, $sp | 365 | \\ move $a0, $sp |
| 355 | \\ and $sp, -16 | 366 | \\ and $sp, -16 |
| 356 | \\ j %[posixCallMainAndExit] | 367 | \\ dsubu $sp, $sp, 16 |
| | 368 | \\ jalr $25 |
| 357 | , | 369 | , |
| 358 | .powerpc, .powerpcle => | 370 | .powerpc, .powerpcle => |
| 359 | // Set up the initial stack frame, and clear the back chain pointer. | 371 | // Set up the initial stack frame, and clear the back chain pointer. |