| author | |
| committer | |
| log | f4c4ca4b4c6f1d0c61ce85d1fd9677ff01cb3072 |
| tree | d299a7a91d52018c979dd2fba0c9a952bc3adbc5 |
| parent | d83a3f1746c81026d1cf0244156513c9b5a2a9f6 |
Skipping the symbols too early when resolving would end up in the
linker not deduping CIEs fully.2 files changed, 10 insertions(+), 12 deletions(-)
src/link/Elf/Object.zig+5-6| ... | @@ -524,12 +524,6 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void { | ... | @@ -524,12 +524,6 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void { |
| 524 | const first_global = self.first_global orelse return; | 524 | const first_global = self.first_global orelse return; |
| 525 | for (self.globals(), first_global..) |_, i| { | 525 | for (self.globals(), first_global..) |_, i| { |
| 526 | const esym = self.symtab.items[i]; | 526 | const esym = self.symtab.items[i]; |
| 527 | if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON and esym.st_shndx != elf.SHN_UNDEF) { | ||
| 528 | const atom_index = self.atoms_indexes.items[esym.st_shndx]; | ||
| 529 | const atom_ptr = self.atom(atom_index) orelse continue; | ||
| 530 | if (!atom_ptr.alive) continue; | ||
| 531 | } | ||
| 532 | |||
| 533 | const resolv = &self.symbols_resolver.items[i - first_global]; | 527 | const resolv = &self.symbols_resolver.items[i - first_global]; |
| 534 | const gop = try elf_file.resolver.getOrPut(gpa, .{ | 528 | const gop = try elf_file.resolver.getOrPut(gpa, .{ |
| 535 | .index = @intCast(i), | 529 | .index = @intCast(i), |
| ... | @@ -541,6 +535,11 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void { | ... | @@ -541,6 +535,11 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void { |
| 541 | resolv.* = gop.index; | 535 | resolv.* = gop.index; |
| 542 | 536 | ||
| 543 | if (esym.st_shndx == elf.SHN_UNDEF) continue; | 537 | if (esym.st_shndx == elf.SHN_UNDEF) continue; |
| 538 | if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) { | ||
| 539 | const atom_index = self.atoms_indexes.items[esym.st_shndx]; | ||
| 540 | const atom_ptr = self.atom(atom_index) orelse continue; | ||
| 541 | if (!atom_ptr.alive) continue; | ||
| 542 | } | ||
| 544 | if (elf_file.symbol(gop.ref.*) == null) { | 543 | if (elf_file.symbol(gop.ref.*) == null) { |
| 545 | gop.ref.* = .{ .index = @intCast(i), .file = self.index }; | 544 | gop.ref.* = .{ .index = @intCast(i), .file = self.index }; |
| 546 | continue; | 545 | continue; |
src/link/Elf/ZigObject.zig+5-6| ... | @@ -603,12 +603,6 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void { | ... | @@ -603,12 +603,6 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void { |
| 603 | const global = &self.symbols.items[index]; | 603 | const global = &self.symbols.items[index]; |
| 604 | const esym = global.elfSym(elf_file); | 604 | const esym = global.elfSym(elf_file); |
| 605 | const shndx = self.symtab.items(.shndx)[global.esym_index]; | 605 | const shndx = self.symtab.items(.shndx)[global.esym_index]; |
| 606 | if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON and esym.st_shndx != elf.SHN_UNDEF) { | ||
| 607 | assert(esym.st_shndx == SHN_ATOM); | ||
| 608 | const atom_ptr = self.atom(shndx) orelse continue; | ||
| 609 | if (!atom_ptr.alive) continue; | ||
| 610 | } | ||
| 611 | |||
| 612 | const resolv = &self.symbols_resolver.items[i]; | 606 | const resolv = &self.symbols_resolver.items[i]; |
| 613 | const gop = try elf_file.resolver.getOrPut(gpa, .{ | 607 | const gop = try elf_file.resolver.getOrPut(gpa, .{ |
| 614 | .index = @intCast(i | global_symbol_bit), | 608 | .index = @intCast(i | global_symbol_bit), |
| ... | @@ -620,6 +614,11 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void { | ... | @@ -620,6 +614,11 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void { |
| 620 | resolv.* = gop.index; | 614 | resolv.* = gop.index; |
| 621 | 615 | ||
| 622 | if (esym.st_shndx == elf.SHN_UNDEF) continue; | 616 | if (esym.st_shndx == elf.SHN_UNDEF) continue; |
| 617 | if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) { | ||
| 618 | assert(esym.st_shndx == SHN_ATOM); | ||
| 619 | const atom_ptr = self.atom(shndx) orelse continue; | ||
| 620 | if (!atom_ptr.alive) continue; | ||
| 621 | } | ||
| 623 | if (elf_file.symbol(gop.ref.*) == null) { | 622 | if (elf_file.symbol(gop.ref.*) == null) { |
| 624 | gop.ref.* = .{ .index = @intCast(i | global_symbol_bit), .file = self.index }; | 623 | gop.ref.* = .{ .index = @intCast(i | global_symbol_bit), .file = self.index }; |
| 625 | continue; | 624 | continue; |