zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bf285c7e409bddfe7089e570ebf836d0343c8628 (tree)
parent faa1849f81fd1478f2340ab6ccdc8d71d1c5d102
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Sat, 13 Jan 2024 19:12:55 +0100

test/link/macho: test for correct handling of large __bss sections

Diffstat:
Mtest/link/macho.zig | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git 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);