| ... | @@ -279,8 +279,10 @@ fn _start() callconv(.naked) noreturn { | ... | @@ -279,8 +279,10 @@ fn _start() callconv(.naked) noreturn { |
| 279 | , | 279 | , |
| 280 | .arm, .armeb, .thumb, .thumbeb => | 280 | .arm, .armeb, .thumb, .thumbeb => |
| 281 | // Note that this code must work for Thumb-1. | 281 | // Note that this code must work for Thumb-1. |
| | 282 | // r7 = FP (local), r11 = FP (unwind) |
| 282 | \\ movs v1, #0 | 283 | \\ movs v1, #0 |
| 283 | \\ mov fp, v1 | 284 | \\ mov r7, v1 |
| | 285 | \\ mov r11, v1 |
| 284 | \\ mov lr, v1 | 286 | \\ mov lr, v1 |
| 285 | \\ mov a1, sp | 287 | \\ mov a1, sp |
| 286 | \\ subs v1, #16 | 288 | \\ subs v1, #16 |
| ... | @@ -290,20 +292,23 @@ fn _start() callconv(.naked) noreturn { | ... | @@ -290,20 +292,23 @@ fn _start() callconv(.naked) noreturn { |
| 290 | , | 292 | , |
| 291 | .csky => | 293 | .csky => |
| 292 | // The CSKY ABI assumes that `gb` is set to the address of the GOT in order for | 294 | // The CSKY ABI assumes that `gb` is set to the address of the GOT in order for |
| 293 | // position-independent code to work. We depend on this in `std.os.linux.start_pie` | 295 | // position-independent code to work. We depend on this in `std.os.linux.pie` to locate |
| 294 | // to locate `_DYNAMIC` as well. | 296 | // `_DYNAMIC` as well. |
| | 297 | // r8 = FP |
| 295 | \\ grs t0, 1f | 298 | \\ grs t0, 1f |
| 296 | \\ 1: | 299 | \\ 1: |
| 297 | \\ lrw gb, 1b@GOTPC | 300 | \\ lrw gb, 1b@GOTPC |
| 298 | \\ addu gb, t0 | 301 | \\ addu gb, t0 |
| | 302 | \\ movi r8, 0 |
| 299 | \\ movi lr, 0 | 303 | \\ movi lr, 0 |
| 300 | \\ mov a0, sp | 304 | \\ mov a0, sp |
| 301 | \\ andi sp, sp, -8 | 305 | \\ andi sp, sp, -8 |
| 302 | \\ jmpi %[posixCallMainAndExit] | 306 | \\ jmpi %[posixCallMainAndExit] |
| 303 | , | 307 | , |
| 304 | .hexagon => | 308 | .hexagon => |
| 305 | // r29 = SP, r30 = FP | 309 | // r29 = SP, r30 = FP, r31 = LR |
| 306 | \\ r30 = #0 | 310 | \\ r30 = #0 |
| | 311 | \\ r31 = #0 |
| 307 | \\ r0 = r29 | 312 | \\ r0 = r29 |
| 308 | \\ r29 = and(r29, #-16) | 313 | \\ r29 = and(r29, #-16) |
| 309 | \\ memw(r29 + #-8) = r29 | 314 | \\ memw(r29 + #-8) = r29 |
| ... | @@ -312,12 +317,13 @@ fn _start() callconv(.naked) noreturn { | ... | @@ -312,12 +317,13 @@ fn _start() callconv(.naked) noreturn { |
| 312 | , | 317 | , |
| 313 | .loongarch32, .loongarch64 => | 318 | .loongarch32, .loongarch64 => |
| 314 | \\ move $fp, $zero | 319 | \\ move $fp, $zero |
| | 320 | \\ move $ra, $zero |
| 315 | \\ move $a0, $sp | 321 | \\ move $a0, $sp |
| 316 | \\ bstrins.d $sp, $zero, 3, 0 | 322 | \\ bstrins.d $sp, $zero, 3, 0 |
| 317 | \\ b %[posixCallMainAndExit] | 323 | \\ b %[posixCallMainAndExit] |
| 318 | , | 324 | , |
| 319 | .riscv32, .riscv64 => | 325 | .riscv32, .riscv64 => |
| 320 | \\ li s0, 0 | 326 | \\ li fp, 0 |
| 321 | \\ li ra, 0 | 327 | \\ li ra, 0 |
| 322 | \\ mv a0, sp | 328 | \\ mv a0, sp |
| 323 | \\ andi sp, sp, -16 | 329 | \\ andi sp, sp, -16 |
| ... | @@ -371,28 +377,35 @@ fn _start() callconv(.naked) noreturn { | ... | @@ -371,28 +377,35 @@ fn _start() callconv(.naked) noreturn { |
| 371 | , | 377 | , |
| 372 | .powerpc, .powerpcle => | 378 | .powerpc, .powerpcle => |
| 373 | // Set up the initial stack frame, and clear the back chain pointer. | 379 | // Set up the initial stack frame, and clear the back chain pointer. |
| | 380 | // r1 = SP, r31 = FP |
| 374 | \\ mr 3, 1 | 381 | \\ mr 3, 1 |
| 375 | \\ clrrwi 1, 1, 4 | 382 | \\ clrrwi 1, 1, 4 |
| 376 | \\ li 0, 0 | 383 | \\ li 0, 0 |
| 377 | \\ stwu 1, -16(1) | 384 | \\ stwu 1, -16(1) |
| 378 | \\ stw 0, 0(1) | 385 | \\ stw 0, 0(1) |
| | 386 | \\ li 31, 0 |
| 379 | \\ mtlr 0 | 387 | \\ mtlr 0 |
| 380 | \\ b %[posixCallMainAndExit] | 388 | \\ b %[posixCallMainAndExit] |
| 381 | , | 389 | , |
| 382 | .powerpc64, .powerpc64le => | 390 | .powerpc64, .powerpc64le => |
| 383 | // Set up the ToC and initial stack frame, and clear the back chain pointer. | 391 | // Set up the ToC and initial stack frame, and clear the back chain pointer. |
| | 392 | // r1 = SP, r2 = ToC, r31 = FP |
| 384 | \\ addis 2, 12, .TOC. - %[_start]@ha | 393 | \\ addis 2, 12, .TOC. - %[_start]@ha |
| 385 | \\ addi 2, 2, .TOC. - %[_start]@l | 394 | \\ addi 2, 2, .TOC. - %[_start]@l |
| 386 | \\ mr 3, 1 | 395 | \\ mr 3, 1 |
| 387 | \\ clrrdi 1, 1, 4 | 396 | \\ clrrdi 1, 1, 4 |
| 388 | \\ li 0, 0 | 397 | \\ li 0, 0 |
| 389 | \\ stdu 0, -32(1) | 398 | \\ stdu 0, -32(1) |
| | 399 | \\ li 31, 0 |
| 390 | \\ mtlr 0 | 400 | \\ mtlr 0 |
| 391 | \\ b %[posixCallMainAndExit] | 401 | \\ b %[posixCallMainAndExit] |
| 392 | \\ nop | 402 | \\ nop |
| 393 | , | 403 | , |
| 394 | .s390x => | 404 | .s390x => |
| 395 | // Set up the stack frame (register save area and cleared back-chain slot). | 405 | // Set up the stack frame (register save area and cleared back-chain slot). |
| | 406 | // r11 = FP, r14 = LR, r15 = SP |
| | 407 | \\ lghi %%r11, 0 |
| | 408 | \\ lghi %%r14, 0 |
| 396 | \\ lgr %%r2, %%r15 | 409 | \\ lgr %%r2, %%r15 |
| 397 | \\ lghi %%r0, -16 | 410 | \\ lghi %%r0, -16 |
| 398 | \\ ngr %%r15, %%r0 | 411 | \\ ngr %%r15, %%r0 |
| ... | @@ -403,7 +416,9 @@ fn _start() callconv(.naked) noreturn { | ... | @@ -403,7 +416,9 @@ fn _start() callconv(.naked) noreturn { |
| 403 | , | 416 | , |
| 404 | .sparc => | 417 | .sparc => |
| 405 | // argc is stored after a register window (16 registers * 4 bytes). | 418 | // argc is stored after a register window (16 registers * 4 bytes). |
| | 419 | // i7 = LR |
| 406 | \\ mov %%g0, %%fp | 420 | \\ mov %%g0, %%fp |
| | 421 | \\ mov %%g0, %%i7 |
| 407 | \\ add %%sp, 64, %%o0 | 422 | \\ add %%sp, 64, %%o0 |
| 408 | \\ and %%sp, -8, %%sp | 423 | \\ and %%sp, -8, %%sp |
| 409 | \\ ba,a %[posixCallMainAndExit] | 424 | \\ ba,a %[posixCallMainAndExit] |
| ... | @@ -411,7 +426,9 @@ fn _start() callconv(.naked) noreturn { | ... | @@ -411,7 +426,9 @@ fn _start() callconv(.naked) noreturn { |
| 411 | .sparc64 => | 426 | .sparc64 => |
| 412 | // argc is stored after a register window (16 registers * 8 bytes) plus the stack bias | 427 | // argc is stored after a register window (16 registers * 8 bytes) plus the stack bias |
| 413 | // (2047 bytes). | 428 | // (2047 bytes). |
| | 429 | // i7 = LR |
| 414 | \\ mov %%g0, %%fp | 430 | \\ mov %%g0, %%fp |
| | 431 | \\ mov %%g0, %%i7 |
| 415 | \\ add %%sp, 2175, %%o0 | 432 | \\ add %%sp, 2175, %%o0 |
| 416 | \\ add %%sp, 2047, %%sp | 433 | \\ add %%sp, 2047, %%sp |
| 417 | \\ and %%sp, -16, %%sp | 434 | \\ and %%sp, -16, %%sp |