authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-15 10:32:25+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
log4cf94bb14869641316f337903ab24eef52eb7899
tree9474291a637ab95d9d60810a38f7beed3348c334
parent4dc1907a88c950daa8273ed4db1b46f7537e20fc

test/link/macho: test attribute "used" on vars in presence of dead_strip


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

test/link/macho.zig+27
...@@ -25,6 +25,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {...@@ -25,6 +25,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
25 macho_step.dependOn(testLargeBss(b, .{ .target = default_target }));25 macho_step.dependOn(testLargeBss(b, .{ .target = default_target }));
26 macho_step.dependOn(testLayout(b, .{ .target = default_target }));26 macho_step.dependOn(testLayout(b, .{ .target = default_target }));
27 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));27 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
28 macho_step.dependOn(testNoDeadStrip(b, .{ .target = default_target }));
28 macho_step.dependOn(testRelocatable(b, .{ .target = default_target }));29 macho_step.dependOn(testRelocatable(b, .{ .target = default_target }));
29 macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));30 macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));
30 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));31 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
...@@ -745,6 +746,32 @@ fn testMhExecuteHeader(b: *Build, opts: Options) *Step {...@@ -745,6 +746,32 @@ fn testMhExecuteHeader(b: *Build, opts: Options) *Step {
745 return test_step;746 return test_step;
746}747}
747748
749fn testNoDeadStrip(b: *Build, opts: Options) *Step {
750 const test_step = addTestStep(b, "macho-no-dead-strip", opts);
751
752 const exe = addExecutable(b, opts, .{ .name = "name", .c_source_bytes =
753 \\__attribute__((used)) int bogus1 = 0;
754 \\int bogus2 = 0;
755 \\int foo = 42;
756 \\int main() {
757 \\ return foo - 42;
758 \\}
759 });
760 exe.link_gc_sections = true;
761
762 const check = exe.checkObject();
763 check.checkInSymtab();
764 check.checkContains("external _bogus1");
765 check.checkInSymtab();
766 check.checkNotPresent("external _bogus2");
767 test_step.dependOn(&check.step);
768
769 const run = addRunArtifact(exe);
770 test_step.dependOn(&run.step);
771
772 return test_step;
773}
774
748fn testNeededFramework(b: *Build, opts: Options) *Step {775fn testNeededFramework(b: *Build, opts: Options) *Step {
749 const test_step = addTestStep(b, "macho-needed-framework", opts);776 const test_step = addTestStep(b, "macho-needed-framework", opts);
750777