| ... | ... | @@ -694,10 +694,22 @@ pub fn flushModule(self: *ZigObject, macho_file: *MachO, tid: Zcu.PerThread.Id) |
| 694 | 694 | pub fn getDeclVAddr( |
| 695 | 695 | self: *ZigObject, |
| 696 | 696 | macho_file: *MachO, |
| 697 | pt: Zcu.PerThread, |
| 697 | 698 | decl_index: InternPool.DeclIndex, |
| 698 | 699 | reloc_info: link.File.RelocInfo, |
| 699 | 700 | ) !u64 { |
| 700 | | const sym_index = try self.getOrCreateMetadataForDecl(macho_file, decl_index); |
| 701 | const zcu = pt.zcu; |
| 702 | const ip = &zcu.intern_pool; |
| 703 | const decl = zcu.declPtr(decl_index); |
| 704 | log.debug("getDeclVAddr {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| 705 | const sym_index = if (decl.isExtern(zcu)) blk: { |
| 706 | const name = decl.name.toSlice(ip); |
| 707 | const lib_name = if (decl.getOwnedExternFunc(zcu)) |ext_fn| |
| 708 | ext_fn.lib_name.toSlice(ip) |
| 709 | else |
| 710 | decl.getOwnedVariable(zcu).?.lib_name.toSlice(ip); |
| 711 | break :blk try self.getGlobalSymbol(macho_file, name, lib_name); |
| 712 | } else try self.getOrCreateMetadataForDecl(macho_file, decl_index); |
| 701 | 713 | const sym = self.symbols.items[sym_index]; |
| 702 | 714 | const vaddr = sym.getAddress(.{}, macho_file); |
| 703 | 715 | const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?; |