| ... | ... | @@ -43,15 +43,19 @@ fn collectRoots(zld: *Zld, roots: *AtomTable) !void { |
| 43 | 43 | .Exe => { |
| 44 | 44 | // Add entrypoint as GC root |
| 45 | 45 | const global: SymbolWithLoc = zld.getEntryPoint(); |
| 46 | | const object = zld.objects.items[global.getFile().?]; |
| 47 | | const atom_index = object.getAtomIndexForSymbol(global.sym_index).?; // panic here means fatal error |
| 48 | | _ = try roots.getOrPut(atom_index); |
| 46 | if (global.getFile()) |file| { |
| 47 | const object = zld.objects.items[file]; |
| 48 | const atom_index = object.getAtomIndexForSymbol(global.sym_index).?; // panic here means fatal error |
| 49 | _ = try roots.getOrPut(atom_index); |
| 49 | 50 | |
| 50 | | log.debug("root(ATOM({d}, %{d}, {?d}))", .{ |
| 51 | | atom_index, |
| 52 | | zld.getAtom(atom_index).sym_index, |
| 53 | | zld.getAtom(atom_index).getFile(), |
| 54 | | }); |
| 51 | log.debug("root(ATOM({d}, %{d}, {?d}))", .{ |
| 52 | atom_index, |
| 53 | zld.getAtom(atom_index).sym_index, |
| 54 | zld.getAtom(atom_index).getFile(), |
| 55 | }); |
| 56 | } else { |
| 57 | assert(zld.getSymbol(global).undf()); // Stub as our entrypoint is in a dylib. |
| 58 | } |
| 55 | 59 | }, |
| 56 | 60 | else => |other| { |
| 57 | 61 | assert(other == .Lib); |