| ... | ... | @@ -975,6 +975,12 @@ pub fn allocateAtoms(self: *Object, elf_file: *Elf) !void { |
| 975 | 975 | shdr.sh_addralign = @max(shdr.sh_addralign, chunk.alignment.toByteUnits().?); |
| 976 | 976 | |
| 977 | 977 | // TODO create back and forward links |
| 978 | // TODO if we had a link from Atom to parent Chunk we would not need to update Atom's value or osec index |
| 979 | for (chunk.atoms.items) |atom_index| { |
| 980 | const atom_ptr = self.atom(atom_index).?; |
| 981 | atom_ptr.output_section_index = chunk.output_section_index; |
| 982 | atom_ptr.value += chunk.value; |
| 983 | } |
| 978 | 984 | } |
| 979 | 985 | } |
| 980 | 986 | |
| ... | ... | @@ -1008,7 +1014,7 @@ pub fn writeAtoms(self: *Object, elf_file: *Elf) !void { |
| 1008 | 1014 | const atom_ptr = self.atom(atom_index).?; |
| 1009 | 1015 | assert(atom_ptr.alive); |
| 1010 | 1016 | |
| 1011 | | const offset = math.cast(usize, atom_ptr.value) orelse return error.Overflow; |
| 1017 | const offset = math.cast(usize, atom_ptr.value - chunk.value) orelse return error.Overflow; |
| 1012 | 1018 | const size = math.cast(usize, atom_ptr.size) orelse return error.Overflow; |
| 1013 | 1019 | |
| 1014 | 1020 | log.debug(" * atom({d}) at 0x{x}", .{ atom_index, chunk.offset(elf_file) + offset }); |