From a41180633e81f6c21331fd51255264c4a5f2045c Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 9 Dec 2022 16:21:48 +0100 Subject: [PATCH] macho+zld: skip atomless synthetic globals in dead_strip They are implicitly marked live. --- src/link/MachO/dead_strip.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/link/MachO/dead_strip.zig b/src/link/MachO/dead_strip.zig index aee03bb1d9d4..ab36ef8a766c 100644 --- a/src/link/MachO/dead_strip.zig +++ b/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);