authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-14 10:59:47+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
log9f0e1ab467a2214efb97d340c733fa1da4e708c7
treee79d51ad1eb3cb6f427148ff7463a8e151d4ceb4
parent5790e89b5aa5c8a939ea92e76a0a88655c4f55d4

test/link/macho: test thunks on arm64


1 files changed, 34 insertions(+), 0 deletions(-)

test/link/macho.zig+34
......@@ -11,6 +11,10 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
1111 .cpu_arch = .x86_64,
1212 .os_tag = .macos,
1313 });
14 const aarch64_target = b.resolveTargetQuery(.{
15 .cpu_arch = .aarch64,
16 .os_tag = .macos,
17 });
1418
1519 macho_step.dependOn(testDeadStrip(b, .{ .target = default_target }));
1620 macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));
......@@ -21,6 +25,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
2125 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
2226 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
2327 macho_step.dependOn(testSegmentBoundarySymbols(b, .{ .target = default_target }));
28 macho_step.dependOn(testThunks(b, .{ .target = aarch64_target }));
2429 macho_step.dependOn(testTlsLargeTbss(b, .{ .target = default_target }));
2530 macho_step.dependOn(testUndefinedFlag(b, .{ .target = default_target }));
2631 macho_step.dependOn(testWeakBind(b, .{ .target = x86_64_target }));
......@@ -639,6 +644,35 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
639644 return test_step;
640645}
641646
647fn testThunks(b: *Build, opts: Options) *Step {
648 const test_step = addTestStep(b, "macho-thunks", opts);
649
650 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
651 \\#include <stdio.h>
652 \\__attribute__((aligned(0x8000000))) int bar() {
653 \\ return 42;
654 \\}
655 \\int foobar();
656 \\int foo() {
657 \\ return bar() - foobar();
658 \\}
659 \\__attribute__((aligned(0x8000000))) int foobar() {
660 \\ return 42;
661 \\}
662 \\int main() {
663 \\ printf("bar=%d, foo=%d, foobar=%d", bar(), foo(), foobar());
664 \\ return foo();
665 \\}
666 });
667
668 const run = addRunArtifact(exe);
669 run.expectStdOutEqual("bar=42, foo=0, foobar=42");
670 run.expectExitCode(0);
671 test_step.dependOn(&run.step);
672
673 return test_step;
674}
675
642676fn testTlsLargeTbss(b: *Build, opts: Options) *Step {
643677 const test_step = addTestStep(b, "macho-tls-large-tbss", opts);
644678