diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-07-30 03:18:10 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-07-31 01:58:10 -0400 |
| commit | 817fa3af8631d894004fbdb668da0882836dbe9b (patch) | |
| tree | 3e63751b5ebb46fe8c45eca41a5248075d97bda8 /lib/std/start.zig | |
| parent | 43b830415368ac4fb08bf5e154a222a38baf4a24 (diff) | |
| download | zig-817fa3af8631d894004fbdb668da0882836dbe9b.tar.gz zig-817fa3af8631d894004fbdb668da0882836dbe9b.zip | |
std: cleanup asm usage
After fixing some issues with inline assembly in the C backend, the std
cleanups have the side effect of making these functions compatible with
the backend, allowing it to be used on linux without linking libc.
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index dbc9cf167d..7e0a8da61b 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -256,38 +256,38 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv fn _start() callconv(.Naked) noreturn { switch (builtin.zig_backend) { .stage2_c => { - @export(argc_argv_ptr, .{ .name = "argc_argv_ptr" }); - @export(posixCallMainAndExit, .{ .name = "_posixCallMainAndExit" }); - switch (native_arch) { - .x86_64 => asm volatile ( + asm volatile (switch (native_arch) { + .x86_64 => \\ xorl %%ebp, %%ebp - \\ movq %%rsp, argc_argv_ptr + \\ movq %%rsp, %[argc_argv_ptr] \\ andq $-16, %%rsp - \\ call _posixCallMainAndExit - ), - .x86 => asm volatile ( + \\ callq %[posixCallMainAndExit:P] + , + .x86 => \\ xorl %%ebp, %%ebp - \\ movl %%esp, argc_argv_ptr + \\ movl %%esp, %[argc_argv_ptr] \\ andl $-16, %%esp - \\ jmp _posixCallMainAndExit - ), - .aarch64, .aarch64_be => asm volatile ( + \\ calll %[posixCallMainAndExit:P] + , + .aarch64, .aarch64_be => \\ mov fp, #0 \\ mov lr, #0 \\ mov x0, sp - \\ adrp x1, argc_argv_ptr - \\ str x0, [x1, :lo12:argc_argv_ptr] - \\ b _posixCallMainAndExit - ), - .arm, .armeb, .thumb => asm volatile ( + \\ str x0, %[argc_argv_ptr] + \\ b %[posixCallMainAndExit] + , + .arm, .armeb, .thumb => \\ mov fp, #0 \\ mov lr, #0 - \\ str sp, argc_argv_ptr + \\ str sp, %[argc_argv_ptr] \\ and sp, #-16 - \\ b _posixCallMainAndExit - ), - else => @compileError("unsupported arch"), - } + \\ b %[posixCallMainAndExit] + , + else => @compileError("unsupported arch"), + } + : [argc_argv_ptr] "=m" (argc_argv_ptr), + : [posixCallMainAndExit] "X" (&posixCallMainAndExit), + ); unreachable; }, else => switch (native_arch) { |
