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 {...@@ -550,6 +550,8 @@ pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void {
550 const file = ref.getFile(macho_file) orelse continue;550 const file = ref.getFile(macho_file) orelse continue;
551 if (file.getIndex() != self.index) continue;551 if (file.getIndex() != self.index) continue;
552 if (sym.getAtom(macho_file)) |atom| if (!atom.isAlive()) continue;552 if (sym.getAtom(macho_file)) |atom| if (!atom.isAlive()) continue;
553 const name = sym.getName(macho_file);
554 assert(name.len > 0);
553 sym.flags.output_symtab = true;555 sym.flags.output_symtab = true;
554 if (sym.isLocal()) {556 if (sym.isLocal()) {
555 sym.addExtra(.{ .symtab = self.output_symtab_ctx.nlocals }, macho_file);557 sym.addExtra(.{ .symtab = self.output_symtab_ctx.nlocals }, macho_file);
...@@ -562,7 +564,7 @@ pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void {...@@ -562,7 +564,7 @@ pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void {
562 sym.addExtra(.{ .symtab = self.output_symtab_ctx.nimports }, macho_file);564 sym.addExtra(.{ .symtab = self.output_symtab_ctx.nimports }, macho_file);
563 self.output_symtab_ctx.nimports += 1;565 self.output_symtab_ctx.nimports += 1;
564 }566 }
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));
566 }568 }
567}569}
568570