From 605e3eb08cffd40af98ff1bb2080d3e5f29da861 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 2 Oct 2023 16:56:21 +0200 Subject: [PATCH] elf: clean up generating GOT symbol names --- src/link/Elf/synthetic_sections.zig | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/link/Elf/synthetic_sections.zig b/src/link/Elf/synthetic_sections.zig index bee044e821..3d49c551ce 100644 --- a/src/link/Elf/synthetic_sections.zig +++ b/src/link/Elf/synthetic_sections.zig @@ -379,15 +379,8 @@ pub const GotSection = struct { pub fn updateStrtab(got: GotSection, elf_file: *Elf) !void { const gpa = elf_file.base.allocator; for (got.entries.items) |entry| { - const suffix = switch (entry.tag) { - .tlsld => "$tlsld", - .tlsgd => "$tlsgd", - .got => "$got", - .gottp => "$gottp", - .tlsdesc => "$tlsdesc", - }; const symbol = elf_file.symbol(entry.symbol_index); - const name = try std.fmt.allocPrint(gpa, "{s}{s}", .{ symbol.name(elf_file), suffix }); + const name = try std.fmt.allocPrint(gpa, "{s}${s}", .{ symbol.name(elf_file), @tagName(entry.tag) }); defer gpa.free(name); _ = try elf_file.strtab.insert(gpa, name); } @@ -396,15 +389,8 @@ pub const GotSection = struct { pub fn writeSymtab(got: GotSection, elf_file: *Elf, ctx: anytype) !void { const gpa = elf_file.base.allocator; for (got.entries.items, ctx.ilocal..) |entry, ilocal| { - const suffix = switch (entry.tag) { - .tlsld => "$tlsld", - .tlsgd => "$tlsgd", - .got => "$got", - .gottp => "$gottp", - .tlsdesc => "$tlsdesc", - }; const symbol = elf_file.symbol(entry.symbol_index); - const name = try std.fmt.allocPrint(gpa, "{s}{s}", .{ symbol.name(elf_file), suffix }); + const name = try std.fmt.allocPrint(gpa, "{s}${s}", .{ symbol.name(elf_file), @tagName(entry.tag) }); defer gpa.free(name); const st_name = try elf_file.strtab.insert(gpa, name); const st_value = switch (entry.tag) {