Skip to content

Commit

Permalink
Merge pull request #92 from kubkon/arm64-baby-steps
Browse files Browse the repository at this point in the history
macho: more arm64 tests
  • Loading branch information
kubkon authored Dec 19, 2023
2 parents a547822 + 4cd2037 commit 1836619
Showing 1 changed file with 48 additions and 22 deletions.
70 changes: 48 additions & 22 deletions test/macho.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,6 @@ fn testHeaderpad(b: *Build, opts: Options) *Step {
fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
const test_step = b.step("test-macho-header-weak-flags", "");

if (builtin.target.cpu.arch != .x86_64) return skipTestStep(test_step); // TODO

const obj1 = cc(b, opts);
obj1.addAsmSource(
\\.globl _x
Expand Down Expand Up @@ -1220,14 +1218,28 @@ fn testHeaderWeakFlags(b: *Build, opts: Options) *Step {
}

{
const obj = cc(b, opts);
obj.addArg("-c");

switch (builtin.target.cpu.arch) {
.aarch64 => obj.addAsmSource(
\\.globl _main
\\_main:
\\ bl _x
\\ ret
),
.x86_64 => obj.addAsmSource(
\\.globl _main
\\_main:
\\ callq _x
\\ ret
),
else => unreachable,
}

const exe = cc(b, opts);
exe.addFileSource(lib.out);
exe.addAsmSource(
\\.globl _main
\\_main:
\\ callq _x
\\ ret
);
exe.addFileSource(obj.out);

const check = exe.check();
check.checkInHeaders();
Expand Down Expand Up @@ -2234,8 +2246,6 @@ fn testStackSize(b: *Build, opts: Options) *Step {
fn testSymbolStabs(b: *Build, opts: Options) *Step {
const test_step = b.step("test-macho-symbol-stabs", "");

if (builtin.target.cpu.arch != .x86_64) return skipTestStep(test_step); // TODO

const a_o = cc(b, opts);
a_o.addCSource(
\\int x;
Expand All @@ -2249,20 +2259,36 @@ fn testSymbolStabs(b: *Build, opts: Options) *Step {
a_o.addArgs(&.{ "-c", "-g" });

const b_o = cc(b, opts);
b_o.addAsmSource(
\\.globl _foo
\\_foo:
\\ mov $42, %rax
\\ ret
\\.globl _bar
\\_bar:
\\ sub $8, %rsp
\\ call _foo
\\ add $8, %rsp
\\ ret
);
b_o.addArgs(&.{ "-c", "-g" });

switch (builtin.target.cpu.arch) {
.aarch64 => b_o.addAsmSource(
\\.globl _foo
\\_foo:
\\ mov x0, #42
\\ ret
\\.globl _bar
\\_bar:
\\ stp fp, lr, [sp, #-0x10]!
\\ bl _foo
\\ ldp fp, lr, [sp], #0x10
\\ ret
),
.x86_64 => b_o.addAsmSource(
\\.globl _foo
\\_foo:
\\ mov $42, %rax
\\ ret
\\.globl _bar
\\_bar:
\\ sub $8, %rsp
\\ call _foo
\\ add $8, %rsp
\\ ret
),
else => unreachable,
}

const exe = cc(b, opts);
exe.addCSource(
\\#include <stdio.h>
Expand Down

0 comments on commit 1836619

Please sign in to comment.