Commit faa1849f81

Jakub Konka <kubkon@jakubkonka.com>
2024-01-13 19:09:40
test/link/macho: test for correct handling of __mh_execute_header symbol
1 parent 49c11e0
Changed files (1)
test
test/link/macho.zig
@@ -10,6 +10,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
 
     macho_step.dependOn(testDeadStrip(b, .{ .target = default_target }));
     macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));
+    macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
     macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
     macho_step.dependOn(testSegmentBoundarySymbols(b, .{ .target = default_target }));
 
@@ -161,6 +162,19 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {
     return test_step;
 }
 
+fn testMhExecuteHeader(b: *Build, opts: Options) *Step {
+    const test_step = addTestStep(b, "macho-mh-execute-header", opts);
+
+    const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
+
+    const check = exe.checkObject();
+    check.checkInSymtab();
+    check.checkContains("[referenced dynamically] external __mh_execute_header");
+    test_step.dependOn(&check.step);
+
+    return test_step;
+}
+
 fn testNeededFramework(b: *Build, opts: Options) *Step {
     const test_step = addTestStep(b, "macho-needed-framework", opts);