| ... | @@ -4061,6 +4061,44 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions. | ... | @@ -4061,6 +4061,44 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions. |
| 4061 | } else { | 4061 | } else { |
| 4062 | return self.fail("TODO implement calling bitcasted functions", .{}); | 4062 | return self.fail("TODO implement calling bitcasted functions", .{}); |
| 4063 | } | 4063 | } |
| | 4064 | } else if (self.bin_file.cast(link.File.Coff)) |coff_file| { |
| | 4065 | if (func_value.castTag(.function)) |func_payload| { |
| | 4066 | const func = func_payload.data; |
| | 4067 | const fn_owner_decl = mod.declPtr(func.owner_decl); |
| | 4068 | try self.genSetReg(Type.initTag(.u64), .x30, .{ |
| | 4069 | .linker_load = .{ |
| | 4070 | .@"type" = .got, |
| | 4071 | .sym_index = fn_owner_decl.link.coff.sym_index, |
| | 4072 | }, |
| | 4073 | }); |
| | 4074 | // blr x30 |
| | 4075 | _ = try self.addInst(.{ |
| | 4076 | .tag = .blr, |
| | 4077 | .data = .{ .reg = .x30 }, |
| | 4078 | }); |
| | 4079 | } else if (func_value.castTag(.extern_fn)) |func_payload| { |
| | 4080 | const extern_fn = func_payload.data; |
| | 4081 | const decl_name = mod.declPtr(extern_fn.owner_decl).name; |
| | 4082 | if (extern_fn.lib_name) |lib_name| { |
| | 4083 | log.debug("TODO enforce that '{s}' is expected in '{s}' library", .{ |
| | 4084 | decl_name, |
| | 4085 | lib_name, |
| | 4086 | }); |
| | 4087 | } |
| | 4088 | const sym_index = try coff_file.getGlobalSymbol(mem.sliceTo(decl_name, 0)); |
| | 4089 | |
| | 4090 | _ = try self.addInst(.{ |
| | 4091 | .tag = .call_extern, |
| | 4092 | .data = .{ |
| | 4093 | .relocation = .{ |
| | 4094 | .atom_index = mod.declPtr(self.mod_fn.owner_decl).link.coff.sym_index, |
| | 4095 | .sym_index = sym_index, |
| | 4096 | }, |
| | 4097 | }, |
| | 4098 | }); |
| | 4099 | } else { |
| | 4100 | return self.fail("TODO implement calling bitcasted functions", .{}); |
| | 4101 | } |
| 4064 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { | 4102 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { |
| 4065 | if (func_value.castTag(.function)) |func_payload| { | 4103 | if (func_value.castTag(.function)) |func_payload| { |
| 4066 | try p9.seeDecl(func_payload.data.owner_decl); | 4104 | try p9.seeDecl(func_payload.data.owner_decl); |