| ... | ... | @@ -18,9 +18,6 @@ objects: std.ArrayListUnmanaged(File.Index) = .{}, |
| 18 | 18 | /// Stored in native-endian format, depending on target endianness needs to be bswapped on read/write. |
| 19 | 19 | /// Same order as in the file. |
| 20 | 20 | shdrs: std.ArrayListUnmanaged(elf.Elf64_Shdr) = .{}, |
| 21 | | /// Given index to a section, returns a list of atoms allocated within it. |
| 22 | | /// Excludes incrementally allocated atoms - for those, use linked-list approach. |
| 23 | | atoms_by_shdr_table: std.AutoArrayHashMapUnmanaged(u16, AtomList) = .{}, |
| 24 | 21 | /// Given index to a section, pulls index of containing phdr if any. |
| 25 | 22 | phdr_to_shdr_table: std.AutoHashMapUnmanaged(u16, u16) = .{}, |
| 26 | 23 | /// File offset into the shdr table. |
| ... | ... | @@ -319,12 +316,6 @@ pub fn deinit(self: *Elf) void { |
| 319 | 316 | self.objects.deinit(gpa); |
| 320 | 317 | |
| 321 | 318 | self.shdrs.deinit(gpa); |
| 322 | | |
| 323 | | for (self.atoms_by_shdr_table.values()) |*list| { |
| 324 | | list.deinit(gpa); |
| 325 | | } |
| 326 | | self.atoms_by_shdr_table.deinit(gpa); |
| 327 | | |
| 328 | 319 | self.phdr_to_shdr_table.deinit(gpa); |
| 329 | 320 | self.phdrs.deinit(gpa); |
| 330 | 321 | self.shstrtab.deinit(gpa); |
| ... | ... | @@ -1254,7 +1245,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1254 | 1245 | // Generate and emit non-incremental sections. |
| 1255 | 1246 | try self.initSections(); |
| 1256 | 1247 | try self.sortSections(); |
| 1257 | | try self.addAtomsToSections(); |
| 1248 | try self.updateSectionSizes(); |
| 1258 | 1249 | |
| 1259 | 1250 | // Dump the state for easy debugging. |
| 1260 | 1251 | // State can be dumped via `--debug-log link_state`. |
| ... | ... | @@ -1266,7 +1257,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1266 | 1257 | // linker-defined synthetic symbols. |
| 1267 | 1258 | try self.allocateObjects(); |
| 1268 | 1259 | self.allocateLinkerDefinedSymbols(); |
| 1269 | | try self.updateSyntheticSectionSizes(); |
| 1270 | 1260 | |
| 1271 | 1261 | // Look for entry address in objects if not set by the incremental compiler. |
| 1272 | 1262 | if (self.entry_addr == null) { |
| ... | ... | @@ -3598,26 +3588,13 @@ fn sortSections(self: *Elf) !void { |
| 3598 | 3588 | } |
| 3599 | 3589 | } |
| 3600 | 3590 | |
| 3601 | | fn addAtomsToSections(self: *Elf) !void { |
| 3602 | | const gpa = self.base.allocator; |
| 3591 | fn updateSectionSizes(self: *Elf) !void { |
| 3603 | 3592 | for (self.objects.items) |index| { |
| 3604 | | for (self.file(index).?.atoms()) |atom_index| { |
| 3605 | | const atom_ptr = self.atom(atom_index) orelse continue; |
| 3606 | | if (!atom_ptr.flags.alive) continue; |
| 3607 | | const gop = try self.atoms_by_shdr_table.getOrPut(gpa, atom_ptr.output_section_index); |
| 3608 | | if (!gop.found_existing) gop.value_ptr.* = .{}; |
| 3609 | | try gop.value_ptr.append(gpa, atom_index); |
| 3610 | | } |
| 3593 | self.file(index).?.object.updateSectionSizes(self); |
| 3611 | 3594 | } |
| 3612 | | } |
| 3613 | 3595 | |
| 3614 | | fn updateSyntheticSectionSizes(self: *Elf) !void { |
| 3615 | 3596 | if (self.got_section_index) |index| { |
| 3616 | | if (self.got.dirty) { |
| 3617 | | try self.growAllocSection(index, self.got.size(self)); |
| 3618 | | self.got.dirty = false; |
| 3619 | | self.got_addresses_dirty = true; |
| 3620 | | } |
| 3597 | self.shdrs.items[index].sh_size = self.got.size(self); |
| 3621 | 3598 | } |
| 3622 | 3599 | |
| 3623 | 3600 | if (self.symtab_section_index != null) { |