diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-05 03:02:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-05 03:02:42 +0200 |
| commit | 5ea6e78943453e145366c8860cb9c8f9684f9b31 (patch) | |
| tree | c9fc4b4ffe6636ce839fa3f24328667d4aed8ee1 /lib | |
| parent | 3a8362e751d210f1cecfce7c33cae2e582bd4b94 (diff) | |
| parent | 83b7dbe52f75161a2ac6f5d8f39b275fd9473c15 (diff) | |
| download | zig-5ea6e78943453e145366c8860cb9c8f9684f9b31.tar.gz zig-5ea6e78943453e145366c8860cb9c8f9684f9b31.zip | |
Merge pull request #15162 from jacobly0/x86_64-start
x86_64: get enough things working to enable full `start.zig` logic
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/os/linux/x86.zig | 16 | ||||
| -rw-r--r-- | lib/std/os/linux/x86_64.zig | 7 | ||||
| -rw-r--r-- | lib/std/start.zig | 2 |
3 files changed, 18 insertions, 7 deletions
diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig index 6ad3c9fa31..2e67fa6b5b 100644 --- a/lib/std/os/linux/x86.zig +++ b/lib/std/os/linux/x86.zig @@ -125,36 +125,44 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: * pub fn restore() callconv(.Naked) void { switch (@import("builtin").zig_backend) { - .stage2_c => return asm volatile ( + .stage2_c => asm volatile ( \\ movl %[number], %%eax \\ int $0x80 + \\ ret : : [number] "i" (@enumToInt(SYS.sigreturn)), : "memory" ), - else => return asm volatile ("int $0x80" + else => asm volatile ( + \\ int $0x80 + \\ ret : : [number] "{eax}" (@enumToInt(SYS.sigreturn)), : "memory" ), } + unreachable; } pub fn restore_rt() callconv(.Naked) void { switch (@import("builtin").zig_backend) { - .stage2_c => return asm volatile ( + .stage2_c => asm volatile ( \\ movl %[number], %%eax \\ int $0x80 + \\ ret : : [number] "i" (@enumToInt(SYS.rt_sigreturn)), : "memory" ), - else => return asm volatile ("int $0x80" + else => asm volatile ( + \\ int $0x80 + \\ ret : : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)), : "memory" ), } + unreachable; } pub const O = struct { diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index bc1bccf53f..09047bda83 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -109,7 +109,7 @@ pub const restore = restore_rt; pub fn restore_rt() callconv(.Naked) void { switch (@import("builtin").zig_backend) { - .stage2_c => return asm volatile ( + .stage2_c => asm volatile ( \\ movl %[number], %%eax \\ syscall \\ retq @@ -117,12 +117,15 @@ pub fn restore_rt() callconv(.Naked) void { : [number] "i" (@enumToInt(SYS.rt_sigreturn)), : "rcx", "r11", "memory" ), - else => return asm volatile ("syscall" + else => asm volatile ( + \\ syscall + \\ retq : : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)), : "rcx", "r11", "memory" ), } + unreachable; } pub const mode_t = usize; diff --git a/lib/std/start.zig b/lib/std/start.zig index b3a064c7f0..1b686e43f5 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -19,7 +19,7 @@ const start_sym_name = if (native_arch.isMIPS()) "__start" else "_start"; // self-hosted is capable enough to handle all of the real start.zig logic. pub const simplified_logic = builtin.zig_backend == .stage2_wasm or - builtin.zig_backend == .stage2_x86_64 or + (builtin.zig_backend == .stage2_x86_64 and (builtin.link_libc or builtin.os.tag == .plan9)) or builtin.zig_backend == .stage2_x86 or builtin.zig_backend == .stage2_aarch64 or builtin.zig_backend == .stage2_arm or |
