authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-03 23:39:32+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-12 10:20:57+02:00
logf01366e8b3ff46831feef2ceb13c5602c0ae3e99
tree02f47e0e84de912c6de20edf58f3ecc502a1a278
parent35403d41ce7845628d608ffd6fe16aa334f017ef

macho: exclude tentative def before checking for collision

when resolving global symbols.

1 files changed, 4 insertions(+), 7 deletions(-)

src/link/MachO.zig+4-7
...@@ -2167,19 +2167,16 @@ fn resolveSymbolsInObject(...@@ -2167,19 +2167,16 @@ fn resolveSymbolsInObject(
2167 .global => {2167 .global => {
2168 const global = &self.globals.items[resolv.where_index];2168 const global = &self.globals.items[resolv.where_index];
21692169
2170 if (!(symbolIsWeakDef(sym) or symbolIsPext(sym)) and2170 if (symbolIsTentative(global.*)) {
2171 _ = tentatives.fetchSwapRemove(resolv.where_index);
2172 } else if (!(symbolIsWeakDef(sym) or symbolIsPext(sym)) and
2171 !(symbolIsWeakDef(global.*) or symbolIsPext(global.*)))2173 !(symbolIsWeakDef(global.*) or symbolIsPext(global.*)))
2172 {2174 {
2173 log.err("symbol '{s}' defined multiple times", .{sym_name});2175 log.err("symbol '{s}' defined multiple times", .{sym_name});
2174 log.err(" first definition in '{s}'", .{self.objects.items[resolv.file].name});2176 log.err(" first definition in '{s}'", .{self.objects.items[resolv.file].name});
2175 log.err(" next definition in '{s}'", .{object.name});2177 log.err(" next definition in '{s}'", .{object.name});
2176 return error.MultipleSymbolDefinitions;2178 return error.MultipleSymbolDefinitions;
2177 }2179 } else if (symbolIsWeakDef(sym) or symbolIsPext(sym)) continue; // Current symbol is weak, so skip it.
2178 if (symbolIsWeakDef(sym) or symbolIsPext(sym)) continue; // Current symbol is weak, so skip it.
2179
2180 if (symbolIsTentative(global.*)) {
2181 _ = tentatives.fetchSwapRemove(resolv.where_index);
2182 }
21832180
2184 // Otherwise, update the resolver and the global symbol.2181 // Otherwise, update the resolver and the global symbol.
2185 global.n_type = sym.n_type;2182 global.n_type = sym.n_type;