Commit 85c0485fd9

Jakub Konka <kubkon@jakubkonka.com>
2023-11-16 10:54:39
elf: test -r mode does not create unneeded .eh_frame section
1 parent f6bf335
Changed files (1)
test
link
test/link/elf.zig
@@ -25,6 +25,7 @@ pub fn testAll(b: *Build) *Step {
     elf_step.dependOn(testEmitRelocatable(b, .{ .target = musl_target }));
     elf_step.dependOn(testRelocatableArchive(b, .{ .target = musl_target }));
     elf_step.dependOn(testRelocatableEhFrame(b, .{ .target = musl_target }));
+    elf_step.dependOn(testRelocatableNoEhFrame(b, .{ .target = musl_target }));
 
     // Exercise linker in ar mode
     elf_step.dependOn(testEmitStaticLib(b, .{ .target = musl_target }));
@@ -2275,6 +2276,33 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
     return test_step;
 }
 
+fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step {
+    const test_step = addTestStep(b, "relocatable-no-eh-frame", opts);
+
+    const obj1 = addObject(b, "obj1", opts);
+    addCSourceBytes(obj1, "int bar() { return 42; }", &.{
+        "-fno-unwind-tables",
+        "-fno-asynchronous-unwind-tables",
+    });
+
+    const obj2 = addObject(b, "obj2", opts);
+    obj2.addObject(obj1);
+
+    const check1 = obj1.checkObject();
+    check1.checkStart();
+    check1.checkExact("section headers");
+    check1.checkNotPresent(".eh_frame");
+    test_step.dependOn(&check1.step);
+
+    const check2 = obj2.checkObject();
+    check2.checkStart();
+    check2.checkExact("section headers");
+    check2.checkNotPresent(".eh_frame");
+    test_step.dependOn(&check2.step);
+
+    return test_step;
+}
+
 fn testSharedAbsSymbol(b: *Build, opts: Options) *Step {
     const test_step = addTestStep(b, "shared-abs-symbol", opts);