authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-13 19:12:55+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:39+01:00
logbf285c7e409bddfe7089e570ebf836d0343c8628
tree9484b77390550b59d66b791ad64ab610c86e975d
parentfaa1849f81fd1478f2340ab6ccdc8d71d1c5d102

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


1 files changed, 22 insertions(+), 0 deletions(-)

test/link/macho.zig+22
......@@ -10,6 +10,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
1010
1111 macho_step.dependOn(testDeadStrip(b, .{ .target = default_target }));
1212 macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));
13 macho_step.dependOn(testLargeBss(b, .{ .target = default_target }));
1314 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
1415 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
1516 macho_step.dependOn(testSegmentBoundarySymbols(b, .{ .target = default_target }));
......@@ -162,6 +163,27 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {
162163 return test_step;
163164}
164165
166fn testLargeBss(b: *Build, opts: Options) *Step {
167 const test_step = addTestStep(b, "macho-large-bss", opts);
168
169 // TODO this test used use a 4GB zerofill section but this actually fails and causes every
170 // linker I tried misbehave in different ways. This only happened on arm64. I thought that
171 // maybe S_GB_ZEROFILL section is an answer to this but it doesn't seem supported by dyld
172 // anymore. When I get some free time I will re-investigate this.
173 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
174 \\char arr[0x1000000];
175 \\int main() {
176 \\ return arr[2000];
177 \\}
178 });
179
180 const run = addRunArtifact(exe);
181 run.expectExitCode(0);
182 test_step.dependOn(&run.step);
183
184 return test_step;
185}
186
165187fn testMhExecuteHeader(b: *Build, opts: Options) *Step {
166188 const test_step = addTestStep(b, "macho-mh-execute-header", opts);
167189