| ... | @@ -2584,12 +2584,11 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { | ... | @@ -2584,12 +2584,11 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { |
| 2584 | return error.UnhandledSymbolType; | 2584 | return error.UnhandledSymbolType; |
| 2585 | } | 2585 | } |
| 2586 | | 2586 | |
| 2587 | const n_strx = try self.makeString(sym_name); | | |
| 2588 | if (sym.sect()) { | 2587 | if (sym.sect()) { |
| 2589 | // Defined symbol regardless of scope lands in the locals symbol table. | 2588 | // Defined symbol regardless of scope lands in the locals symbol table. |
| 2590 | const local_sym_index = @intCast(u32, self.locals.items.len); | 2589 | const local_sym_index = @intCast(u32, self.locals.items.len); |
| 2591 | try self.locals.append(self.base.allocator, .{ | 2590 | try self.locals.append(self.base.allocator, .{ |
| 2592 | .n_strx = n_strx, | 2591 | .n_strx = if (symbolIsTemp(sym, sym_name)) 0 else try self.makeString(sym_name), |
| 2593 | .n_type = macho.N_SECT, | 2592 | .n_type = macho.N_SECT, |
| 2594 | .n_sect = 0, | 2593 | .n_sect = 0, |
| 2595 | .n_desc = 0, | 2594 | .n_desc = 0, |
| ... | @@ -2602,6 +2601,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { | ... | @@ -2602,6 +2601,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { |
| 2602 | // if we should save the symbol as a global, or potentially flag the error. | 2601 | // if we should save the symbol as a global, or potentially flag the error. |
| 2603 | if (!sym.ext()) continue; | 2602 | if (!sym.ext()) continue; |
| 2604 | | 2603 | |
| | 2604 | const n_strx = try self.makeString(sym_name); |
| 2605 | const local = self.locals.items[local_sym_index]; | 2605 | const local = self.locals.items[local_sym_index]; |
| 2606 | const resolv = self.symbol_resolver.getPtr(n_strx) orelse { | 2606 | const resolv = self.symbol_resolver.getPtr(n_strx) orelse { |
| 2607 | const global_sym_index = @intCast(u32, self.globals.items.len); | 2607 | const global_sym_index = @intCast(u32, self.globals.items.len); |
| ... | @@ -2672,6 +2672,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { | ... | @@ -2672,6 +2672,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { |
| 2672 | }; | 2672 | }; |
| 2673 | } else if (sym.tentative()) { | 2673 | } else if (sym.tentative()) { |
| 2674 | // Symbol is a tentative definition. | 2674 | // Symbol is a tentative definition. |
| | 2675 | const n_strx = try self.makeString(sym_name); |
| 2675 | const resolv = self.symbol_resolver.getPtr(n_strx) orelse { | 2676 | const resolv = self.symbol_resolver.getPtr(n_strx) orelse { |
| 2676 | const global_sym_index = @intCast(u32, self.globals.items.len); | 2677 | const global_sym_index = @intCast(u32, self.globals.items.len); |
| 2677 | try self.globals.append(self.base.allocator, .{ | 2678 | try self.globals.append(self.base.allocator, .{ |
| ... | @@ -2729,6 +2730,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { | ... | @@ -2729,6 +2730,7 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void { |
| 2729 | } | 2730 | } |
| 2730 | } else { | 2731 | } else { |
| 2731 | // Symbol is undefined. | 2732 | // Symbol is undefined. |
| | 2733 | const n_strx = try self.makeString(sym_name); |
| 2732 | if (self.symbol_resolver.contains(n_strx)) continue; | 2734 | if (self.symbol_resolver.contains(n_strx)) continue; |
| 2733 | | 2735 | |
| 2734 | const undef_sym_index = @intCast(u32, self.undefs.items.len); | 2736 | const undef_sym_index = @intCast(u32, self.undefs.items.len); |
| ... | @@ -5394,7 +5396,7 @@ fn writeSymbolTable(self: *MachO) !void { | ... | @@ -5394,7 +5396,7 @@ fn writeSymbolTable(self: *MachO) !void { |
| 5394 | | 5396 | |
| 5395 | for (self.locals.items) |sym| { | 5397 | for (self.locals.items) |sym| { |
| 5396 | if (sym.n_strx == 0) continue; | 5398 | if (sym.n_strx == 0) continue; |
| 5397 | if (symbolIsTemp(sym, self.getString(sym.n_strx))) continue; | 5399 | if (self.symbol_resolver.get(sym.n_strx)) |_| continue; |
| 5398 | try locals.append(sym); | 5400 | try locals.append(sym); |
| 5399 | } | 5401 | } |
| 5400 | | 5402 | |