| ... | @@ -1193,7 +1193,9 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1193,7 +1193,9 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1193 | const need_realloc = code.len > capacity or !mem.isAlignedGeneric(u64, symbol.n_value, required_alignment); | 1193 | const need_realloc = code.len > capacity or !mem.isAlignedGeneric(u64, symbol.n_value, required_alignment); |
| 1194 | if (need_realloc) { | 1194 | if (need_realloc) { |
| 1195 | const vaddr = try self.growTextBlock(&decl.link.macho, code.len, required_alignment); | 1195 | const vaddr = try self.growTextBlock(&decl.link.macho, code.len, required_alignment); |
| 1196 | log.debug("growing {s} from 0x{x} to 0x{x}", .{ decl.name, symbol.n_value, vaddr }); | 1196 | |
| | 1197 | log.debug("growing {s} and moving from 0x{x} to 0x{x}", .{ decl.name, symbol.n_value, vaddr }); |
| | 1198 | |
| 1197 | if (vaddr != symbol.n_value) { | 1199 | if (vaddr != symbol.n_value) { |
| 1198 | log.debug(" (writing new offset table entry)", .{}); | 1200 | log.debug(" (writing new offset table entry)", .{}); |
| 1199 | self.offset_table.items[decl.link.macho.offset_table_index] = .{ | 1201 | self.offset_table.items[decl.link.macho.offset_table_index] = .{ |
| ... | @@ -1203,6 +1205,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1203,6 +1205,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1203 | }; | 1205 | }; |
| 1204 | try self.writeOffsetTableEntry(decl.link.macho.offset_table_index); | 1206 | try self.writeOffsetTableEntry(decl.link.macho.offset_table_index); |
| 1205 | } | 1207 | } |
| | 1208 | |
| | 1209 | symbol.n_value = vaddr; |
| 1206 | } else if (code.len < decl.link.macho.size) { | 1210 | } else if (code.len < decl.link.macho.size) { |
| 1207 | self.shrinkTextBlock(&decl.link.macho, code.len); | 1211 | self.shrinkTextBlock(&decl.link.macho, code.len); |
| 1208 | } | 1212 | } |
| ... | @@ -1219,7 +1223,9 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { | ... | @@ -1219,7 +1223,9 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { |
| 1219 | const decl_name = mem.spanZ(decl.name); | 1223 | const decl_name = mem.spanZ(decl.name); |
| 1220 | const name_str_index = try self.makeString(decl_name); | 1224 | const name_str_index = try self.makeString(decl_name); |
| 1221 | const addr = try self.allocateTextBlock(&decl.link.macho, code.len, required_alignment); | 1225 | const addr = try self.allocateTextBlock(&decl.link.macho, code.len, required_alignment); |
| | 1226 | |
| 1222 | log.debug("allocated text block for {s} at 0x{x}", .{ decl_name, addr }); | 1227 | log.debug("allocated text block for {s} at 0x{x}", .{ decl_name, addr }); |
| | 1228 | |
| 1223 | errdefer self.freeTextBlock(&decl.link.macho); | 1229 | errdefer self.freeTextBlock(&decl.link.macho); |
| 1224 | | 1230 | |
| 1225 | symbol.* = .{ | 1231 | symbol.* = .{ |