target: emit unwind tables if the platform supports unwinding

This commit is contained in:
kcbanner 2023-07-26 01:26:26 -04:00
parent f2aab12a86
commit 661028a907
3 changed files with 20 additions and 9 deletions

View File

@ -1656,7 +1656,7 @@ pub const DwarfInfo = struct {
/// `explicit_fde_offset` is for cases where the FDE offset is known, such as when __unwind_info
/// defers unwinding to DWARF. This is an offset into the `.eh_frame` section.
pub fn unwindFrame(di: *const DwarfInfo, context: *UnwindContext, explicit_fde_offset: ?usize) !usize {
if (!comptime abi.isSupportedArch(builtin.target.cpu.arch)) return error.UnsupportedCpuArchitecture;
if (!comptime abi.supportsUnwinding(builtin.target)) return error.UnsupportedCpuArchitecture;
if (context.pc == 0) return 0;
// Find the FDE and CIE

View File

@ -3,13 +3,24 @@ const std = @import("../std.zig");
const os = std.os;
const mem = std.mem;
pub fn isSupportedArch(arch: std.Target.Cpu.Arch) bool {
return switch (arch) {
.x86,
.x86_64,
.arm,
.aarch64,
=> true,
pub fn supportsUnwinding(target: std.Target) bool {
return switch (target.cpu.arch) {
.x86 => switch (target.os.tag) {
.linux, .netbsd, .solaris => true,
else => false,
},
.x86_64 => switch (target.os.tag) {
.linux, .netbsd, .freebsd, .openbsd, .macos, .solaris => true,
else => false,
},
.arm => switch (target.os.tag) {
.linux => true,
else => false,
},
.aarch64 => switch (target.os.tag) {
.linux, .netbsd, .freebsd, .macos => true,
else => false,
},
else => false,
};
}

View File

@ -510,7 +510,7 @@ pub fn clangAssemblerSupportsMcpuArg(target: std.Target) bool {
}
pub fn needUnwindTables(target: std.Target) bool {
return target.os.tag == .windows or target.isDarwin();
return target.os.tag == .windows or target.isDarwin() or std.dwarf.abi.supportsUnwinding(target);
}
pub fn defaultAddressSpace(