| ... | @@ -4,15 +4,15 @@ | ... | @@ -4,15 +4,15 @@ |
| 4 | pub fn testAll(b: *std.Build) *Step { | 4 | pub fn testAll(b: *std.Build) *Step { |
| 5 | const macho_step = b.step("test-macho", "Run MachO tests"); | 5 | const macho_step = b.step("test-macho", "Run MachO tests"); |
| 6 | | 6 | |
| 7 | macho_step.dependOn(testResolvingBoundarySymbols(b, .{ | 7 | macho_step.dependOn(testSectionBoundarySymbols(b, .{ |
| 8 | .target = b.resolveTargetQuery(.{ .os_tag = .macos }), | 8 | .target = b.resolveTargetQuery(.{ .os_tag = .macos }), |
| 9 | })); | 9 | })); |
| 10 | | 10 | |
| 11 | return macho_step; | 11 | return macho_step; |
| 12 | } | 12 | } |
| 13 | | 13 | |
| 14 | fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { | 14 | fn testSectionBoundarySymbols(b: *std.Build, opts: Options) *Step { |
| 15 | const test_step = addTestStep(b, "macho-resolving-boundary-symbols", opts); | 15 | const test_step = addTestStep(b, "macho-section-boundary-symbols", opts); |
| 16 | | 16 | |
| 17 | const obj1 = addObject(b, opts, .{ | 17 | const obj1 = addObject(b, opts, .{ |
| 18 | .name = "obj1", | 18 | .name = "obj1", |
| ... | @@ -25,10 +25,10 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { | ... | @@ -25,10 +25,10 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { |
| 25 | .name = "main", | 25 | .name = "main", |
| 26 | .zig_source_bytes = | 26 | .zig_source_bytes = |
| 27 | \\const std = @import("std"); | 27 | \\const std = @import("std"); |
| 28 | \\extern fn interop() [*:0]const u8; | 28 | \\extern fn interop() ?[*:0]const u8; |
| 29 | \\pub fn main() !void { | 29 | \\pub fn main() !void { |
| 30 | \\ std.debug.print("All your {s} are belong to us.\n", .{ | 30 | \\ std.debug.print("All your {s} are belong to us.\n", .{ |
| 31 | \\ std.mem.span(interop()), | 31 | \\ if (interop()) |ptr| std.mem.span(ptr) else "(null)", |
| 32 | \\ }); | 32 | \\ }); |
| 33 | \\} | 33 | \\} |
| 34 | , | 34 | , |
| ... | @@ -57,7 +57,7 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { | ... | @@ -57,7 +57,7 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { |
| 57 | | 57 | |
| 58 | const check = exe.checkObject(); | 58 | const check = exe.checkObject(); |
| 59 | check.checkInSymtab(); | 59 | check.checkInSymtab(); |
| 60 | check.checkNotPresent("section$start$__DATA_CONST$__message_ptr"); | 60 | check.checkNotPresent("external section$start$__DATA_CONST$__message_ptr"); |
| 61 | test_step.dependOn(&check.step); | 61 | test_step.dependOn(&check.step); |
| 62 | } | 62 | } |
| 63 | | 63 | |
| ... | @@ -65,7 +65,7 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { | ... | @@ -65,7 +65,7 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { |
| 65 | const obj3 = addObject(b, opts, .{ | 65 | const obj3 = addObject(b, opts, .{ |
| 66 | .name = "obj3", | 66 | .name = "obj3", |
| 67 | .cpp_source_bytes = | 67 | .cpp_source_bytes = |
| 68 | \\extern const char* message_pointer __asm("section$start$__DATA$__message_ptr"); | 68 | \\extern const char* message_pointer __asm("section$start$__DATA_CONST$__not_present"); |
| 69 | \\extern "C" const char* interop() { | 69 | \\extern "C" const char* interop() { |
| 70 | \\ return message_pointer; | 70 | \\ return message_pointer; |
| 71 | \\} | 71 | \\} |
| ... | @@ -77,10 +77,15 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { | ... | @@ -77,10 +77,15 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step { |
| 77 | exe.addObject(obj3); | 77 | exe.addObject(obj3); |
| 78 | exe.addObject(main_o); | 78 | exe.addObject(main_o); |
| 79 | | 79 | |
| 80 | expectLinkErrors(exe, test_step, .{ .exact = &.{ | 80 | const run = b.addRunArtifact(exe); |
| 81 | "section not found: __DATA,__message_ptr", | 81 | run.skip_foreign_checks = true; |
| 82 | "note: while resolving section$start$__DATA$__message_ptr", | 82 | run.expectStdErrEqual("All your (null) are belong to us.\n"); |
| 83 | } }); | 83 | test_step.dependOn(&run.step); |
| | 84 | |
| | 85 | const check = exe.checkObject(); |
| | 86 | check.checkInSymtab(); |
| | 87 | check.checkNotPresent("external section$start$__DATA_CONST$__not_present"); |
| | 88 | test_step.dependOn(&check.step); |
| 84 | } | 89 | } |
| 85 | | 90 | |
| 86 | return test_step; | 91 | return test_step; |