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