mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
elf: fix symbol resolution for Objects
This commit is contained in:
parent
04f8f8ad3e
commit
26da7c8207
@ -447,8 +447,13 @@ fn formatSymtab(
|
||||
const self = ctx.self;
|
||||
const elf_file = ctx.elf_file;
|
||||
try writer.writeAll(" globals\n");
|
||||
for (self.symbols.items) |sym| {
|
||||
try writer.print(" {}\n", .{sym.fmt(elf_file)});
|
||||
for (self.symbols.items, 0..) |sym, i| {
|
||||
const ref = self.resolveSymbol(@intCast(i), elf_file);
|
||||
if (elf_file.symbol(ref)) |ref_sym| {
|
||||
try writer.print(" {}\n", .{ref_sym.fmt(elf_file)});
|
||||
} else {
|
||||
try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -612,7 +612,7 @@ 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) {
|
||||
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;
|
||||
@ -1492,8 +1492,14 @@ fn formatSymtab(
|
||||
try writer.print(" {}\n", .{sym.fmt(elf_file)});
|
||||
}
|
||||
try writer.writeAll(" globals\n");
|
||||
for (object.globals()) |sym| {
|
||||
try writer.print(" {}\n", .{sym.fmt(elf_file)});
|
||||
for (object.globals(), 0..) |sym, i| {
|
||||
const first_global = object.first_global.?;
|
||||
const ref = object.resolveSymbol(@intCast(i + first_global), elf_file);
|
||||
if (elf_file.symbol(ref)) |ref_sym| {
|
||||
try writer.print(" {}\n", .{ref_sym.fmt(elf_file)});
|
||||
} else {
|
||||
try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -493,8 +493,13 @@ fn formatSymtab(
|
||||
const shared = ctx.shared;
|
||||
const elf_file = ctx.elf_file;
|
||||
try writer.writeAll(" globals\n");
|
||||
for (shared.symbols.items) |sym| {
|
||||
try writer.print(" {}\n", .{sym.fmt(elf_file)});
|
||||
for (shared.symbols.items, 0..) |sym, i| {
|
||||
const ref = shared.resolveSymbol(@intCast(i), elf_file);
|
||||
if (elf_file.symbol(ref)) |ref_sym| {
|
||||
try writer.print(" {}\n", .{ref_sym.fmt(elf_file)});
|
||||
} else {
|
||||
try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -417,9 +417,9 @@ pub const ZigGotSection = struct {
|
||||
_ = unused_fmt_string;
|
||||
const zig_got = ctx.zig_got;
|
||||
const elf_file = ctx.elf_file;
|
||||
const zo = elf_file.zigObjectPtr().?;
|
||||
try writer.writeAll(".zig.got\n");
|
||||
for (zig_got.entries.items, 0..) |entry, index| {
|
||||
const zo = elf_file.zigObjectPtr().?;
|
||||
const symbol = zo.symbol(entry);
|
||||
try writer.print(" {d}@0x{x} => {d}@0x{x} ({s})\n", .{
|
||||
index,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user