Skip to content

Commit 108c682

Browse files
committed
start: Add POSIX csky support.
1 parent 389ce98 commit 108c682

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/std/start.zig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,24 @@ fn _start() callconv(.Naked) noreturn {
316316
\\ and sp, #-16
317317
\\ b %[posixCallMainAndExit]
318318
,
319+
// zig fmt: off
320+
.csky =>
321+
if (builtin.position_independent_code)
322+
// The CSKY ABI assumes that `gb` is set to the address of the GOT in order for
323+
// position-independent code to work. We depend on this in `std.os.linux.start_pie`
324+
// to locate `_DYNAMIC` as well.
325+
\\ grs t0, 1f
326+
\\ 1:
327+
\\ lrw gb, 1b@GOTPC
328+
\\ addu gb, t0
329+
else ""
330+
++
331+
\\ movi lr, 0
332+
\\ mov a0, sp
333+
\\ andi sp, sp, -8
334+
\\ jmpi %[posixCallMainAndExit]
335+
,
336+
// zig fmt: on
319337
.hexagon =>
320338
// r29 = SP, r30 = FP
321339
\\ r30 = #0

0 commit comments

Comments
 (0)