authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-02 16:56:21+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:03+02:00
log605e3eb08cffd40af98ff1bb2080d3e5f29da861
tree55f544fbbcde4995c51507213269e52b2bb39afa
parent43406c0696cd164c4da4d893d54390f21a42f0b0

elf: clean up generating GOT symbol names


1 files changed, 2 insertions(+), 16 deletions(-)

src/link/Elf/synthetic_sections.zig+2-16
......@@ -379,15 +379,8 @@ pub const GotSection = struct {
379379 pub fn updateStrtab(got: GotSection, elf_file: *Elf) !void {
380380 const gpa = elf_file.base.allocator;
381381 for (got.entries.items) |entry| {
382 const suffix = switch (entry.tag) {
383 .tlsld => "$tlsld",
384 .tlsgd => "$tlsgd",
385 .got => "$got",
386 .gottp => "$gottp",
387 .tlsdesc => "$tlsdesc",
388 };
389382 const symbol = elf_file.symbol(entry.symbol_index);
390 const name = try std.fmt.allocPrint(gpa, "{s}{s}", .{ symbol.name(elf_file), suffix });
383 const name = try std.fmt.allocPrint(gpa, "{s}${s}", .{ symbol.name(elf_file), @tagName(entry.tag) });
391384 defer gpa.free(name);
392385 _ = try elf_file.strtab.insert(gpa, name);
393386 }
......@@ -396,15 +389,8 @@ pub const GotSection = struct {
396389 pub fn writeSymtab(got: GotSection, elf_file: *Elf, ctx: anytype) !void {
397390 const gpa = elf_file.base.allocator;
398391 for (got.entries.items, ctx.ilocal..) |entry, ilocal| {
399 const suffix = switch (entry.tag) {
400 .tlsld => "$tlsld",
401 .tlsgd => "$tlsgd",
402 .got => "$got",
403 .gottp => "$gottp",
404 .tlsdesc => "$tlsdesc",
405 };
406392 const symbol = elf_file.symbol(entry.symbol_index);
407 const name = try std.fmt.allocPrint(gpa, "{s}{s}", .{ symbol.name(elf_file), suffix });
393 const name = try std.fmt.allocPrint(gpa, "{s}${s}", .{ symbol.name(elf_file), @tagName(entry.tag) });
408394 defer gpa.free(name);
409395 const st_name = try elf_file.strtab.insert(gpa, name);
410396 const st_value = switch (entry.tag) {