| ... | ... | @@ -7378,11 +7378,15 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 7378 | 7378 | // on linking. |
| 7379 | 7379 | const mod = self.bin_file.options.module.?; |
| 7380 | 7380 | if (self.air.value(callee)) |func_value| { |
| 7381 | | if (func_value.castTag(.function)) |func_payload| { |
| 7382 | | const func = func_payload.data; |
| 7383 | | |
| 7381 | if (if (func_value.castTag(.function)) |func_payload| |
| 7382 | func_payload.data.owner_decl |
| 7383 | else if (func_value.castTag(.decl_ref)) |decl_ref_payload| |
| 7384 | decl_ref_payload.data |
| 7385 | else |
| 7386 | null) |owner_decl| |
| 7387 | { |
| 7384 | 7388 | if (self.bin_file.cast(link.File.Elf)) |elf_file| { |
| 7385 | | const atom_index = try elf_file.getOrCreateAtomForDecl(func.owner_decl); |
| 7389 | const atom_index = try elf_file.getOrCreateAtomForDecl(owner_decl); |
| 7386 | 7390 | const atom = elf_file.getAtom(atom_index); |
| 7387 | 7391 | _ = try atom.getOrCreateOffsetTableEntry(elf_file); |
| 7388 | 7392 | const got_addr = atom.getOffsetTableAddress(elf_file); |
| ... | ... | @@ -7391,17 +7395,17 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 7391 | 7395 | .disp = @intCast(i32, got_addr), |
| 7392 | 7396 | })); |
| 7393 | 7397 | } else if (self.bin_file.cast(link.File.Coff)) |coff_file| { |
| 7394 | | const atom = try coff_file.getOrCreateAtomForDecl(func.owner_decl); |
| 7398 | const atom = try coff_file.getOrCreateAtomForDecl(owner_decl); |
| 7395 | 7399 | const sym_index = coff_file.getAtom(atom).getSymbolIndex().?; |
| 7396 | 7400 | try self.genSetReg(.rax, Type.usize, .{ .lea_got = sym_index }); |
| 7397 | 7401 | try self.asmRegister(.{ ._, .call }, .rax); |
| 7398 | 7402 | } else if (self.bin_file.cast(link.File.MachO)) |macho_file| { |
| 7399 | | const atom = try macho_file.getOrCreateAtomForDecl(func.owner_decl); |
| 7403 | const atom = try macho_file.getOrCreateAtomForDecl(owner_decl); |
| 7400 | 7404 | const sym_index = macho_file.getAtom(atom).getSymbolIndex().?; |
| 7401 | 7405 | try self.genSetReg(.rax, Type.usize, .{ .lea_got = sym_index }); |
| 7402 | 7406 | try self.asmRegister(.{ ._, .call }, .rax); |
| 7403 | 7407 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { |
| 7404 | | const decl_block_index = try p9.seeDecl(func.owner_decl); |
| 7408 | const decl_block_index = try p9.seeDecl(owner_decl); |
| 7405 | 7409 | const decl_block = p9.getDeclBlock(decl_block_index); |
| 7406 | 7410 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); |
| 7407 | 7411 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |