| ... | @@ -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) { |