diff options
| author | Koakuma <koachan@protonmail.com> | 2020-10-24 19:54:58 +0700 |
|---|---|---|
| committer | Koakuma <koachan@protonmail.com> | 2020-10-24 20:05:36 +0700 |
| commit | 792526c0bd45754bced18298573ad2a145a7141e (patch) | |
| tree | d2d923c3d6b837c68b86703d5a816a0222bcfaed /lib/std | |
| parent | cdbf66e36ec110993347e5158005ec1cc0adaf13 (diff) | |
| download | zig-792526c0bd45754bced18298573ad2a145a7141e.tar.gz zig-792526c0bd45754bced18298573ad2a145a7141e.zip | |
Fix sparc64 argument loading
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/start.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index dae8251d9a..8bb9780e27 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -148,8 +148,14 @@ fn _start() callconv(.Naked) noreturn { ); }, .sparcv9 => { - starting_stack_ptr = asm ("" - : [argc] "={o6}" (-> [*]usize) + // On sparc64, the stack pointer register points to a place + // 2047 bytes below the actual stack. Also, argc and friends are + // placed starting at [stack-start + 128], so we need to account for that too. + // Ref: System V Application Binary Interface: SPARC Version 9 Processor Supplement + // Version 1.35, figure 3-16. + // TODO: find a better way to do this. + starting_stack_ptr = asm ("add %%o6, 2175, %[argc]" + : [argc] "=r" (-> [*]usize) ); }, else => @compileError("unsupported arch"), |
