mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
link-test: add matching test case for unwind info when MH_SUBSECTIONS_VIA_SYMBOLS is not set
This commit is contained in:
parent
d6e095de2c
commit
16f09127b5
5 changed files with 120 additions and 0 deletions
|
|
@ -96,6 +96,10 @@ pub const cases = [_]Case{
|
|||
.build_root = "test/link/macho/bugs/16308",
|
||||
.import = @import("link/macho/bugs/16308/build.zig"),
|
||||
},
|
||||
.{
|
||||
.build_root = "test/link/macho/bugs/16628",
|
||||
.import = @import("link/macho/bugs/16628/build.zig"),
|
||||
},
|
||||
.{
|
||||
.build_root = "test/link/macho/dead_strip",
|
||||
.import = @import("link/macho/dead_strip/build.zig"),
|
||||
|
|
|
|||
37
test/link/macho/bugs/16628/a_arm64.s
Normal file
37
test/link/macho/bugs/16628/a_arm64.s
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
.globl _foo
|
||||
.align 4
|
||||
_foo:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, #-32]!
|
||||
.cfi_def_cfa_offset 32
|
||||
.cfi_offset w30, -24
|
||||
.cfi_offset w29, -32
|
||||
mov x29, sp
|
||||
.cfi_def_cfa w29, 32
|
||||
bl _bar
|
||||
ldp x29, x30, [sp], #32
|
||||
.cfi_restore w29
|
||||
.cfi_restore w30
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
|
||||
.globl _bar
|
||||
.align 4
|
||||
_bar:
|
||||
.cfi_startproc
|
||||
sub sp, sp, #32
|
||||
.cfi_def_cfa_offset -32
|
||||
stp x29, x30, [sp, #16]
|
||||
.cfi_offset w30, -24
|
||||
.cfi_offset w29, -32
|
||||
mov x29, sp
|
||||
.cfi_def_cfa w29, 32
|
||||
mov w0, #4
|
||||
ldp x29, x30, [sp, #16]
|
||||
.cfi_restore w29
|
||||
.cfi_restore w30
|
||||
add sp, sp, #32
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
29
test/link/macho/bugs/16628/a_x64.s
Normal file
29
test/link/macho/bugs/16628/a_x64.s
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
.globl _foo
|
||||
_foo:
|
||||
.cfi_startproc
|
||||
push %rbp
|
||||
.cfi_def_cfa_offset 8
|
||||
.cfi_offset %rbp, -8
|
||||
mov %rsp, %rbp
|
||||
.cfi_def_cfa_register %rbp
|
||||
call _bar
|
||||
pop %rbp
|
||||
.cfi_restore %rbp
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
|
||||
.globl _bar
|
||||
_bar:
|
||||
.cfi_startproc
|
||||
push %rbp
|
||||
.cfi_def_cfa_offset 8
|
||||
.cfi_offset %rbp, -8
|
||||
mov %rsp, %rbp
|
||||
.cfi_def_cfa_register %rbp
|
||||
mov $4, %rax
|
||||
pop %rbp
|
||||
.cfi_restore %rbp
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
42
test/link/macho/bugs/16628/build.zig
Normal file
42
test/link/macho/bugs/16628/build.zig
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const requires_symlinks = true;
|
||||
pub const requires_macos_sdk = false;
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const test_step = b.step("test", "Test it");
|
||||
b.default_step = test_step;
|
||||
|
||||
add(b, test_step, .Debug);
|
||||
add(b, test_step, .ReleaseFast);
|
||||
add(b, test_step, .ReleaseSmall);
|
||||
add(b, test_step, .ReleaseSafe);
|
||||
}
|
||||
|
||||
fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
|
||||
const target: std.zig.CrossTarget = .{ .os_tag = .macos };
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "test",
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
});
|
||||
exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} });
|
||||
switch (builtin.cpu.arch) {
|
||||
.aarch64 => {
|
||||
exe.addCSourceFile(.{ .file = .{ .path = "a_arm64.s" }, .flags = &[0][]const u8{} });
|
||||
},
|
||||
.x86_64 => {
|
||||
exe.addCSourceFile(.{ .file = .{ .path = "a_x64.s" }, .flags = &[0][]const u8{} });
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
exe.linkLibC();
|
||||
|
||||
const run = b.addRunArtifact(exe);
|
||||
run.skip_foreign_checks = true;
|
||||
run.expectStdOutEqual("4\n");
|
||||
|
||||
test_step.dependOn(&run.step);
|
||||
}
|
||||
8
test/link/macho/bugs/16628/main.c
Normal file
8
test/link/macho/bugs/16628/main.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int foo();
|
||||
|
||||
int main() {
|
||||
printf("%d\n", foo());
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue