aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-08-01 01:34:33 -0700
committerGitHub <noreply@github.com>2024-08-01 01:34:33 -0700
commit7a0da805a8d785a2c0bd9d50f01136dc7d190b46 (patch)
treea5686535f532d743f849be808166921a5d5cc970 /lib/std/start.zig
parent8f7cbaa4c0cebc22613a33d212569cf221d6a3df (diff)
parent108c682df0ec6908695e55d3c3f50fe158a5d502 (diff)
downloadzig-7a0da805a8d785a2c0bd9d50f01136dc7d190b46.tar.gz
zig-7a0da805a8d785a2c0bd9d50f01136dc7d190b46.zip
Merge pull request #20797 from alexrp/start-more-arches
`start`: Add POSIX arc, csky, and hexagon support
Diffstat (limited to 'lib/std/start.zig')
-rw-r--r--lib/std/start.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig
index c68dec4462..fd8661660b 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -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