| ... | ... | @@ -216,7 +216,7 @@ merge_subsections: std.ArrayListUnmanaged(MergeSubsection) = .{}, |
| 216 | 216 | last_atom_and_free_list_table: LastAtomAndFreeListTable = .{}, |
| 217 | 217 | |
| 218 | 218 | comdat_groups_owners: std.ArrayListUnmanaged(ComdatGroupOwner) = .{}, |
| 219 | | comdat_groups_table: std.AutoHashMapUnmanaged(u32, ComdatGroupOwner.Index) = .{}, |
| 219 | comdat_groups_table: std.ArrayHashMapUnmanaged(ComdatGroupKey, ComdatGroupOwner.Index, ComdatGroupContext, false) = .{}, |
| 220 | 220 | |
| 221 | 221 | /// Global string table used to provide quick access to global symbol resolvers |
| 222 | 222 | /// such as `resolver` and `comdat_groups_table`. |
| ... | ... | @@ -5742,10 +5742,9 @@ const GetOrCreateComdatGroupOwnerResult = struct { |
| 5742 | 5742 | index: ComdatGroupOwner.Index, |
| 5743 | 5743 | }; |
| 5744 | 5744 | |
| 5745 | | pub fn getOrCreateComdatGroupOwner(self: *Elf, name: [:0]const u8) !GetOrCreateComdatGroupOwnerResult { |
| 5745 | pub fn getOrCreateComdatGroupOwner(self: *Elf, key: ComdatGroupKey) !GetOrCreateComdatGroupOwnerResult { |
| 5746 | 5746 | const gpa = self.base.comp.gpa; |
| 5747 | | const off = try self.strings.insert(gpa, name); |
| 5748 | | const gop = try self.comdat_groups_table.getOrPut(gpa, off); |
| 5747 | const gop = try self.comdat_groups_table.getOrPutContext(gpa, key, .{ .elf_file = self }); |
| 5749 | 5748 | if (!gop.found_existing) { |
| 5750 | 5749 | const index: ComdatGroupOwner.Index = @intCast(self.comdat_groups_owners.items.len); |
| 5751 | 5750 | const owner = try self.comdat_groups_owners.addOne(gpa); |
| ... | ... | @@ -6244,6 +6243,33 @@ const default_entry_addr = 0x8000000; |
| 6244 | 6243 | |
| 6245 | 6244 | pub const base_tag: link.File.Tag = .elf; |
| 6246 | 6245 | |
| 6246 | const ComdatGroupKey = struct { |
| 6247 | /// String table offset. |
| 6248 | off: u32, |
| 6249 | |
| 6250 | /// File index. |
| 6251 | file_index: File.Index, |
| 6252 | |
| 6253 | pub fn get(key: ComdatGroupKey, elf_file: *Elf) [:0]const u8 { |
| 6254 | const file_ptr = elf_file.file(key.file_index).?; |
| 6255 | return file_ptr.getString(key.off); |
| 6256 | } |
| 6257 | }; |
| 6258 | |
| 6259 | const ComdatGroupContext = struct { |
| 6260 | elf_file: *Elf, |
| 6261 | |
| 6262 | pub fn eql(ctx: ComdatGroupContext, a: ComdatGroupKey, b: ComdatGroupKey, b_index: usize) bool { |
| 6263 | _ = b_index; |
| 6264 | const elf_file = ctx.elf_file; |
| 6265 | return mem.eql(u8, a.get(elf_file), b.get(elf_file)); |
| 6266 | } |
| 6267 | |
| 6268 | pub fn hash(ctx: ComdatGroupContext, a: ComdatGroupKey) u32 { |
| 6269 | return std.array_hash_map.hashString(a.get(ctx.elf_file)); |
| 6270 | } |
| 6271 | }; |
| 6272 | |
| 6247 | 6273 | const ComdatGroupOwner = struct { |
| 6248 | 6274 | file: File.Index = 0, |
| 6249 | 6275 | |