authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 14:09:47+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-19 02:15:30+01:00
log8a78d875cc1cdab2648e7413fc0d2eea5afc6991
tree57301c426505167cbe1580e2912304fe2a5483ac
parent4de661ef18d4cdc7f859c8bc1990e8a0519163db
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux: Don't emit CFI directives if unwind tables are disabled.


13 files changed, 73 insertions(+), 5 deletions(-)

lib/std/os/linux/aarch64.zig+7-1
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -122,7 +123,12 @@ pub fn clone() callconv(.Naked) usize {
122123 \\ ret
123124 \\
124125 \\ // child
125 \\1: .cfi_undefined lr
126 \\1:
127 );
128 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
129 \\ .cfi_undefined lr
130 );
131 asm volatile (
126132 \\ mov fp, 0
127133 \\ mov lr, 0
128134 \\
lib/std/os/linux/hexagon.zig+5-1
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const iovec = std.posix.iovec;
34const iovec_const = std.posix.iovec_const;
......@@ -117,8 +118,11 @@ pub fn clone() callconv(.Naked) usize {
117118 \\
118119 \\ p0 = cmp.eq(r0, #0)
119120 \\ if (!p0) dealloc_return
120 \\
121 );
122 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
121123 \\ .cfi_undefined r31
124 );
125 asm volatile (
122126 \\ r30 = #0
123127 \\ r31 = #0
124128 \\
lib/std/os/linux/loongarch64.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const linux = std.os.linux;
34const SYS = linux.SYS;
......@@ -121,7 +122,11 @@ pub fn clone() callconv(.Naked) usize {
121122 \\ beqz $a0, 1f # whether child process
122123 \\ jirl $zero, $ra, 0 # parent process return
123124 \\1:
125 );
126 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
124127 \\ .cfi_undefined 1
128 );
129 asm volatile (
125130 \\ move $fp, $zero
126131 \\ move $ra, $zero
127132 \\
lib/std/os/linux/mips.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -231,7 +232,11 @@ pub fn clone() callconv(.Naked) usize {
231232 \\ jr $ra
232233 \\ nop
233234 \\1:
235 );
236 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
234237 \\ .cfi_undefined $ra
238 );
239 asm volatile (
235240 \\ move $fp, $zero
236241 \\ move $ra, $zero
237242 \\
lib/std/os/linux/mips64.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -210,7 +211,11 @@ pub fn clone() callconv(.Naked) usize {
210211 \\ jr $ra
211212 \\ nop
212213 \\1:
214 );
215 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
213216 \\ .cfi_undefined $ra
217 );
218 asm volatile (
214219 \\ move $fp, $zero
215220 \\ move $ra, $zero
216221 \\
lib/std/os/linux/powerpc.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -176,7 +177,11 @@ pub fn clone() callconv(.Naked) usize {
176177 \\
177178 \\ #else: we're the child
178179 \\ 2:
180 );
181 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
179182 \\ .cfi_undefined lr
183 );
184 asm volatile (
180185 \\ li 31, 0
181186 \\ mtlr 0
182187 \\
lib/std/os/linux/powerpc64.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -161,7 +162,11 @@ pub fn clone() callconv(.Naked) usize {
161162 \\ bnelr cr7
162163 \\
163164 \\ # we're the child
165 );
166 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
164167 \\ .cfi_undefined lr
168 );
169 asm volatile (
165170 \\ li 31, 0
166171 \\ mtlr 0
167172 \\
lib/std/os/linux/riscv32.zig+7-1
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const iovec = std.posix.iovec;
34const iovec_const = std.posix.iovec_const;
......@@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {
120121 \\ ret
121122 \\
122123 \\ # Child
123 \\1: .cfi_undefined ra
124 \\1:
125 );
126 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
127 \\ .cfi_undefined ra
128 );
129 asm volatile (
124130 \\ mv fp, zero
125131 \\ mv ra, zero
126132 \\
lib/std/os/linux/riscv64.zig+7-1
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const iovec = std.posix.iovec;
34const iovec_const = std.posix.iovec_const;
......@@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {
120121 \\ ret
121122 \\
122123 \\ # Child
123 \\1: .cfi_undefined ra
124 \\1:
125 );
126 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
127 \\ .cfi_undefined ra
128 );
129 asm volatile (
124130 \\ mv fp, zero
125131 \\ mv ra, zero
126132 \\
lib/std/os/linux/s390x.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const iovec = std.posix.iovec;
34const iovec_const = std.posix.iovec_const;
......@@ -134,7 +135,11 @@ pub fn clone() callconv(.Naked) usize {
134135 \\bnzr %%r14
135136 \\
136137 \\# we're the child
138 );
139 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
137140 \\.cfi_undefined %%r14
141 );
142 asm volatile (
138143 \\lghi %%r11, 0
139144 \\lghi %%r14, 0
140145 \\
lib/std/os/linux/sparc64.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const pid_t = linux.pid_t;
......@@ -215,7 +216,11 @@ pub fn clone() callconv(.Naked) usize {
215216 \\ restore
216217 \\2:
217218 \\ # Child process
219 );
220 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
218221 \\ .cfi_undefined %%i7
222 );
223 asm volatile (
219224 \\ mov %%g0, %%fp
220225 \\ mov %%g0, %%i7
221226 \\
lib/std/os/linux/x86.zig+5
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -156,7 +157,11 @@ pub fn clone() callconv(.Naked) usize {
156157 \\ retl
157158 \\
158159 \\1:
160 );
161 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
159162 \\ .cfi_undefined %%eip
163 );
164 asm volatile (
160165 \\ xorl %%ebp,%%ebp
161166 \\
162167 \\ popl %%eax
lib/std/os/linux/x86_64.zig+7-1
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("../../std.zig");
23const maxInt = std.math.maxInt;
34const linux = std.os.linux;
......@@ -117,7 +118,12 @@ pub fn clone() callconv(.Naked) usize {
117118 \\ jz 1f
118119 \\ retq
119120 \\
120 \\1: .cfi_undefined %%rip
121 \\1:
122 );
123 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
124 \\ .cfi_undefined %%rip
125 );
126 asm volatile (
121127 \\ xorl %%ebp,%%ebp
122128 \\
123129 \\ popq %%rdi