commit 23a63f4ce445d26d7fc577eecc6c3f5ca129a007 (tree)
parent b5601a2da60df2f8f2bc6ac1ef287d4733a47df2
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Wed, 22 Jun 2022 10:27:51 +0200
link-tests: rename CheckMachOStep to CheckObjectStep and accept obj format
Diffstat:
8 files changed, 366 insertions(+), 342 deletions(-)
diff --git a/lib/std/build.zig b/lib/std/build.zig
@@ -24,7 +24,7 @@ pub const TranslateCStep = @import("build/TranslateCStep.zig");
pub const WriteFileStep = @import("build/WriteFileStep.zig");
pub const RunStep = @import("build/RunStep.zig");
pub const CheckFileStep = @import("build/CheckFileStep.zig");
-pub const CheckMachOStep = @import("build/CheckMachOStep.zig");
+pub const CheckObjectStep = @import("build/CheckObjectStep.zig");
pub const InstallRawStep = @import("build/InstallRawStep.zig");
pub const OptionsStep = @import("build/OptionsStep.zig");
@@ -1865,8 +1865,8 @@ pub const LibExeObjStep = struct {
return run_step;
}
- pub fn checkMachO(self: *LibExeObjStep) *CheckMachOStep {
- return CheckMachOStep.create(self.builder, self.getOutputSource());
+ pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
+ return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);
}
pub fn setLinkerScriptPath(self: *LibExeObjStep, source: FileSource) void {
@@ -3455,7 +3455,7 @@ pub const Step = struct {
write_file,
run,
check_file,
- check_macho,
+ check_object,
install_raw,
options,
custom,
diff --git a/lib/std/build/CheckMachOStep.zig b/lib/std/build/CheckMachOStep.zig
@@ -1,331 +0,0 @@
-const std = @import("../std.zig");
-const assert = std.debug.assert;
-const build = std.build;
-const fs = std.fs;
-const macho = std.macho;
-const mem = std.mem;
-
-const CheckMachOStep = @This();
-
-const Allocator = mem.Allocator;
-const Builder = build.Builder;
-const Step = build.Step;
-
-pub const base_id = .check_macho;
-
-step: Step,
-builder: *Builder,
-source: build.FileSource,
-max_bytes: usize = 20 * 1024 * 1024,
-checks: std.ArrayList(Check),
-dump_symtab: bool = false,
-
-pub fn create(builder: *Builder, source: build.FileSource) *CheckMachOStep {
- const gpa = builder.allocator;
- const self = gpa.create(CheckMachOStep) catch unreachable;
- self.* = CheckMachOStep{
- .builder = builder,
- .step = Step.init(.check_file, "CheckMachO", gpa, make),
- .source = source.dupe(builder),
- .checks = std.ArrayList(Check).init(gpa),
- };
- self.source.addStepDependencies(&self.step);
- return self;
-}
-
-const Action = union(enum) {
- exact_match: []const u8,
- extract_var: struct {
- fuzzy_match: []const u8,
- var_name: []const u8,
- var_value: u64,
- },
- compare: CompareAction,
-};
-
-const CompareAction = struct {
- expected: union(enum) {
- literal: u64,
- varr: []const u8,
- },
- var_stack: std.ArrayList([]const u8),
- op_stack: std.ArrayList(Op),
-
- const Op = enum {
- add,
- };
-};
-
-const Check = struct {
- builder: *Builder,
- actions: std.ArrayList(Action),
-
- fn create(b: *Builder) Check {
- return .{
- .builder = b,
- .actions = std.ArrayList(Action).init(b.allocator),
- };
- }
-
- fn exactMatch(self: *Check, phrase: []const u8) void {
- self.actions.append(.{
- .exact_match = self.builder.dupe(phrase),
- }) catch unreachable;
- }
-
- fn extractVar(self: *Check, phrase: []const u8, var_name: []const u8) void {
- self.actions.append(.{
- .extract_var = .{
- .fuzzy_match = self.builder.dupe(phrase),
- .var_name = self.builder.dupe(var_name),
- .var_value = undefined,
- },
- }) catch unreachable;
- }
-};
-
-pub fn check(self: *CheckMachOStep, phrase: []const u8) void {
- var new_check = Check.create(self.builder);
- new_check.exactMatch(phrase);
- self.checks.append(new_check) catch unreachable;
-}
-
-pub fn checkNext(self: *CheckMachOStep, phrase: []const u8) void {
- assert(self.checks.items.len > 0);
- const last = &self.checks.items[self.checks.items.len - 1];
- last.exactMatch(phrase);
-}
-
-pub fn checkNextExtract(self: *CheckMachOStep, comptime phrase: []const u8) void {
- assert(self.checks.items.len > 0);
- const matcher_start = comptime mem.indexOf(u8, phrase, "{") orelse
- @compileError("missing { } matcher");
- const matcher_end = comptime mem.indexOf(u8, phrase, "}") orelse
- @compileError("missing { } matcher");
- const last = &self.checks.items[self.checks.items.len - 1];
- last.extractVar(phrase[0..matcher_start], phrase[matcher_start + 1 .. matcher_end]);
-}
-
-pub fn checkInSymtab(self: *CheckMachOStep) void {
- self.dump_symtab = true;
- self.check("symtab");
-}
-
-pub fn checkCompare(self: *CheckMachOStep, comptime phrase: []const u8, expected: anytype) void {
- comptime assert(phrase[0] == '{');
- comptime assert(phrase[phrase.len - 1] == '}');
-
- const gpa = self.builder.allocator;
- var ca = CompareAction{
- .expected = expected,
- .var_stack = std.ArrayList([]const u8).init(gpa),
- .op_stack = std.ArrayList(CompareAction.Op).init(gpa),
- };
-
- var it = mem.tokenize(u8, phrase[1 .. phrase.len - 1], " ");
- while (it.next()) |next| {
- if (mem.eql(u8, next, "+")) {
- ca.op_stack.append(.add) catch unreachable;
- } else {
- ca.var_stack.append(self.builder.dupe(next)) catch unreachable;
- }
- }
-
- var new_check = Check.create(self.builder);
- new_check.actions.append(.{ .compare = ca }) catch unreachable;
- self.checks.append(new_check) catch unreachable;
-}
-
-fn make(step: *Step) !void {
- const self = @fieldParentPtr(CheckMachOStep, "step", step);
-
- const gpa = self.builder.allocator;
- const src_path = self.source.getPath(self.builder);
- const contents = try fs.cwd().readFileAlloc(gpa, src_path, self.max_bytes);
-
- // Parse the object file's header
- var stream = std.io.fixedBufferStream(contents);
- const reader = stream.reader();
-
- const hdr = try reader.readStruct(macho.mach_header_64);
- if (hdr.magic != macho.MH_MAGIC_64) {
- return error.InvalidMagicNumber;
- }
-
- var metadata = std.ArrayList(u8).init(gpa);
- const writer = metadata.writer();
-
- var symtab_cmd: ?macho.symtab_command = null;
- var i: u16 = 0;
- while (i < hdr.ncmds) : (i += 1) {
- var cmd = try macho.LoadCommand.read(gpa, reader);
-
- if (self.dump_symtab and cmd.cmd() == .SYMTAB) {
- symtab_cmd = cmd.symtab;
- }
-
- try dumpLoadCommand(cmd, i, writer);
- try writer.writeByte('\n');
- }
-
- if (symtab_cmd) |cmd| {
- try writer.writeAll("symtab\n");
- const strtab = contents[cmd.stroff..][0..cmd.strsize];
- const symtab = @ptrCast(
- [*]const macho.nlist_64,
- @alignCast(@alignOf(macho.nlist_64), contents.ptr + cmd.symoff),
- )[0..cmd.nsyms];
-
- for (symtab) |sym| {
- if (sym.stab()) continue;
- const sym_name = mem.sliceTo(@ptrCast([*:0]const u8, strtab.ptr + sym.n_strx), 0);
- try writer.print("{s} {x}\n", .{ sym_name, sym.n_value });
- }
- }
-
- var vars = std.StringHashMap(u64).init(gpa);
-
- for (self.checks.items) |chk| {
- const first_action = chk.actions.items[0];
-
- switch (first_action) {
- .exact_match => |first| {
- if (mem.indexOf(u8, metadata.items, first)) |index| {
- // TODO backtrack to track current scope
- var it = std.mem.tokenize(u8, metadata.items[index..], "\r\n");
-
- outer: for (chk.actions.items[1..]) |next_action| {
- switch (next_action) {
- .exact_match => |exact| {
- while (it.next()) |line| {
- if (mem.eql(u8, line, exact)) {
- std.debug.print("{s} == {s}\n", .{ line, exact });
- continue :outer;
- }
- std.debug.print("{s} != {s}\n", .{ line, exact });
- } else {
- return error.TestFailed;
- }
- },
- .extract_var => |extract| {
- const phrase = extract.fuzzy_match;
- while (it.next()) |line| {
- if (mem.indexOf(u8, line, phrase)) |found| {
- std.debug.print("{s} in {s}\n", .{ phrase, line });
- // Extract variable and save back in the action.
- const trimmed = mem.trim(u8, line[found + phrase.len ..], " ");
- const parsed = try std.fmt.parseInt(u64, trimmed, 16);
- try vars.putNoClobber(extract.var_name, parsed);
- continue :outer;
- }
- std.debug.print("{s} not in {s}\n", .{ extract.fuzzy_match, line });
- }
- },
- .compare => unreachable,
- }
- }
- } else {
- return error.TestFailed;
- }
- },
- .compare => |act| {
- var values = std.ArrayList(u64).init(gpa);
- try values.ensureTotalCapacity(act.var_stack.items.len);
- for (act.var_stack.items) |vv| {
- const val = vars.get(vv) orelse return error.TestFailed;
- values.appendAssumeCapacity(val);
- }
-
- var op_i: usize = 1;
- var reduced: u64 = values.items[0];
- for (act.op_stack.items) |op| {
- const other = values.items[op_i];
- switch (op) {
- .add => {
- reduced += other;
- },
- }
- }
-
- const expected = switch (act.expected) {
- .literal => |exp| exp,
- .varr => |vv| vars.get(vv) orelse return error.TestFailed,
- };
- if (reduced != expected) return error.TestFailed;
- },
- .extract_var => unreachable,
- }
- }
-
- var it = vars.iterator();
- while (it.next()) |entry| {
- std.debug.print(" {s} => {x}", .{ entry.key_ptr.*, entry.value_ptr.* });
- }
-}
-
-fn dumpLoadCommand(lc: macho.LoadCommand, index: u16, writer: anytype) !void {
- // print header first
- try writer.print(
- \\LC {d}
- \\cmd {s}
- \\cmdsize {d}
- , .{ index, @tagName(lc.cmd()), lc.cmdsize() });
-
- switch (lc.cmd()) {
- .SEGMENT_64 => {
- // TODO dump section headers
- const seg = lc.segment.inner;
- try writer.writeByte('\n');
- try writer.print(
- \\segname {s}
- \\vmaddr {x}
- \\vmsize {x}
- \\fileoff {x}
- \\filesz {x}
- , .{
- seg.segName(),
- seg.vmaddr,
- seg.vmsize,
- seg.fileoff,
- seg.filesize,
- });
- },
-
- .ID_DYLIB,
- .LOAD_DYLIB,
- => {
- const dylib = lc.dylib.inner.dylib;
- try writer.writeByte('\n');
- try writer.print(
- \\path {s}
- \\timestamp {d}
- \\current version {x}
- \\compatibility version {x}
- , .{
- mem.sliceTo(lc.dylib.data, 0),
- dylib.timestamp,
- dylib.current_version,
- dylib.compatibility_version,
- });
- },
-
- .MAIN => {
- try writer.writeByte('\n');
- try writer.print(
- \\entryoff {x}
- \\stacksize {x}
- , .{ lc.main.entryoff, lc.main.stacksize });
- },
-
- .RPATH => {
- try writer.writeByte('\n');
- try writer.print(
- \\path {s}
- , .{
- mem.sliceTo(lc.rpath.data, 0),
- });
- },
-
- else => {},
- }
-}
diff --git a/lib/std/build/CheckObjectStep.zig b/lib/std/build/CheckObjectStep.zig
@@ -0,0 +1,355 @@
+const std = @import("../std.zig");
+const assert = std.debug.assert;
+const build = std.build;
+const fs = std.fs;
+const macho = std.macho;
+const mem = std.mem;
+
+const CheckObjectStep = @This();
+
+const Allocator = mem.Allocator;
+const Builder = build.Builder;
+const Step = build.Step;
+
+pub const base_id = .check_obj;
+
+step: Step,
+builder: *Builder,
+source: build.FileSource,
+max_bytes: usize = 20 * 1024 * 1024,
+checks: std.ArrayList(Check),
+dump_symtab: bool = false,
+obj_format: std.Target.ObjectFormat,
+
+pub fn create(builder: *Builder, source: build.FileSource, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
+ const gpa = builder.allocator;
+ const self = gpa.create(CheckObjectStep) catch unreachable;
+ self.* = .{
+ .builder = builder,
+ .step = Step.init(.check_file, "CheckObject", gpa, make),
+ .source = source.dupe(builder),
+ .checks = std.ArrayList(Check).init(gpa),
+ .obj_format = obj_format,
+ };
+ self.source.addStepDependencies(&self.step);
+ return self;
+}
+
+const Action = union(enum) {
+ exact_match: []const u8,
+ extract_var: struct {
+ fuzzy_match: []const u8,
+ var_name: []const u8,
+ var_value: u64,
+ },
+ compare: CompareAction,
+};
+
+const CompareAction = struct {
+ expected: union(enum) {
+ literal: u64,
+ varr: []const u8,
+ },
+ var_stack: std.ArrayList([]const u8),
+ op_stack: std.ArrayList(Op),
+
+ const Op = enum {
+ add,
+ };
+};
+
+const Check = struct {
+ builder: *Builder,
+ actions: std.ArrayList(Action),
+
+ fn create(b: *Builder) Check {
+ return .{
+ .builder = b,
+ .actions = std.ArrayList(Action).init(b.allocator),
+ };
+ }
+
+ fn exactMatch(self: *Check, phrase: []const u8) void {
+ self.actions.append(.{
+ .exact_match = self.builder.dupe(phrase),
+ }) catch unreachable;
+ }
+
+ fn extractVar(self: *Check, phrase: []const u8, var_name: []const u8) void {
+ self.actions.append(.{
+ .extract_var = .{
+ .fuzzy_match = self.builder.dupe(phrase),
+ .var_name = self.builder.dupe(var_name),
+ .var_value = undefined,
+ },
+ }) catch unreachable;
+ }
+};
+
+pub fn check(self: *CheckObjectStep, phrase: []const u8) void {
+ var new_check = Check.create(self.builder);
+ new_check.exactMatch(phrase);
+ self.checks.append(new_check) catch unreachable;
+}
+
+pub fn checkNext(self: *CheckObjectStep, phrase: []const u8) void {
+ assert(self.checks.items.len > 0);
+ const last = &self.checks.items[self.checks.items.len - 1];
+ last.exactMatch(phrase);
+}
+
+pub fn checkNextExtract(self: *CheckObjectStep, comptime phrase: []const u8) void {
+ assert(self.checks.items.len > 0);
+ const matcher_start = comptime mem.indexOf(u8, phrase, "{") orelse
+ @compileError("missing { } matcher");
+ const matcher_end = comptime mem.indexOf(u8, phrase, "}") orelse
+ @compileError("missing { } matcher");
+ const last = &self.checks.items[self.checks.items.len - 1];
+ last.extractVar(phrase[0..matcher_start], phrase[matcher_start + 1 .. matcher_end]);
+}
+
+pub fn checkInSymtab(self: *CheckObjectStep) void {
+ self.dump_symtab = true;
+ self.check("symtab");
+}
+
+pub fn checkCompare(self: *CheckObjectStep, comptime phrase: []const u8, expected: anytype) void {
+ comptime assert(phrase[0] == '{');
+ comptime assert(phrase[phrase.len - 1] == '}');
+
+ const gpa = self.builder.allocator;
+ var ca = CompareAction{
+ .expected = expected,
+ .var_stack = std.ArrayList([]const u8).init(gpa),
+ .op_stack = std.ArrayList(CompareAction.Op).init(gpa),
+ };
+
+ var it = mem.tokenize(u8, phrase[1 .. phrase.len - 1], " ");
+ while (it.next()) |next| {
+ if (mem.eql(u8, next, "+")) {
+ ca.op_stack.append(.add) catch unreachable;
+ } else {
+ ca.var_stack.append(self.builder.dupe(next)) catch unreachable;
+ }
+ }
+
+ var new_check = Check.create(self.builder);
+ new_check.actions.append(.{ .compare = ca }) catch unreachable;
+ self.checks.append(new_check) catch unreachable;
+}
+
+fn make(step: *Step) !void {
+ const self = @fieldParentPtr(CheckObjectStep, "step", step);
+
+ const gpa = self.builder.allocator;
+ const src_path = self.source.getPath(self.builder);
+ const contents = try fs.cwd().readFileAlloc(gpa, src_path, self.max_bytes);
+
+ const output = switch (self.obj_format) {
+ .macho => try MachODumper.parseAndDump(contents, .{
+ .gpa = gpa,
+ .dump_symtab = self.dump_symtab,
+ }),
+ .elf => @panic("TODO elf parser"),
+ .coff => @panic("TODO coff parser"),
+ .wasm => @panic("TODO wasm parser"),
+ else => unreachable,
+ };
+
+ var vars = std.StringHashMap(u64).init(gpa);
+
+ for (self.checks.items) |chk| {
+ const first_action = chk.actions.items[0];
+
+ switch (first_action) {
+ .exact_match => |first| {
+ if (mem.indexOf(u8, output, first)) |index| {
+ // TODO backtrack to track current scope
+ var it = std.mem.tokenize(u8, output[index..], "\r\n");
+
+ outer: for (chk.actions.items[1..]) |next_action| {
+ switch (next_action) {
+ .exact_match => |exact| {
+ while (it.next()) |line| {
+ if (mem.eql(u8, line, exact)) {
+ std.debug.print("{s} == {s}\n", .{ line, exact });
+ continue :outer;
+ }
+ std.debug.print("{s} != {s}\n", .{ line, exact });
+ } else {
+ return error.TestFailed;
+ }
+ },
+ .extract_var => |extract| {
+ const phrase = extract.fuzzy_match;
+ while (it.next()) |line| {
+ if (mem.indexOf(u8, line, phrase)) |found| {
+ std.debug.print("{s} in {s}\n", .{ phrase, line });
+ // Extract variable and save back in the action.
+ const trimmed = mem.trim(u8, line[found + phrase.len ..], " ");
+ const parsed = try std.fmt.parseInt(u64, trimmed, 16);
+ try vars.putNoClobber(extract.var_name, parsed);
+ continue :outer;
+ }
+ std.debug.print("{s} not in {s}\n", .{ extract.fuzzy_match, line });
+ }
+ },
+ .compare => unreachable,
+ }
+ }
+ } else {
+ return error.TestFailed;
+ }
+ },
+ .compare => |act| {
+ var values = std.ArrayList(u64).init(gpa);
+ try values.ensureTotalCapacity(act.var_stack.items.len);
+ for (act.var_stack.items) |vv| {
+ const val = vars.get(vv) orelse return error.TestFailed;
+ values.appendAssumeCapacity(val);
+ }
+
+ var op_i: usize = 1;
+ var reduced: u64 = values.items[0];
+ for (act.op_stack.items) |op| {
+ const other = values.items[op_i];
+ switch (op) {
+ .add => {
+ reduced += other;
+ },
+ }
+ }
+
+ const expected = switch (act.expected) {
+ .literal => |exp| exp,
+ .varr => |vv| vars.get(vv) orelse return error.TestFailed,
+ };
+ if (reduced != expected) return error.TestFailed;
+ },
+ .extract_var => unreachable,
+ }
+ }
+
+ var it = vars.iterator();
+ while (it.next()) |entry| {
+ std.debug.print(" {s} => {x}", .{ entry.key_ptr.*, entry.value_ptr.* });
+ }
+}
+
+const Opts = struct {
+ gpa: ?Allocator = null,
+ dump_symtab: bool = false,
+};
+
+const MachODumper = struct {
+ fn parseAndDump(bytes: []const u8, opts: Opts) ![]const u8 {
+ const gpa = opts.gpa orelse unreachable; // MachO dumper requires an allocator
+ var stream = std.io.fixedBufferStream(bytes);
+ const reader = stream.reader();
+
+ const hdr = try reader.readStruct(macho.mach_header_64);
+ if (hdr.magic != macho.MH_MAGIC_64) {
+ return error.InvalidMagicNumber;
+ }
+
+ var output = std.ArrayList(u8).init(gpa);
+ const writer = output.writer();
+
+ var symtab_cmd: ?macho.symtab_command = null;
+ var i: u16 = 0;
+ while (i < hdr.ncmds) : (i += 1) {
+ var cmd = try macho.LoadCommand.read(gpa, reader);
+
+ if (opts.dump_symtab and cmd.cmd() == .SYMTAB) {
+ symtab_cmd = cmd.symtab;
+ }
+
+ try dumpLoadCommand(cmd, i, writer);
+ try writer.writeByte('\n');
+ }
+
+ if (symtab_cmd) |cmd| {
+ try writer.writeAll("symtab\n");
+ const strtab = bytes[cmd.stroff..][0..cmd.strsize];
+ const symtab = @ptrCast(
+ [*]const macho.nlist_64,
+ @alignCast(@alignOf(macho.nlist_64), bytes.ptr + cmd.symoff),
+ )[0..cmd.nsyms];
+
+ for (symtab) |sym| {
+ if (sym.stab()) continue;
+ const sym_name = mem.sliceTo(@ptrCast([*:0]const u8, strtab.ptr + sym.n_strx), 0);
+ try writer.print("{s} {x}\n", .{ sym_name, sym.n_value });
+ }
+ }
+
+ return output.toOwnedSlice();
+ }
+
+ fn dumpLoadCommand(lc: macho.LoadCommand, index: u16, writer: anytype) !void {
+ // print header first
+ try writer.print(
+ \\LC {d}
+ \\cmd {s}
+ \\cmdsize {d}
+ , .{ index, @tagName(lc.cmd()), lc.cmdsize() });
+
+ switch (lc.cmd()) {
+ .SEGMENT_64 => {
+ // TODO dump section headers
+ const seg = lc.segment.inner;
+ try writer.writeByte('\n');
+ try writer.print(
+ \\segname {s}
+ \\vmaddr {x}
+ \\vmsize {x}
+ \\fileoff {x}
+ \\filesz {x}
+ , .{
+ seg.segName(),
+ seg.vmaddr,
+ seg.vmsize,
+ seg.fileoff,
+ seg.filesize,
+ });
+ },
+
+ .ID_DYLIB,
+ .LOAD_DYLIB,
+ => {
+ const dylib = lc.dylib.inner.dylib;
+ try writer.writeByte('\n');
+ try writer.print(
+ \\path {s}
+ \\timestamp {d}
+ \\current version {x}
+ \\compatibility version {x}
+ , .{
+ mem.sliceTo(lc.dylib.data, 0),
+ dylib.timestamp,
+ dylib.current_version,
+ dylib.compatibility_version,
+ });
+ },
+
+ .MAIN => {
+ try writer.writeByte('\n');
+ try writer.print(
+ \\entryoff {x}
+ \\stacksize {x}
+ , .{ lc.main.entryoff, lc.main.stacksize });
+ },
+
+ .RPATH => {
+ try writer.writeByte('\n');
+ try writer.print(
+ \\path {s}
+ , .{
+ mem.sliceTo(lc.rpath.data, 0),
+ });
+ },
+
+ else => {},
+ }
+ }
+};
diff --git a/test/link.zig b/test/link.zig
@@ -28,7 +28,7 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
});
if (builtin.os.tag == .macos) {
- cases.addBuildFile("test/link/entry/build.zig", .{
+ cases.addBuildFile("test/link/macho/entry/build.zig", .{
.build_modes = true,
});
diff --git a/test/link/macho/dylib/build.zig b/test/link/macho/dylib/build.zig
@@ -13,7 +13,7 @@ pub fn build(b: *Builder) void {
dylib.linkLibC();
dylib.install();
- const check_dylib = dylib.checkMachO();
+ const check_dylib = dylib.checkObject(.macho);
check_dylib.check("cmd ID_DYLIB");
check_dylib.checkNext("path @rpath/liba.dylib");
check_dylib.checkNext("timestamp 2");
@@ -30,7 +30,7 @@ pub fn build(b: *Builder) void {
exe.addLibraryPath(b.pathFromRoot("zig-out/lib/"));
exe.addRPath(b.pathFromRoot("zig-out/lib"));
- const check_exe = exe.checkMachO();
+ const check_exe = exe.checkObject(.macho);
check_exe.check("cmd LOAD_DYLIB");
check_exe.checkNext("path @rpath/liba.dylib");
check_exe.checkNext("timestamp 2");
diff --git a/test/link/macho/entry/build.zig b/test/link/macho/entry/build.zig
@@ -13,7 +13,7 @@ pub fn build(b: *Builder) void {
exe.linkLibC();
exe.entry_symbol_name = "_non_main";
- const check_exe = exe.checkMachO();
+ const check_exe = exe.checkObject(.macho);
check_exe.check("segname __TEXT");
check_exe.checkNextExtract("vmaddr {vmaddr}");
diff --git a/test/link/macho/pagezero/build.zig b/test/link/macho/pagezero/build.zig
@@ -14,7 +14,7 @@ pub fn build(b: *Builder) void {
exe.linkLibC();
exe.pagezero_size = 0x4000;
- const check = exe.checkMachO();
+ const check = exe.checkObject(.macho);
check.check("LC 0");
check.checkNext("segname __PAGEZERO");
check.checkNext("vmaddr 0");
@@ -33,7 +33,7 @@ pub fn build(b: *Builder) void {
exe.linkLibC();
exe.pagezero_size = 0;
- const check = exe.checkMachO();
+ const check = exe.checkObject(.macho);
check.check("LC 0");
check.checkNext("segname __TEXT");
check.checkNext("vmaddr 0");
diff --git a/test/link/macho/stack_size/build.zig b/test/link/macho/stack_size/build.zig
@@ -13,7 +13,7 @@ pub fn build(b: *Builder) void {
exe.linkLibC();
exe.stack_size = 0x100000000;
- const check_exe = exe.checkMachO();
+ const check_exe = exe.checkObject(.macho);
check_exe.check("cmd MAIN");
check_exe.checkNext("stacksize 100000000");