mirror of
https://github.com/ziglang/zig.git
synced 2026-01-02 03:25:01 +00:00
zld: more fixes todo with symbol resolution
namely, fixes proper symbol reolution when scanning and including objects from static archives, and properly discard any null symbols when a tentative definition was substituted by a defined, global symbol.
This commit is contained in:
parent
d8c4838c7d
commit
a095263462
@ -1636,7 +1636,11 @@ fn resolveSymbols(self: *Zld) !void {
|
||||
}
|
||||
|
||||
// Second pass, resolve symbols in static libraries.
|
||||
loop: for (self.undefs.items) |sym| {
|
||||
var next_sym: usize = 0;
|
||||
loop: while (true) : (next_sym += 1) {
|
||||
if (next_sym == self.undefs.items.len) break;
|
||||
|
||||
const sym = self.undefs.items[next_sym];
|
||||
if (symbolIsNull(sym)) continue;
|
||||
|
||||
const sym_name = self.getString(sym.n_strx);
|
||||
@ -1661,6 +1665,8 @@ fn resolveSymbols(self: *Zld) !void {
|
||||
// Convert any tentative definition into a regular symbol and allocate
|
||||
// text blocks for each tentative defintion.
|
||||
for (self.tentatives.items) |sym| {
|
||||
if (symbolIsNull(sym)) continue;
|
||||
|
||||
const sym_name = self.getString(sym.n_strx);
|
||||
const match: MatchingSection = blk: {
|
||||
if (self.common_section_index == null) {
|
||||
@ -1813,6 +1819,13 @@ fn resolveSymbols(self: *Zld) !void {
|
||||
.n_desc = macho.N_WEAK_DEF,
|
||||
.n_value = seg.inner.vmaddr,
|
||||
});
|
||||
undef.* = .{
|
||||
.n_strx = 0,
|
||||
.n_type = macho.N_UNDF,
|
||||
.n_sect = 0,
|
||||
.n_desc = 0,
|
||||
.n_value = 0,
|
||||
};
|
||||
resolv.* = .{
|
||||
.where = .global,
|
||||
.where_index = global_sym_index,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user