authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-01 01:34:33-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-01 01:34:33-07:00
log7a0da805a8d785a2c0bd9d50f01136dc7d190b46
treea5686535f532d743f849be808166921a5d5cc970
parent8f7cbaa4c0cebc22613a33d212569cf221d6a3df
parent108c682df0ec6908695e55d3c3f50fe158a5d502
signaturebadge-check Signed by PGP key B5690EEEBB952194

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

`start`: Add POSIX arc, csky, and hexagon support

1 files changed, 36 insertions(+), 0 deletions(-)

lib/std/start.zig+36
......@@ -259,6 +259,15 @@ fn _start() callconv(.Naked) noreturn {
259259 \\ and sp, x0, #-16
260260 \\ b %[posixCallMainAndExit]
261261 ,
262 .arc =>
263 // The `arc` tag currently means ARCv2, which has an unusually low stack alignment
264 // requirement. ARCv3 increases it from 4 to 16, but we don't support ARCv3 yet.
265 \\ mov fp, 0
266 \\ mov blink, 0
267 \\ mov r0, sp
268 \\ and sp, sp, -4
269 \\ b %[posixCallMainAndExit]
270 ,
262271 .arm, .armeb, .thumb, .thumbeb =>
263272 \\ mov fp, #0
264273 \\ mov lr, #0
......@@ -266,6 +275,33 @@ fn _start() callconv(.Naked) noreturn {
266275 \\ and sp, #-16
267276 \\ b %[posixCallMainAndExit]
268277 ,
278 // zig fmt: off
279 .csky =>
280 if (builtin.position_independent_code)
281 // The CSKY ABI assumes that `gb` is set to the address of the GOT in order for
282 // position-independent code to work. We depend on this in `std.os.linux.start_pie`
283 // to locate `_DYNAMIC` as well.
284 \\ grs t0, 1f
285 \\ 1:
286 \\ lrw gb, 1b@GOTPC
287 \\ addu gb, t0
288 else ""
289 ++
290 \\ movi lr, 0
291 \\ mov a0, sp
292 \\ andi sp, sp, -8
293 \\ jmpi %[posixCallMainAndExit]
294 ,
295 // zig fmt: on
296 .hexagon =>
297 // r29 = SP, r30 = FP
298 \\ r30 = #0
299 \\ r0 = r29
300 \\ r29 = and(r29, #-16)
301 \\ memw(r29 + #-8) = r29
302 \\ r29 = add(r29, #-8)
303 \\ call %[posixCallMainAndExit]
304 ,
269305 .loongarch32, .loongarch64 =>
270306 \\ move $fp, $zero
271307 \\ move $a0, $sp