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

This commit is contained in:
Alex Rønne Petersen 2025-01-18 14:09:47 +01:00
parent 4de661ef18
commit 8a78d875cc
No known key found for this signature in database
13 changed files with 73 additions and 5 deletions

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -122,7 +123,12 @@ pub fn clone() callconv(.Naked) usize {
\\ ret \\ ret
\\ \\
\\ // child \\ // child
\\1: .cfi_undefined lr \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined lr
);
asm volatile (
\\ mov fp, 0 \\ mov fp, 0
\\ mov lr, 0 \\ mov lr, 0
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const iovec = std.posix.iovec; const iovec = std.posix.iovec;
const iovec_const = std.posix.iovec_const; const iovec_const = std.posix.iovec_const;
@ -117,8 +118,11 @@ pub fn clone() callconv(.Naked) usize {
\\ \\
\\ p0 = cmp.eq(r0, #0) \\ p0 = cmp.eq(r0, #0)
\\ if (!p0) dealloc_return \\ if (!p0) dealloc_return
\\ );
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined r31 \\ .cfi_undefined r31
);
asm volatile (
\\ r30 = #0 \\ r30 = #0
\\ r31 = #0 \\ r31 = #0
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const linux = std.os.linux; const linux = std.os.linux;
const SYS = linux.SYS; const SYS = linux.SYS;
@ -121,7 +122,11 @@ pub fn clone() callconv(.Naked) usize {
\\ beqz $a0, 1f # whether child process \\ beqz $a0, 1f # whether child process
\\ jirl $zero, $ra, 0 # parent process return \\ jirl $zero, $ra, 0 # parent process return
\\1: \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined 1 \\ .cfi_undefined 1
);
asm volatile (
\\ move $fp, $zero \\ move $fp, $zero
\\ move $ra, $zero \\ move $ra, $zero
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -231,7 +232,11 @@ pub fn clone() callconv(.Naked) usize {
\\ jr $ra \\ jr $ra
\\ nop \\ nop
\\1: \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined $ra \\ .cfi_undefined $ra
);
asm volatile (
\\ move $fp, $zero \\ move $fp, $zero
\\ move $ra, $zero \\ move $ra, $zero
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -210,7 +211,11 @@ pub fn clone() callconv(.Naked) usize {
\\ jr $ra \\ jr $ra
\\ nop \\ nop
\\1: \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined $ra \\ .cfi_undefined $ra
);
asm volatile (
\\ move $fp, $zero \\ move $fp, $zero
\\ move $ra, $zero \\ move $ra, $zero
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -176,7 +177,11 @@ pub fn clone() callconv(.Naked) usize {
\\ \\
\\ #else: we're the child \\ #else: we're the child
\\ 2: \\ 2:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined lr \\ .cfi_undefined lr
);
asm volatile (
\\ li 31, 0 \\ li 31, 0
\\ mtlr 0 \\ mtlr 0
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -161,7 +162,11 @@ pub fn clone() callconv(.Naked) usize {
\\ bnelr cr7 \\ bnelr cr7
\\ \\
\\ # we're the child \\ # we're the child
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined lr \\ .cfi_undefined lr
);
asm volatile (
\\ li 31, 0 \\ li 31, 0
\\ mtlr 0 \\ mtlr 0
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const iovec = std.posix.iovec; const iovec = std.posix.iovec;
const iovec_const = std.posix.iovec_const; const iovec_const = std.posix.iovec_const;
@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {
\\ ret \\ ret
\\ \\
\\ # Child \\ # Child
\\1: .cfi_undefined ra \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined ra
);
asm volatile (
\\ mv fp, zero \\ mv fp, zero
\\ mv ra, zero \\ mv ra, zero
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const iovec = std.posix.iovec; const iovec = std.posix.iovec;
const iovec_const = std.posix.iovec_const; const iovec_const = std.posix.iovec_const;
@ -120,7 +121,12 @@ pub fn clone() callconv(.Naked) usize {
\\ ret \\ ret
\\ \\
\\ # Child \\ # Child
\\1: .cfi_undefined ra \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined ra
);
asm volatile (
\\ mv fp, zero \\ mv fp, zero
\\ mv ra, zero \\ mv ra, zero
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const iovec = std.posix.iovec; const iovec = std.posix.iovec;
const iovec_const = std.posix.iovec_const; const iovec_const = std.posix.iovec_const;
@ -134,7 +135,11 @@ pub fn clone() callconv(.Naked) usize {
\\bnzr %%r14 \\bnzr %%r14
\\ \\
\\# we're the child \\# we're the child
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\.cfi_undefined %%r14 \\.cfi_undefined %%r14
);
asm volatile (
\\lghi %%r11, 0 \\lghi %%r11, 0
\\lghi %%r14, 0 \\lghi %%r14, 0
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const pid_t = linux.pid_t; const pid_t = linux.pid_t;
@ -215,7 +216,11 @@ pub fn clone() callconv(.Naked) usize {
\\ restore \\ restore
\\2: \\2:
\\ # Child process \\ # Child process
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined %%i7 \\ .cfi_undefined %%i7
);
asm volatile (
\\ mov %%g0, %%fp \\ mov %%g0, %%fp
\\ mov %%g0, %%i7 \\ mov %%g0, %%i7
\\ \\

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -156,7 +157,11 @@ pub fn clone() callconv(.Naked) usize {
\\ retl \\ retl
\\ \\
\\1: \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined %%eip \\ .cfi_undefined %%eip
);
asm volatile (
\\ xorl %%ebp,%%ebp \\ xorl %%ebp,%%ebp
\\ \\
\\ popl %%eax \\ popl %%eax

View File

@ -1,3 +1,4 @@
const builtin = @import("builtin");
const std = @import("../../std.zig"); const std = @import("../../std.zig");
const maxInt = std.math.maxInt; const maxInt = std.math.maxInt;
const linux = std.os.linux; const linux = std.os.linux;
@ -117,7 +118,12 @@ pub fn clone() callconv(.Naked) usize {
\\ jz 1f \\ jz 1f
\\ retq \\ retq
\\ \\
\\1: .cfi_undefined %%rip \\1:
);
if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
\\ .cfi_undefined %%rip
);
asm volatile (
\\ xorl %%ebp,%%ebp \\ xorl %%ebp,%%ebp
\\ \\
\\ popq %%rdi \\ popq %%rdi