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 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -122,7 +123,12 @@ pub fn clone() callconv(.Naked) usize {...@@ -122,7 +123,12 @@ pub fn clone() callconv(.Naked) usize {
122 \\ ret123 \\ ret
123 \\124 \\
124 \\ // child125 \\ // child
125 \\1: .cfi_undefined lr126 \\1:
127 );
128 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
129 \\ .cfi_undefined lr
130 );
131 asm volatile (
126 \\ mov fp, 0132 \\ mov fp, 0
127 \\ mov lr, 0133 \\ mov lr, 0
128 \\134 \\
lib/std/os/linux/hexagon.zig+5-1
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const iovec = std.posix.iovec;3const iovec = std.posix.iovec;
3const iovec_const = std.posix.iovec_const;4const iovec_const = std.posix.iovec_const;
...@@ -117,8 +118,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -117,8 +118,11 @@ pub fn clone() callconv(.Naked) usize {
117 \\118 \\
118 \\ p0 = cmp.eq(r0, #0)119 \\ p0 = cmp.eq(r0, #0)
119 \\ if (!p0) dealloc_return120 \\ if (!p0) dealloc_return
120 \\121 );
122 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
121 \\ .cfi_undefined r31123 \\ .cfi_undefined r31
124 );
125 asm volatile (
122 \\ r30 = #0126 \\ r30 = #0
123 \\ r31 = #0127 \\ r31 = #0
124 \\128 \\
lib/std/os/linux/loongarch64.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const linux = std.os.linux;3const linux = std.os.linux;
3const SYS = linux.SYS;4const SYS = linux.SYS;
...@@ -121,7 +122,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -121,7 +122,11 @@ pub fn clone() callconv(.Naked) usize {
121 \\ beqz $a0, 1f # whether child process122 \\ beqz $a0, 1f # whether child process
122 \\ jirl $zero, $ra, 0 # parent process return123 \\ jirl $zero, $ra, 0 # parent process return
123 \\1:124 \\1:
125 );
126 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
124 \\ .cfi_undefined 1127 \\ .cfi_undefined 1
128 );
129 asm volatile (
125 \\ move $fp, $zero130 \\ move $fp, $zero
126 \\ move $ra, $zero131 \\ move $ra, $zero
127 \\132 \\
lib/std/os/linux/mips.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -231,7 +232,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -231,7 +232,11 @@ pub fn clone() callconv(.Naked) usize {
231 \\ jr $ra232 \\ jr $ra
232 \\ nop233 \\ nop
233 \\1:234 \\1:
235 );
236 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
234 \\ .cfi_undefined $ra237 \\ .cfi_undefined $ra
238 );
239 asm volatile (
235 \\ move $fp, $zero240 \\ move $fp, $zero
236 \\ move $ra, $zero241 \\ move $ra, $zero
237 \\242 \\
lib/std/os/linux/mips64.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -210,7 +211,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -210,7 +211,11 @@ pub fn clone() callconv(.Naked) usize {
210 \\ jr $ra211 \\ jr $ra
211 \\ nop212 \\ nop
212 \\1:213 \\1:
214 );
215 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
213 \\ .cfi_undefined $ra216 \\ .cfi_undefined $ra
217 );
218 asm volatile (
214 \\ move $fp, $zero219 \\ move $fp, $zero
215 \\ move $ra, $zero220 \\ move $ra, $zero
216 \\221 \\
lib/std/os/linux/powerpc.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -176,7 +177,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -176,7 +177,11 @@ pub fn clone() callconv(.Naked) usize {
176 \\177 \\
177 \\ #else: we're the child178 \\ #else: we're the child
178 \\ 2:179 \\ 2:
180 );
181 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
179 \\ .cfi_undefined lr182 \\ .cfi_undefined lr
183 );
184 asm volatile (
180 \\ li 31, 0185 \\ li 31, 0
181 \\ mtlr 0186 \\ mtlr 0
182 \\187 \\
lib/std/os/linux/powerpc64.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -161,7 +162,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -161,7 +162,11 @@ pub fn clone() callconv(.Naked) usize {
161 \\ bnelr cr7162 \\ bnelr cr7
162 \\163 \\
163 \\ # we're the child164 \\ # we're the child
165 );
166 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
164 \\ .cfi_undefined lr167 \\ .cfi_undefined lr
168 );
169 asm volatile (
165 \\ li 31, 0170 \\ li 31, 0
166 \\ mtlr 0171 \\ mtlr 0
167 \\172 \\
lib/std/os/linux/riscv32.zig+7-1
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const iovec = std.posix.iovec;3const iovec = std.posix.iovec;
3const iovec_const = std.posix.iovec_const;4const iovec_const = std.posix.iovec_const;
...@@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {...@@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {
120 \\ ret121 \\ ret
121 \\122 \\
122 \\ # Child123 \\ # Child
123 \\1: .cfi_undefined ra124 \\1:
125 );
126 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
127 \\ .cfi_undefined ra
128 );
129 asm volatile (
124 \\ mv fp, zero130 \\ mv fp, zero
125 \\ mv ra, zero131 \\ mv ra, zero
126 \\132 \\
lib/std/os/linux/riscv64.zig+7-1
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const iovec = std.posix.iovec;3const iovec = std.posix.iovec;
3const iovec_const = std.posix.iovec_const;4const iovec_const = std.posix.iovec_const;
...@@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {...@@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {
120 \\ ret121 \\ ret
121 \\122 \\
122 \\ # Child123 \\ # Child
123 \\1: .cfi_undefined ra124 \\1:
125 );
126 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
127 \\ .cfi_undefined ra
128 );
129 asm volatile (
124 \\ mv fp, zero130 \\ mv fp, zero
125 \\ mv ra, zero131 \\ mv ra, zero
126 \\132 \\
lib/std/os/linux/s390x.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const iovec = std.posix.iovec;3const iovec = std.posix.iovec;
3const iovec_const = std.posix.iovec_const;4const iovec_const = std.posix.iovec_const;
...@@ -134,7 +135,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -134,7 +135,11 @@ pub fn clone() callconv(.Naked) usize {
134 \\bnzr %%r14135 \\bnzr %%r14
135 \\136 \\
136 \\# we're the child137 \\# we're the child
138 );
139 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
137 \\.cfi_undefined %%r14140 \\.cfi_undefined %%r14
141 );
142 asm volatile (
138 \\lghi %%r11, 0143 \\lghi %%r11, 0
139 \\lghi %%r14, 0144 \\lghi %%r14, 0
140 \\145 \\
lib/std/os/linux/sparc64.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const pid_t = linux.pid_t;4const pid_t = linux.pid_t;
...@@ -215,7 +216,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -215,7 +216,11 @@ pub fn clone() callconv(.Naked) usize {
215 \\ restore216 \\ restore
216 \\2:217 \\2:
217 \\ # Child process218 \\ # Child process
219 );
220 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
218 \\ .cfi_undefined %%i7221 \\ .cfi_undefined %%i7
222 );
223 asm volatile (
219 \\ mov %%g0, %%fp224 \\ mov %%g0, %%fp
220 \\ mov %%g0, %%i7225 \\ mov %%g0, %%i7
221 \\226 \\
lib/std/os/linux/x86.zig+5
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -156,7 +157,11 @@ pub fn clone() callconv(.Naked) usize {...@@ -156,7 +157,11 @@ pub fn clone() callconv(.Naked) usize {
156 \\ retl157 \\ retl
157 \\158 \\
158 \\1:159 \\1:
160 );
161 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
159 \\ .cfi_undefined %%eip162 \\ .cfi_undefined %%eip
163 );
164 asm volatile (
160 \\ xorl %%ebp,%%ebp165 \\ xorl %%ebp,%%ebp
161 \\166 \\
162 \\ popl %%eax167 \\ popl %%eax
lib/std/os/linux/x86_64.zig+7-1
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("../../std.zig");2const std = @import("../../std.zig");
2const maxInt = std.math.maxInt;3const maxInt = std.math.maxInt;
3const linux = std.os.linux;4const linux = std.os.linux;
...@@ -117,7 +118,12 @@ pub fn clone() callconv(.Naked) usize {...@@ -117,7 +118,12 @@ pub fn clone() callconv(.Naked) usize {
117 \\ jz 1f118 \\ jz 1f
118 \\ retq119 \\ retq
119 \\120 \\
120 \\1: .cfi_undefined %%rip121 \\1:
122 );
123 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
124 \\ .cfi_undefined %%rip
125 );
126 asm volatile (
121 \\ xorl %%ebp,%%ebp127 \\ xorl %%ebp,%%ebp
122 \\128 \\
123 \\ popq %%rdi129 \\ popq %%rdi