| ... | ... | @@ -988,7 +988,25 @@ pub fn allocateAtoms(self: *Object, elf_file: *Elf) !void { |
| 988 | 988 | if (expand_section) last_atom_ref.* = chunk.lastAtom(self).ref(); |
| 989 | 989 | shdr.sh_addralign = @max(shdr.sh_addralign, chunk.alignment.toByteUnits().?); |
| 990 | 990 | |
| 991 | | // TODO create back and forward links |
| 991 | { |
| 992 | var idx: usize = 0; |
| 993 | while (idx < chunk.atoms.items.len) : (idx += 1) { |
| 994 | const curr_atom_ptr = self.atom(chunk.atoms.items[idx]).?; |
| 995 | if (idx > 0) { |
| 996 | curr_atom_ptr.prev_atom_ref = .{ .index = chunk.atoms.items[idx - 1], .file = self.index }; |
| 997 | } |
| 998 | if (idx + 1 < chunk.atoms.items.len) { |
| 999 | curr_atom_ptr.next_atom_ref = .{ .index = chunk.atoms.items[idx + 1], .file = self.index }; |
| 1000 | } |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | if (elf_file.atom(alloc_res.placement)) |placement_atom| { |
| 1005 | chunk.firstAtom(self).prev_atom_ref = placement_atom.ref(); |
| 1006 | chunk.lastAtom(self).next_atom_ref = placement_atom.next_atom_ref; |
| 1007 | placement_atom.next_atom_ref = chunk.firstAtom(self).ref(); |
| 1008 | } |
| 1009 | |
| 992 | 1010 | // TODO if we had a link from Atom to parent Chunk we would not need to update Atom's value or osec index |
| 993 | 1011 | for (chunk.atoms.items) |atom_index| { |
| 994 | 1012 | const atom_ptr = self.atom(atom_index).?; |