Commit 43406c0696
Changed files (2)
src
link
src/link/Elf/synthetic_sections.zig
@@ -376,6 +376,23 @@ pub const GotSection = struct {
got.output_symtab_size.nlocals = @as(u32, @intCast(got.entries.items.len));
}
+ 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 });
+ defer gpa.free(name);
+ _ = try elf_file.strtab.insert(gpa, name);
+ }
+ }
+
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| {
src/link/Elf.zig
@@ -3503,6 +3503,11 @@ fn updateSyntheticSectionSizes(self: *Elf) !void {
try self.updateSymtabSize();
}
if (self.strtab_section_index) |index| {
+ // TODO I don't really this here but we need it to add symbol names from GOT and other synthetic
+ // sections into .strtab for easier debugging.
+ if (self.got_section_index) |_| {
+ try self.got.updateStrtab(self);
+ }
try self.growNonAllocSection(index, self.strtab.buffer.items.len, 1, false);
}
if (self.shstrtab_section_index) |index| {