From bf285c7e409bddfe7089e570ebf836d0343c8628 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sat, 13 Jan 2024 19:12:55 +0100 Subject: [PATCH] test/link/macho: test for correct handling of large __bss sections --- test/link/macho.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/link/macho.zig b/test/link/macho.zig index bbcd7b31bd..dd7b178f27 100644 --- a/test/link/macho.zig +++ b/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(testLargeBss(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 })); @@ -162,6 +163,27 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step { return test_step; } +fn testLargeBss(b: *Build, opts: Options) *Step { + const test_step = addTestStep(b, "macho-large-bss", opts); + + // TODO this test used use a 4GB zerofill section but this actually fails and causes every + // linker I tried misbehave in different ways. This only happened on arm64. I thought that + // maybe S_GB_ZEROFILL section is an answer to this but it doesn't seem supported by dyld + // anymore. When I get some free time I will re-investigate this. + const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = + \\char arr[0x1000000]; + \\int main() { + \\ return arr[2000]; + \\} + }); + + const run = addRunArtifact(exe); + run.expectExitCode(0); + test_step.dependOn(&run.step); + + return test_step; +} + fn testMhExecuteHeader(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "macho-mh-execute-header", opts);