authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-08-27 22:42:04+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-08-29 11:40:20+02:00
log0353bfd55ed67fa5c1c1d0e3004fcbae7f139b92
tree7a53fed6216bea552ba60d61f24109aeebd9d0b0
parent5eb6c81d07d2df43f6df5e0a421b93dac10f8fed

macho: fix a few regressions in incremental codepath


1 files changed, 12 insertions(+), 7 deletions(-)

src/link/MachO.zig+12-7
...@@ -1650,12 +1650,16 @@ fn resolveGlobalSymbol(self: *MachO, current: SymbolWithLoc) !void {...@@ -1650,12 +1650,16 @@ fn resolveGlobalSymbol(self: *MachO, current: SymbolWithLoc) !void {
1650 const global_is_weak = global_sym.sect() and (global_sym.weakDef() or global_sym.pext());1650 const global_is_weak = global_sym.sect() and (global_sym.weakDef() or global_sym.pext());
16511651
1652 if (sym_is_strong and global_is_strong) {1652 if (sym_is_strong and global_is_strong) {
1653 log.err("symbol '{s}' defined multiple times", .{sym_name});1653 // TODO redo this logic with corresponding logic in updateDeclExports to avoid this
1654 if (global.getFile()) |file| {1654 // ugly check.
1655 log.err(" first definition in '{s}'", .{self.objects.items[file].name});1655 if (self.mode == .zld) {
1656 }1656 log.err("symbol '{s}' defined multiple times", .{sym_name});
1657 if (current.getFile()) |file| {1657 if (global.getFile()) |file| {
1658 log.err(" next definition in '{s}'", .{self.objects.items[file].name});1658 log.err(" first definition in '{s}'", .{self.objects.items[file].name});
1659 }
1660 if (current.getFile()) |file| {
1661 log.err(" next definition in '{s}'", .{self.objects.items[file].name});
1662 }
1659 }1663 }
1660 return error.MultipleSymbolDefinitions;1664 return error.MultipleSymbolDefinitions;
1661 }1665 }
...@@ -3079,6 +3083,7 @@ fn allocateSection(self: *MachO, segname: []const u8, sectname: []const u8, opts...@@ -3079,6 +3083,7 @@ fn allocateSection(self: *MachO, segname: []const u8, sectname: []const u8, opts
3079 section.offset = mem.alignForward(u32, @as(u32, @intCast(off)), opts.alignment);3083 section.offset = mem.alignForward(u32, @as(u32, @intCast(off)), opts.alignment);
3080 section.size = opts.size;3084 section.size = opts.size;
3081 section.@"align" = math.log2(opts.alignment);3085 section.@"align" = math.log2(opts.alignment);
3086 self.sections.items(.segment_index)[sect_id] = segment_id;
3082 assert(!section.isZerofill()); // TODO zerofill sections3087 assert(!section.isZerofill()); // TODO zerofill sections
30833088
3084 return sect_id;3089 return sect_id;
...@@ -4053,8 +4058,8 @@ fn writeSymtab(self: *MachO) !SymtabCtx {...@@ -4053,8 +4058,8 @@ fn writeSymtab(self: *MachO) !SymtabCtx {
4053 // We generate stabs last in order to ensure that the strtab always has debug info4058 // We generate stabs last in order to ensure that the strtab always has debug info
4054 // strings trailing4059 // strings trailing
4055 if (!self.base.options.strip) {4060 if (!self.base.options.strip) {
4056 assert(self.d_sym == null); // TODO
4057 for (self.objects.items) |object| {4061 for (self.objects.items) |object| {
4062 assert(self.d_sym == null); // TODO
4058 try self.generateSymbolStabs(object, &locals);4063 try self.generateSymbolStabs(object, &locals);
4059 }4064 }
4060 }4065 }