aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-07-24 23:25:19 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2024-07-30 17:47:46 +0200
commit108c682df0ec6908695e55d3c3f50fe158a5d502 (patch)
tree3526332eed5b78aadc045056a7a3eeefe5c1fc51 /lib/std/start.zig
parent389ce984b5fc601b1b4e28e4ba47d051750afd83 (diff)
downloadzig-108c682df0ec6908695e55d3c3f50fe158a5d502.tar.gz
zig-108c682df0ec6908695e55d3c3f50fe158a5d502.zip
start: Add POSIX csky support.
Diffstat (limited to 'lib/std/start.zig')
-rw-r--r--lib/std/start.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig
index 74e177ce0b..76789bc5fc 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -316,6 +316,24 @@ 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