Commit b431e9af97
Changed files (2)
src
link
test
incremental
src/link/Elf/ZigObject.zig
@@ -1937,9 +1937,14 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e
const shdr = &slice.items(.shdr)[atom_ptr.output_section_index];
const last_atom_ref = &slice.items(.last_atom)[atom_ptr.output_section_index];
- // This only works if this atom is the only atom in the output section. In
- // every other case, we need to redo the prev/next links.
- if (last_atom_ref.eql(atom_ptr.ref())) last_atom_ref.* = .{};
+ if (last_atom_ref.eql(atom_ptr.ref())) {
+ if (atom_ptr.prevAtom(elf_file)) |prev_atom| {
+ prev_atom.next_atom_ref = .{};
+ last_atom_ref.* = prev_atom.ref();
+ } else {
+ last_atom_ref.* = .{};
+ }
+ }
const alloc_res = try elf_file.allocateChunk(.{
.shndx = atom_ptr.output_section_index,
test/incremental/no_change_preserves_tag_names
@@ -0,0 +1,20 @@
+#target=x86_64-linux-selfhosted
+#target=x86_64-linux-cbe
+#target=x86_64-windows-cbe
+//#target=wasm32-wasi-selfhosted
+#update=initial version
+#file=main.zig
+const std = @import("std");
+var some_enum: enum { first, second } = .first;
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@tagName(some_enum));
+}
+#expect_stdout="first"
+#update=no change
+#file=main.zig
+const std = @import("std");
+var some_enum: enum { first, second } = .first;
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@tagName(some_enum));
+}
+#expect_stdout="first"