| ... | ... | @@ -4127,6 +4127,7 @@ pub fn updateSymtabSize(self: *Elf) !void { |
| 4127 | 4127 | nlocals += @intCast(self.sections.slice().len); |
| 4128 | 4128 | |
| 4129 | 4129 | if (self.requiresThunks()) for (self.thunks.items) |*th| { |
| 4130 | th.output_symtab_ctx.reset(); |
| 4130 | 4131 | th.output_symtab_ctx.ilocal = nlocals; |
| 4131 | 4132 | th.calcSymtabSize(self); |
| 4132 | 4133 | nlocals += th.output_symtab_ctx.nlocals; |
| ... | ... | @@ -4138,6 +4139,7 @@ pub fn updateSymtabSize(self: *Elf) !void { |
| 4138 | 4139 | const ctx = switch (file_ptr) { |
| 4139 | 4140 | inline else => |x| &x.output_symtab_ctx, |
| 4140 | 4141 | }; |
| 4142 | ctx.reset(); |
| 4141 | 4143 | ctx.ilocal = nlocals; |
| 4142 | 4144 | ctx.iglobal = nglobals; |
| 4143 | 4145 | try file_ptr.updateSymtabSize(self); |
| ... | ... | @@ -4147,6 +4149,7 @@ pub fn updateSymtabSize(self: *Elf) !void { |
| 4147 | 4149 | } |
| 4148 | 4150 | |
| 4149 | 4151 | if (self.got_section_index) |_| { |
| 4152 | self.got.output_symtab_ctx.reset(); |
| 4150 | 4153 | self.got.output_symtab_ctx.ilocal = nlocals; |
| 4151 | 4154 | self.got.updateSymtabSize(self); |
| 4152 | 4155 | nlocals += self.got.output_symtab_ctx.nlocals; |
| ... | ... | @@ -4154,6 +4157,7 @@ pub fn updateSymtabSize(self: *Elf) !void { |
| 4154 | 4157 | } |
| 4155 | 4158 | |
| 4156 | 4159 | if (self.plt_section_index) |_| { |
| 4160 | self.plt.output_symtab_ctx.reset(); |
| 4157 | 4161 | self.plt.output_symtab_ctx.ilocal = nlocals; |
| 4158 | 4162 | self.plt.updateSymtabSize(self); |
| 4159 | 4163 | nlocals += self.plt.output_symtab_ctx.nlocals; |
| ... | ... | @@ -4161,6 +4165,7 @@ pub fn updateSymtabSize(self: *Elf) !void { |
| 4161 | 4165 | } |
| 4162 | 4166 | |
| 4163 | 4167 | if (self.plt_got_section_index) |_| { |
| 4168 | self.plt_got.output_symtab_ctx.reset(); |
| 4164 | 4169 | self.plt_got.output_symtab_ctx.ilocal = nlocals; |
| 4165 | 4170 | self.plt_got.updateSymtabSize(self); |
| 4166 | 4171 | nlocals += self.plt_got.output_symtab_ctx.nlocals; |
| ... | ... | @@ -4359,6 +4364,9 @@ pub fn writeSymtab(self: *Elf) !void { |
| 4359 | 4364 | |
| 4360 | 4365 | try self.symtab.resize(gpa, nsyms); |
| 4361 | 4366 | const needed_strtab_size = math.cast(usize, strtab_shdr.sh_size - 1) orelse return error.Overflow; |
| 4367 | // TODO we could resize instead and in ZigObject/Object always access as slice |
| 4368 | self.strtab.clearRetainingCapacity(); |
| 4369 | self.strtab.appendAssumeCapacity(0); |
| 4362 | 4370 | try self.strtab.ensureUnusedCapacity(gpa, needed_strtab_size); |
| 4363 | 4371 | |
| 4364 | 4372 | for (slice.items(.shdr), 0..) |shdr, shndx| { |
| ... | ... | @@ -5330,7 +5338,7 @@ fn fmtDumpState( |
| 5330 | 5338 | { |
| 5331 | 5339 | try writer.writeAll("atom lists\n"); |
| 5332 | 5340 | for (slice.items(.shdr), slice.items(.atom_list_2), 0..) |shdr, atom_list, shndx| { |
| 5333 | | try writer.print("shdr({d}) : {s} : {}", .{ shndx, self.getShString(shdr.sh_name), atom_list.fmt(self) }); |
| 5341 | try writer.print("shdr({d}) : {s} : {}\n", .{ shndx, self.getShString(shdr.sh_name), atom_list.fmt(self) }); |
| 5334 | 5342 | } |
| 5335 | 5343 | } |
| 5336 | 5344 | |
| ... | ... | @@ -5462,6 +5470,14 @@ pub const SymtabCtx = struct { |
| 5462 | 5470 | nlocals: u32 = 0, |
| 5463 | 5471 | nglobals: u32 = 0, |
| 5464 | 5472 | strsize: u32 = 0, |
| 5473 | |
| 5474 | pub fn reset(ctx: *SymtabCtx) void { |
| 5475 | ctx.ilocal = 0; |
| 5476 | ctx.iglobal = 0; |
| 5477 | ctx.nlocals = 0; |
| 5478 | ctx.nglobals = 0; |
| 5479 | ctx.strsize = 0; |
| 5480 | } |
| 5465 | 5481 | }; |
| 5466 | 5482 | |
| 5467 | 5483 | pub const null_sym = elf.Elf64_Sym{ |