mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
macho: do not assume entrypoint is defined
This commit is contained in:
parent
5d0bb50e3d
commit
2dd178443a
1 changed files with 12 additions and 8 deletions
|
|
@ -43,15 +43,19 @@ fn collectRoots(zld: *Zld, roots: *AtomTable) !void {
|
||||||
.Exe => {
|
.Exe => {
|
||||||
// Add entrypoint as GC root
|
// Add entrypoint as GC root
|
||||||
const global: SymbolWithLoc = zld.getEntryPoint();
|
const global: SymbolWithLoc = zld.getEntryPoint();
|
||||||
const object = zld.objects.items[global.getFile().?];
|
if (global.getFile()) |file| {
|
||||||
const atom_index = object.getAtomIndexForSymbol(global.sym_index).?; // panic here means fatal error
|
const object = zld.objects.items[file];
|
||||||
_ = try roots.getOrPut(atom_index);
|
const atom_index = object.getAtomIndexForSymbol(global.sym_index).?; // panic here means fatal error
|
||||||
|
_ = try roots.getOrPut(atom_index);
|
||||||
|
|
||||||
log.debug("root(ATOM({d}, %{d}, {?d}))", .{
|
log.debug("root(ATOM({d}, %{d}, {?d}))", .{
|
||||||
atom_index,
|
atom_index,
|
||||||
zld.getAtom(atom_index).sym_index,
|
zld.getAtom(atom_index).sym_index,
|
||||||
zld.getAtom(atom_index).getFile(),
|
zld.getAtom(atom_index).getFile(),
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
assert(zld.getSymbol(global).undf()); // Stub as our entrypoint is in a dylib.
|
||||||
|
}
|
||||||
},
|
},
|
||||||
else => |other| {
|
else => |other| {
|
||||||
assert(other == .Lib);
|
assert(other == .Lib);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue