| ... | @@ -1856,11 +1856,23 @@ pub fn flushModule(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no | ... | @@ -1856,11 +1856,23 @@ pub fn flushModule(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no |
| 1856 | assert(!self.imports_count_dirty); | 1856 | assert(!self.imports_count_dirty); |
| 1857 | } | 1857 | } |
| 1858 | | 1858 | |
| 1859 | pub fn getDeclVAddr(self: *Coff, _: Zcu.PerThread, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 { | 1859 | pub fn getDeclVAddr(self: *Coff, pt: Zcu.PerThread, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 { |
| 1860 | assert(self.llvm_object == null); | 1860 | assert(self.llvm_object == null); |
| 1861 | | 1861 | const zcu = pt.zcu; |
| 1862 | const this_atom_index = try self.getOrCreateAtomForDecl(decl_index); | 1862 | const ip = &zcu.intern_pool; |
| 1863 | const sym_index = self.getAtom(this_atom_index).getSymbolIndex().?; | 1863 | const decl = zcu.declPtr(decl_index); |
| | 1864 | log.debug("getDeclVAddr {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| | 1865 | const sym_index = if (decl.isExtern(zcu)) blk: { |
| | 1866 | const name = decl.name.toSlice(ip); |
| | 1867 | const lib_name = if (decl.getOwnedExternFunc(zcu)) |ext_fn| |
| | 1868 | ext_fn.lib_name.toSlice(ip) |
| | 1869 | else |
| | 1870 | decl.getOwnedVariable(zcu).?.lib_name.toSlice(ip); |
| | 1871 | break :blk try self.getGlobalSymbol(name, lib_name); |
| | 1872 | } else blk: { |
| | 1873 | const this_atom_index = try self.getOrCreateAtomForDecl(decl_index); |
| | 1874 | break :blk self.getAtom(this_atom_index).getSymbolIndex().?; |
| | 1875 | }; |
| 1864 | const atom_index = self.getAtomIndexForSymbol(.{ .sym_index = reloc_info.parent_atom_index, .file = null }).?; | 1876 | const atom_index = self.getAtomIndexForSymbol(.{ .sym_index = reloc_info.parent_atom_index, .file = null }).?; |
| 1865 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; | 1877 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; |
| 1866 | try Atom.addRelocation(self, atom_index, .{ | 1878 | try Atom.addRelocation(self, atom_index, .{ |