Merge pull request #20797 from alexrp/start-more-arches

`start`: Add POSIX arc, csky, and hexagon support
This commit is contained in:
Andrew Kelley 2024-08-01 01:34:33 -07:00 committed by GitHub
commit 7a0da805a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -259,6 +259,15 @@ fn _start() callconv(.Naked) noreturn {
\\ and sp, x0, #-16
\\ b %[posixCallMainAndExit]
,
.arc =>
// The `arc` tag currently means ARCv2, which has an unusually low stack alignment
// requirement. ARCv3 increases it from 4 to 16, but we don't support ARCv3 yet.
\\ mov fp, 0
\\ mov blink, 0
\\ mov r0, sp
\\ and sp, sp, -4
\\ b %[posixCallMainAndExit]
,
.arm, .armeb, .thumb, .thumbeb =>
\\ mov fp, #0
\\ mov lr, #0
@ -266,6 +275,33 @@ fn _start() callconv(.Naked) noreturn {
\\ and sp, #-16
\\ b %[posixCallMainAndExit]
,
// zig fmt: off
.csky =>
if (builtin.position_independent_code)
// The CSKY ABI assumes that `gb` is set to the address of the GOT in order for
// position-independent code to work. We depend on this in `std.os.linux.start_pie`
// to locate `_DYNAMIC` as well.
\\ grs t0, 1f
\\ 1:
\\ lrw gb, 1b@GOTPC
\\ addu gb, t0
else ""
++
\\ movi lr, 0
\\ mov a0, sp
\\ andi sp, sp, -8
\\ jmpi %[posixCallMainAndExit]
,
// zig fmt: on
.hexagon =>
// r29 = SP, r30 = FP
\\ r30 = #0
\\ r0 = r29
\\ r29 = and(r29, #-16)
\\ memw(r29 + #-8) = r29
\\ r29 = add(r29, #-8)
\\ call %[posixCallMainAndExit]
,
.loongarch32, .loongarch64 =>
\\ move $fp, $zero
\\ move $a0, $sp