| ... | @@ -12357,7 +12357,16 @@ fn genCall(self: *Self, info: union(enum) { | ... | @@ -12357,7 +12357,16 @@ fn genCall(self: *Self, info: union(enum) { |
| 12357 | }); | 12357 | }); |
| 12358 | } else unreachable; | 12358 | } else unreachable; |
| 12359 | }, | 12359 | }, |
| 12360 | .@"extern" => |@"extern"| try self.genExternSymbolRef( | 12360 | .@"extern" => |@"extern"| if (self.bin_file.cast(.elf)) |elf_file| { |
| | 12361 | const target_sym_index = try elf_file.getGlobalSymbol( |
| | 12362 | @"extern".name.toSlice(ip), |
| | 12363 | @"extern".lib_name.toSlice(ip), |
| | 12364 | ); |
| | 12365 | try self.asmImmediate(.{ ._, .call }, Immediate.rel(.{ |
| | 12366 | .atom_index = try self.owner.getSymbolIndex(self), |
| | 12367 | .sym_index = target_sym_index, |
| | 12368 | })); |
| | 12369 | } else try self.genExternSymbolRef( |
| 12361 | .call, | 12370 | .call, |
| 12362 | @"extern".lib_name.toSlice(ip), | 12371 | @"extern".lib_name.toSlice(ip), |
| 12363 | @"extern".name.toSlice(ip), | 12372 | @"extern".name.toSlice(ip), |
| ... | @@ -12369,7 +12378,13 @@ fn genCall(self: *Self, info: union(enum) { | ... | @@ -12369,7 +12378,13 @@ fn genCall(self: *Self, info: union(enum) { |
| 12369 | try self.genSetReg(.rax, Type.usize, .{ .air_ref = callee }, .{}); | 12378 | try self.genSetReg(.rax, Type.usize, .{ .air_ref = callee }, .{}); |
| 12370 | try self.asmRegister(.{ ._, .call }, .rax); | 12379 | try self.asmRegister(.{ ._, .call }, .rax); |
| 12371 | }, | 12380 | }, |
| 12372 | .lib => |lib| try self.genExternSymbolRef(.call, lib.lib, lib.callee), | 12381 | .lib => |lib| if (self.bin_file.cast(.elf)) |elf_file| { |
| | 12382 | const target_sym_index = try elf_file.getGlobalSymbol(lib.callee, lib.lib); |
| | 12383 | try self.asmImmediate(.{ ._, .call }, Immediate.rel(.{ |
| | 12384 | .atom_index = try self.owner.getSymbolIndex(self), |
| | 12385 | .sym_index = target_sym_index, |
| | 12386 | })); |
| | 12387 | } else try self.genExternSymbolRef(.call, lib.lib, lib.callee), |
| 12373 | } | 12388 | } |
| 12374 | return call_info.return_value.short; | 12389 | return call_info.return_value.short; |
| 12375 | } | 12390 | } |
| ... | @@ -15245,16 +15260,7 @@ fn genExternSymbolRef( | ... | @@ -15245,16 +15260,7 @@ fn genExternSymbolRef( |
| 15245 | callee: []const u8, | 15260 | callee: []const u8, |
| 15246 | ) InnerError!void { | 15261 | ) InnerError!void { |
| 15247 | const atom_index = try self.owner.getSymbolIndex(self); | 15262 | const atom_index = try self.owner.getSymbolIndex(self); |
| 15248 | if (self.bin_file.cast(.elf)) |elf_file| { | 15263 | if (self.bin_file.cast(.coff)) |coff_file| { |
| 15249 | _ = try self.addInst(.{ | | |
| 15250 | .tag = tag, | | |
| 15251 | .ops = .extern_fn_reloc, | | |
| 15252 | .data = .{ .reloc = .{ | | |
| 15253 | .atom_index = atom_index, | | |
| 15254 | .sym_index = try elf_file.getGlobalSymbol(callee, lib), | | |
| 15255 | } }, | | |
| 15256 | }); | | |
| 15257 | } else if (self.bin_file.cast(.coff)) |coff_file| { | | |
| 15258 | const global_index = try coff_file.getGlobalSymbol(callee, lib); | 15264 | const global_index = try coff_file.getGlobalSymbol(callee, lib); |
| 15259 | _ = try self.addInst(.{ | 15265 | _ = try self.addInst(.{ |
| 15260 | .tag = .mov, | 15266 | .tag = .mov, |