| ... | @@ -1937,9 +1937,14 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e | ... | @@ -1937,9 +1937,14 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e |
| 1937 | const shdr = &slice.items(.shdr)[atom_ptr.output_section_index]; | 1937 | const shdr = &slice.items(.shdr)[atom_ptr.output_section_index]; |
| 1938 | const last_atom_ref = &slice.items(.last_atom)[atom_ptr.output_section_index]; | 1938 | const last_atom_ref = &slice.items(.last_atom)[atom_ptr.output_section_index]; |
| 1939 | | 1939 | |
| 1940 | // This only works if this atom is the only atom in the output section. In | 1940 | if (last_atom_ref.eql(atom_ptr.ref())) { |
| 1941 | // every other case, we need to redo the prev/next links. | 1941 | if (atom_ptr.prevAtom(elf_file)) |prev_atom| { |
| 1942 | if (last_atom_ref.eql(atom_ptr.ref())) last_atom_ref.* = .{}; | 1942 | prev_atom.next_atom_ref = .{}; |
| | 1943 | last_atom_ref.* = prev_atom.ref(); |
| | 1944 | } else { |
| | 1945 | last_atom_ref.* = .{}; |
| | 1946 | } |
| | 1947 | } |
| 1943 | | 1948 | |
| 1944 | const alloc_res = try elf_file.allocateChunk(.{ | 1949 | const alloc_res = try elf_file.allocateChunk(.{ |
| 1945 | .shndx = atom_ptr.output_section_index, | 1950 | .shndx = atom_ptr.output_section_index, |