mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
elf: fix COMDAT deduping logic
This commit is contained in:
parent
9a80ac0429
commit
04a8f217c6
@ -1172,7 +1172,7 @@ pub const Index = u32;
|
||||
|
||||
pub const Flags = packed struct {
|
||||
/// Specifies whether this atom is alive or has been garbage collected.
|
||||
alive: bool = false,
|
||||
alive: bool = true,
|
||||
|
||||
/// Specifies if the atom has been visited during garbage collection.
|
||||
visited: bool = false,
|
||||
|
||||
@ -130,7 +130,10 @@ fn initAtoms(self: *Object, elf_file: *Elf) !void {
|
||||
continue;
|
||||
}
|
||||
|
||||
const group_signature_off = try self.strings.insert(elf_file.base.allocator, group_signature);
|
||||
// Note the assumption about a global strtab used here to disambiguate common
|
||||
// COMDAT owners.
|
||||
const gpa = elf_file.base.allocator;
|
||||
const group_signature_off = try elf_file.strtab.insert(gpa, group_signature);
|
||||
const gop = try elf_file.getOrCreateComdatGroupOwner(group_signature_off);
|
||||
const comdat_group_index = try elf_file.addComdatGroup();
|
||||
const comdat_group = elf_file.comdatGroup(comdat_group_index);
|
||||
@ -138,7 +141,7 @@ fn initAtoms(self: *Object, elf_file: *Elf) !void {
|
||||
.owner = gop.index,
|
||||
.shndx = shndx,
|
||||
};
|
||||
try self.comdat_groups.append(elf_file.base.allocator, comdat_group_index);
|
||||
try self.comdat_groups.append(gpa, comdat_group_index);
|
||||
},
|
||||
|
||||
elf.SHT_SYMTAB_SHNDX => @panic("TODO SHT_SYMTAB_SHNDX"),
|
||||
@ -184,7 +187,6 @@ fn addAtom(
|
||||
atom.name_offset = try elf_file.strtab.insert(elf_file.base.allocator, name);
|
||||
atom.file_index = self.index;
|
||||
atom.input_section_index = shndx;
|
||||
atom.flags.alive = true;
|
||||
self.atoms.items[shndx] = atom_index;
|
||||
|
||||
if (shdr.sh_flags & elf.SHF_COMPRESSED != 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user