Skip to content

Commit

Permalink
lib: Fix asm code in _start for SPARC
Browse files Browse the repository at this point in the history
SPARCs have delayed branches, that is, it will unconditionally
run the next instruction following a branch.
Slightly reorder the _start code sequence to prevent it from
accidentally executing stray instructions, which may result in odd
program behavior.
  • Loading branch information
koachan authored and andrewrk committed Oct 12, 2023
1 parent 67ee68f commit 375bb5f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/std/start.zig
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ fn _start() callconv(.Naked) noreturn {
// argc is stored after a register window (16 registers) plus stack bias
\\ mov %%g0, %%i6
\\ add %%o6, 2175, %%l0
\\ stx %%l0, %[argc_argv_ptr]
\\ ba %[posixCallMainAndExit]
\\ stx %%l0, %[argc_argv_ptr]
,
else => @compileError("unsupported arch"),
}
Expand Down

0 comments on commit 375bb5f

Please sign in to comment.