Commit 7c65f0be37

Jakub Konka <kubkon@jakubkonka.com>
2024-01-15 10:35:42
test/link/macho: test no exports in a dylib
1 parent 4cf94bb
Changed files (1)
test
test/link/macho.zig
@@ -26,6 +26,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
     macho_step.dependOn(testLayout(b, .{ .target = default_target }));
     macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
     macho_step.dependOn(testNoDeadStrip(b, .{ .target = default_target }));
+    macho_step.dependOn(testNoExportsDylib(b, .{ .target = default_target }));
     macho_step.dependOn(testRelocatable(b, .{ .target = default_target }));
     macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));
     macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
@@ -772,6 +773,19 @@ fn testNoDeadStrip(b: *Build, opts: Options) *Step {
     return test_step;
 }
 
+fn testNoExportsDylib(b: *Build, opts: Options) *Step {
+    const test_step = addTestStep(b, "macho-no-exports-dylib", opts);
+
+    const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes = "static void abc() {}" });
+
+    const check = dylib.checkObject();
+    check.checkInSymtab();
+    check.checkNotPresent("external _abc");
+    test_step.dependOn(&check.step);
+
+    return test_step;
+}
+
 fn testNeededFramework(b: *Build, opts: Options) *Step {
     const test_step = addTestStep(b, "macho-needed-framework", opts);