authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-25 09:19:57+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-05-26 06:48:53+01:00
log32fa9eea52505b657e2c31a85b8a737740a1014e
tree65a877274af569ad52cac90a076684ac4972ae5a
parent9ce9ee9ae2e2c74c782de416ed735a77e94d3c07
signaturelock-open Commit is signed but in an unrecognized format.

Elf2: strip input debug info sections under `-fstrip`


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

src/link/Elf2.zig+10
...@@ -2847,6 +2847,14 @@ fn mapInputSection(elf: *Elf, opts: struct {...@@ -2847,6 +2847,14 @@ fn mapInputSection(elf: *Elf, opts: struct {
2847 assert(!elf.base.comp.config.any_non_single_threaded);2847 assert(!elf.base.comp.config.any_non_single_threaded);
2848 return error.TlsSectionUnavailable;2848 return error.TlsSectionUnavailable;
2849 }2849 }
2850
2851 if (elf.base.comp.config.debug_format == .strip and
2852 std.mem.startsWith(u8, opts.name, ".debug_") and
2853 !opts.flags.ALLOC)
2854 {
2855 return error.StripSection;
2856 }
2857
2850 const name: []const u8 = switch (elf.ehdrField(.type)) {2858 const name: []const u8 = switch (elf.ehdrField(.type)) {
2851 .NONE, .CORE, _ => unreachable,2859 .NONE, .CORE, _ => unreachable,
2852 .REL => opts.name,2860 .REL => opts.name,
...@@ -2971,6 +2979,7 @@ fn navMapIndex(elf: *Elf, zcu: *Zcu, nav_index: InternPool.Nav.Index) !Node.NavM...@@ -2971,6 +2979,7 @@ fn navMapIndex(elf: *Elf, zcu: *Zcu, nav_index: InternPool.Nav.Index) !Node.NavM
2971 })) |shndx| {2979 })) |shndx| {
2972 break :section shndx;2980 break :section shndx;
2973 } else |err| switch (err) {2981 } else |err| switch (err) {
2982 error.StripSection,
2974 error.TlsSectionUnavailable,2983 error.TlsSectionUnavailable,
2975 error.UnsupportedSectionFlags,2984 error.UnsupportedSectionFlags,
2976 error.SectionTypeConflict,2985 error.SectionTypeConflict,
...@@ -3271,6 +3280,7 @@ fn loadObject(...@@ -3271,6 +3280,7 @@ fn loadObject(
3271 .addralign = section.shdr.addralign,3280 .addralign = section.shdr.addralign,
3272 .entsize = section.shdr.entsize,3281 .entsize = section.shdr.entsize,
3273 }) catch |err| switch (err) {3282 }) catch |err| switch (err) {
3283 error.StripSection => continue,
3274 error.TlsSectionUnavailable => return diags.failParse(3284 error.TlsSectionUnavailable => return diags.failParse(
3275 path,3285 path,
3276 "thread-local storage section '{s}' is incompatible with '-fsingle-threaded'",3286 "thread-local storage section '{s}' is incompatible with '-fsingle-threaded'",