| ... | @@ -376,6 +376,23 @@ pub const GotSection = struct { | ... | @@ -376,6 +376,23 @@ pub const GotSection = struct { |
| 376 | got.output_symtab_size.nlocals = @as(u32, @intCast(got.entries.items.len)); | 376 | got.output_symtab_size.nlocals = @as(u32, @intCast(got.entries.items.len)); |
| 377 | } | 377 | } |
| 378 | | 378 | |
| | 379 | pub fn updateStrtab(got: GotSection, elf_file: *Elf) !void { |
| | 380 | const gpa = elf_file.base.allocator; |
| | 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); |
| | 390 | const name = try std.fmt.allocPrint(gpa, "{s}{s}", .{ symbol.name(elf_file), suffix }); |
| | 391 | defer gpa.free(name); |
| | 392 | _ = try elf_file.strtab.insert(gpa, name); |
| | 393 | } |
| | 394 | } |
| | 395 | |
| 379 | pub fn writeSymtab(got: GotSection, elf_file: *Elf, ctx: anytype) !void { | 396 | pub fn writeSymtab(got: GotSection, elf_file: *Elf, ctx: anytype) !void { |
| 380 | const gpa = elf_file.base.allocator; | 397 | const gpa = elf_file.base.allocator; |
| 381 | for (got.entries.items, ctx.ilocal..) |entry, ilocal| { | 398 | for (got.entries.items, ctx.ilocal..) |entry, ilocal| { |