| ... | @@ -1636,7 +1636,11 @@ fn resolveSymbols(self: *Zld) !void { | ... | @@ -1636,7 +1636,11 @@ fn resolveSymbols(self: *Zld) !void { |
| 1636 | } | 1636 | } |
| 1637 | | 1637 | |
| 1638 | // Second pass, resolve symbols in static libraries. | 1638 | // Second pass, resolve symbols in static libraries. |
| 1639 | loop: for (self.undefs.items) |sym| { | 1639 | var next_sym: usize = 0; |
| | 1640 | loop: while (true) : (next_sym += 1) { |
| | 1641 | if (next_sym == self.undefs.items.len) break; |
| | 1642 | |
| | 1643 | const sym = self.undefs.items[next_sym]; |
| 1640 | if (symbolIsNull(sym)) continue; | 1644 | if (symbolIsNull(sym)) continue; |
| 1641 | | 1645 | |
| 1642 | const sym_name = self.getString(sym.n_strx); | 1646 | const sym_name = self.getString(sym.n_strx); |
| ... | @@ -1661,6 +1665,8 @@ fn resolveSymbols(self: *Zld) !void { | ... | @@ -1661,6 +1665,8 @@ fn resolveSymbols(self: *Zld) !void { |
| 1661 | // Convert any tentative definition into a regular symbol and allocate | 1665 | // Convert any tentative definition into a regular symbol and allocate |
| 1662 | // text blocks for each tentative defintion. | 1666 | // text blocks for each tentative defintion. |
| 1663 | for (self.tentatives.items) |sym| { | 1667 | for (self.tentatives.items) |sym| { |
| | 1668 | if (symbolIsNull(sym)) continue; |
| | 1669 | |
| 1664 | const sym_name = self.getString(sym.n_strx); | 1670 | const sym_name = self.getString(sym.n_strx); |
| 1665 | const match: MatchingSection = blk: { | 1671 | const match: MatchingSection = blk: { |
| 1666 | if (self.common_section_index == null) { | 1672 | if (self.common_section_index == null) { |
| ... | @@ -1813,6 +1819,13 @@ fn resolveSymbols(self: *Zld) !void { | ... | @@ -1813,6 +1819,13 @@ fn resolveSymbols(self: *Zld) !void { |
| 1813 | .n_desc = macho.N_WEAK_DEF, | 1819 | .n_desc = macho.N_WEAK_DEF, |
| 1814 | .n_value = seg.inner.vmaddr, | 1820 | .n_value = seg.inner.vmaddr, |
| 1815 | }); | 1821 | }); |
| | 1822 | undef.* = .{ |
| | 1823 | .n_strx = 0, |
| | 1824 | .n_type = macho.N_UNDF, |
| | 1825 | .n_sect = 0, |
| | 1826 | .n_desc = 0, |
| | 1827 | .n_value = 0, |
| | 1828 | }; |
| 1816 | resolv.* = .{ | 1829 | resolv.* = .{ |
| 1817 | .where = .global, | 1830 | .where = .global, |
| 1818 | .where_index = global_sym_index, | 1831 | .where_index = global_sym_index, |