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 {...@@ -379,15 +379,8 @@ pub const GotSection = struct {
379 pub fn updateStrtab(got: GotSection, elf_file: *Elf) !void {379 pub fn updateStrtab(got: GotSection, elf_file: *Elf) !void {
380 const gpa = elf_file.base.allocator;380 const gpa = elf_file.base.allocator;
381 for (got.entries.items) |entry| {381 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 };
389 const symbol = elf_file.symbol(entry.symbol_index);382 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) });
391 defer gpa.free(name);384 defer gpa.free(name);
392 _ = try elf_file.strtab.insert(gpa, name);385 _ = try elf_file.strtab.insert(gpa, name);
393 }386 }
...@@ -396,15 +389,8 @@ pub const GotSection = struct {...@@ -396,15 +389,8 @@ pub const GotSection = struct {
396 pub fn writeSymtab(got: GotSection, elf_file: *Elf, ctx: anytype) !void {389 pub fn writeSymtab(got: GotSection, elf_file: *Elf, ctx: anytype) !void {
397 const gpa = elf_file.base.allocator;390 const gpa = elf_file.base.allocator;
398 for (got.entries.items, ctx.ilocal..) |entry, ilocal| {391 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 };
406 const symbol = elf_file.symbol(entry.symbol_index);392 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) });
408 defer gpa.free(name);394 defer gpa.free(name);
409 const st_name = try elf_file.strtab.insert(gpa, name);395 const st_name = try elf_file.strtab.insert(gpa, name);
410 const st_value = switch (entry.tag) {396 const st_value = switch (entry.tag) {