Commit f7fea080b2

Jakub Konka <kubkon@jakubkonka.com>
2022-12-09 16:21:48
macho+zld: skip atomless synthetic globals in dead_strip
They are implicitly marked live.
1 parent bd5a8f8
Changed files (1)
src
link
src/link/MachO/dead_strip.zig
@@ -58,7 +58,8 @@ fn collectRoots(zld: *Zld, roots: *AtomTable) !void {
                 const sym = zld.getSymbol(global);
                 if (sym.undf()) continue;
 
-                const object = zld.objects.items[global.getFile().?];
+                const file = global.getFile() orelse continue; // synthetic globals are atomless
+                const object = zld.objects.items[file];
                 const atom_index = object.getAtomIndexForSymbol(global.sym_index).?; // panic here means fatal error
                 _ = try roots.getOrPut(atom_index);