mirror of
https://github.com/ziglang/zig.git
synced 2024-12-17 00:30:15 +00:00
commit
8c232922bd
@ -47,7 +47,7 @@ fn newSymbolAssumeCapacity(self: *LinkerDefined, name_off: u32, elf_file: *Elf)
|
||||
const esym = self.symtab.addOneAssumeCapacity();
|
||||
esym.* = .{
|
||||
.st_name = name_off,
|
||||
.st_info = elf.STB_GLOBAL << 4,
|
||||
.st_info = elf.STB_WEAK << 4,
|
||||
.st_other = @intFromEnum(elf.STV.HIDDEN),
|
||||
.st_shndx = elf.SHN_ABS,
|
||||
.st_value = 0,
|
||||
@ -158,7 +158,6 @@ pub fn initStartStopSymbols(self: *LinkerDefined, elf_file: *Elf) !void {
|
||||
.index = index,
|
||||
.file = self.index,
|
||||
}, elf_file);
|
||||
assert(!gop.found_existing);
|
||||
gop.ref.* = .{ .index = index, .file = self.index };
|
||||
self.symbols_resolver.appendAssumeCapacity(gop.index);
|
||||
}
|
||||
@ -255,8 +254,10 @@ pub fn allocateSymbols(self: *LinkerDefined, elf_file: *Elf) void {
|
||||
|
||||
// __dso_handle
|
||||
if (self.dso_handle_index) |index| {
|
||||
const shdr = shdrs[1];
|
||||
allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
|
||||
if (self.resolveSymbol(index, elf_file).file == self.index) {
|
||||
const shdr = shdrs[1];
|
||||
allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
|
||||
}
|
||||
}
|
||||
|
||||
// __GNU_EH_FRAME_HDR
|
||||
|
@ -524,12 +524,6 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void {
|
||||
const first_global = self.first_global orelse return;
|
||||
for (self.globals(), first_global..) |_, i| {
|
||||
const esym = self.symtab.items[i];
|
||||
if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON and esym.st_shndx != elf.SHN_UNDEF) {
|
||||
const atom_index = self.atoms_indexes.items[esym.st_shndx];
|
||||
const atom_ptr = self.atom(atom_index) orelse continue;
|
||||
if (!atom_ptr.alive) continue;
|
||||
}
|
||||
|
||||
const resolv = &self.symbols_resolver.items[i - first_global];
|
||||
const gop = try elf_file.resolver.getOrPut(gpa, .{
|
||||
.index = @intCast(i),
|
||||
@ -541,6 +535,11 @@ pub fn resolveSymbols(self: *Object, elf_file: *Elf) !void {
|
||||
resolv.* = gop.index;
|
||||
|
||||
if (esym.st_shndx == elf.SHN_UNDEF) continue;
|
||||
if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) {
|
||||
const atom_index = self.atoms_indexes.items[esym.st_shndx];
|
||||
const atom_ptr = self.atom(atom_index) orelse continue;
|
||||
if (!atom_ptr.alive) continue;
|
||||
}
|
||||
if (elf_file.symbol(gop.ref.*) == null) {
|
||||
gop.ref.* = .{ .index = @intCast(i), .file = self.index };
|
||||
continue;
|
||||
|
@ -471,7 +471,6 @@ pub const Extra = struct {
|
||||
tlsgd: u32 = 0,
|
||||
gottp: u32 = 0,
|
||||
tlsdesc: u32 = 0,
|
||||
merge_section: u32 = 0,
|
||||
trampoline: u32 = 0,
|
||||
};
|
||||
|
||||
|
@ -603,12 +603,6 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void {
|
||||
const global = &self.symbols.items[index];
|
||||
const esym = global.elfSym(elf_file);
|
||||
const shndx = self.symtab.items(.shndx)[global.esym_index];
|
||||
if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON and esym.st_shndx != elf.SHN_UNDEF) {
|
||||
assert(esym.st_shndx == SHN_ATOM);
|
||||
const atom_ptr = self.atom(shndx) orelse continue;
|
||||
if (!atom_ptr.alive) continue;
|
||||
}
|
||||
|
||||
const resolv = &self.symbols_resolver.items[i];
|
||||
const gop = try elf_file.resolver.getOrPut(gpa, .{
|
||||
.index = @intCast(i | global_symbol_bit),
|
||||
@ -620,6 +614,11 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) !void {
|
||||
resolv.* = gop.index;
|
||||
|
||||
if (esym.st_shndx == elf.SHN_UNDEF) continue;
|
||||
if (esym.st_shndx != elf.SHN_ABS and esym.st_shndx != elf.SHN_COMMON) {
|
||||
assert(esym.st_shndx == SHN_ATOM);
|
||||
const atom_ptr = self.atom(shndx) orelse continue;
|
||||
if (!atom_ptr.alive) continue;
|
||||
}
|
||||
if (elf_file.symbol(gop.ref.*) == null) {
|
||||
gop.ref.* = .{ .index = @intCast(i | global_symbol_bit), .file = self.index };
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user