authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-05 00:34:45+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:04+02:00
log04a8f217c651f56a2e185d87dd40c0a87ee78bc5
tree88c21a1678fa5be114b227d873c89a9e067888cb
parent9a80ac0429b34541b91671246833c47143d1e4da

elf: fix COMDAT deduping logic


2 files changed, 6 insertions(+), 4 deletions(-)

src/link/Elf/Atom.zig+1-1
......@@ -1172,7 +1172,7 @@ pub const Index = u32;
11721172
11731173pub const Flags = packed struct {
11741174 /// Specifies whether this atom is alive or has been garbage collected.
1175 alive: bool = false,
1175 alive: bool = true,
11761176
11771177 /// Specifies if the atom has been visited during garbage collection.
11781178 visited: bool = false,
src/link/Elf/Object.zig+5-3
......@@ -130,7 +130,10 @@ fn initAtoms(self: *Object, elf_file: *Elf) !void {
130130 continue;
131131 }
132132
133 const group_signature_off = try self.strings.insert(elf_file.base.allocator, group_signature);
133 // Note the assumption about a global strtab used here to disambiguate common
134 // COMDAT owners.
135 const gpa = elf_file.base.allocator;
136 const group_signature_off = try elf_file.strtab.insert(gpa, group_signature);
134137 const gop = try elf_file.getOrCreateComdatGroupOwner(group_signature_off);
135138 const comdat_group_index = try elf_file.addComdatGroup();
136139 const comdat_group = elf_file.comdatGroup(comdat_group_index);
......@@ -138,7 +141,7 @@ fn initAtoms(self: *Object, elf_file: *Elf) !void {
138141 .owner = gop.index,
139142 .shndx = shndx,
140143 };
141 try self.comdat_groups.append(elf_file.base.allocator, comdat_group_index);
144 try self.comdat_groups.append(gpa, comdat_group_index);
142145 },
143146
144147 elf.SHT_SYMTAB_SHNDX => @panic("TODO SHT_SYMTAB_SHNDX"),
......@@ -184,7 +187,6 @@ fn addAtom(
184187 atom.name_offset = try elf_file.strtab.insert(elf_file.base.allocator, name);
185188 atom.file_index = self.index;
186189 atom.input_section_index = shndx;
187 atom.flags.alive = true;
188190 self.atoms.items[shndx] = atom_index;
189191
190192 if (shdr.sh_flags & elf.SHF_COMPRESSED != 0) {