| author | |
| committer | |
| log | 8c232922bdf21d9936db94447da21ac0dd9ec319 |
| tree | 4f6b54398e61b197a9e24295fcf8d6a0878506be |
| parent | d83a3f1746c81026d1cf0244156513c9b5a2a9f6 |
| parent | e0acf432482efba4c92029a7dd18037f1607fc27 |
| signature |
elf: misc fixes4 files changed, 15 insertions(+), 17 deletions(-)
src/link/Elf/LinkerDefined.zig+5-4| ... | ... | @@ -47,7 +47,7 @@ fn newSymbolAssumeCapacity(self: *LinkerDefined, name_off: u32, elf_file: *Elf) |
| 47 | 47 | const esym = self.symtab.addOneAssumeCapacity(); |
| 48 | 48 | esym.* = .{ |
| 49 | 49 | .st_name = name_off, |
| 50 | .st_info = elf.STB_GLOBAL << 4, | |
| 50 | .st_info = elf.STB_WEAK << 4, | |
| 51 | 51 | .st_other = @intFromEnum(elf.STV.HIDDEN), |
| 52 | 52 | .st_shndx = elf.SHN_ABS, |
| 53 | 53 | .st_value = 0, |
| ... | ... | @@ -158,7 +158,6 @@ pub fn initStartStopSymbols(self: *LinkerDefined, elf_file: *Elf) !void { |
| 158 | 158 | .index = index, |
| 159 | 159 | .file = self.index, |
| 160 | 160 | }, elf_file); |
| 161 | assert(!gop.found_existing); | |
| 162 | 161 | gop.ref.* = .{ .index = index, .file = self.index }; |
| 163 | 162 | self.symbols_resolver.appendAssumeCapacity(gop.index); |
| 164 | 163 | } |
| ... | ... | @@ -255,8 +254,10 @@ pub fn allocateSymbols(self: *LinkerDefined, elf_file: *Elf) void { |
| 255 | 254 | |
| 256 | 255 | // __dso_handle |
| 257 | 256 | if (self.dso_handle_index) |index| { |
| 258 | const shdr = shdrs[1]; | |
| 259 | allocSymbol(self, index, shdr.sh_addr, 0, elf_file); | |
| 257 | if (self.resolveSymbol(index, elf_file).file == self.index) { | |
| 258 | const shdr = shdrs[1]; | |
| 259 | allocSymbol(self, index, shdr.sh_addr, 0, elf_file); | |
| 260 | } | |
| 260 | 261 | } |
| 261 | 262 | |
| 262 | 263 | // __GNU_EH_FRAME_HDR |
src/link/Elf/Object.zig+5-6| ... | ... | @@ -524,12 +524,6 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void { |
| 524 | 524 | const first_global = self.first_global orelse return; |
| 525 | 525 | for (self.globals(), first_global..) |_, i| { |
| 526 | 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 | 527 | const resolv = &self.symbols_resolver.items[i - first_global]; |
| 534 | 528 | const gop = try elf_file.resolver.getOrPut(gpa, .{ |
| 535 | 529 | .index = @intCast(i), |
| ... | ... | @@ -541,6 +535,11 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void { |
| 541 | 535 | resolv.* = gop.index; |
| 542 | 536 | |
| 543 | 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 | 543 | if (elf_file.symbol(gop.ref.*) == null) { |
| 545 | 544 | gop.ref.* = .{ .index = @intCast(i), .file = self.index }; |
| 546 | 545 | continue; |
src/link/Elf/Symbol.zig-1| ... | ... | @@ -471,7 +471,6 @@ pub const Extra = struct { |
| 471 | 471 | tlsgd: u32 = 0, |
| 472 | 472 | gottp: u32 = 0, |
| 473 | 473 | tlsdesc: u32 = 0, |
| 474 | merge_section: u32 = 0, | |
| 475 | 474 | trampoline: u32 = 0, |
| 476 | 475 | }; |
| 477 | 476 |
src/link/Elf/ZigObject.zig+5-6| ... | ... | @@ -603,12 +603,6 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void { |
| 603 | 603 | const global = &self.symbols.items[index]; |
| 604 | 604 | const esym = global.elfSym(elf_file); |
| 605 | 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 | 606 | const resolv = &self.symbols_resolver.items[i]; |
| 613 | 607 | const gop = try elf_file.resolver.getOrPut(gpa, .{ |
| 614 | 608 | .index = @intCast(i | global_symbol_bit), |
| ... | ... | @@ -620,6 +614,11 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void { |
| 620 | 614 | resolv.* = gop.index; |
| 621 | 615 | |
| 622 | 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 | 622 | if (elf_file.symbol(gop.ref.*) == null) { |
| 624 | 623 | gop.ref.* = .{ .index = @intCast(i | global_symbol_bit), .file = self.index }; |
| 625 | 624 | continue; |