authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-10 17:19:37+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-10 17:19:37+02:00
log421b105d85507e6e3a98cfcf932ca6a8d14e2791
tree61fd792f9198778593fac9c5785f5f23fac25c00
parent3f2a0c3de47c8d359f3c7316badc281237d6c494

macho: ensure we only ever put named symbols in the symtab


1 files changed, 3 insertions(+), 1 deletions(-)

src/link/MachO/ZigObject.zig+3-1
......@@ -550,6 +550,8 @@ pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void {
550550 const file = ref.getFile(macho_file) orelse continue;
551551 if (file.getIndex() != self.index) continue;
552552 if (sym.getAtom(macho_file)) |atom| if (!atom.isAlive()) continue;
553 const name = sym.getName(macho_file);
554 assert(name.len > 0);
553555 sym.flags.output_symtab = true;
554556 if (sym.isLocal()) {
555557 sym.addExtra(.{ .symtab = self.output_symtab_ctx.nlocals }, macho_file);
......@@ -562,7 +564,7 @@ pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void {
562564 sym.addExtra(.{ .symtab = self.output_symtab_ctx.nimports }, macho_file);
563565 self.output_symtab_ctx.nimports += 1;
564566 }
565 self.output_symtab_ctx.strsize += @as(u32, @intCast(sym.getName(macho_file).len + 1));
567 self.output_symtab_ctx.strsize += @as(u32, @intCast(name.len + 1));
566568 }
567569}
568570