mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Elf: fix incrementally reallocating the last atom in a section
This commit is contained in:
parent
d53cc5e5b2
commit
b431e9af97
2 changed files with 28 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
20
test/incremental/no_change_preserves_tag_names
Normal file
20
test/incremental/no_change_preserves_tag_names
Normal file
|
|
@ -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"
|
||||
Loading…
Add table
Reference in a new issue