| ... | ... | @@ -664,10 +664,22 @@ pub fn codeAlloc(self: *ZigObject, elf_file: *Elf, atom_index: Atom.Index) ![]u8 |
| 664 | 664 | pub fn getDeclVAddr( |
| 665 | 665 | self: *ZigObject, |
| 666 | 666 | elf_file: *Elf, |
| 667 | pt: Zcu.PerThread, |
| 667 | 668 | decl_index: InternPool.DeclIndex, |
| 668 | 669 | reloc_info: link.File.RelocInfo, |
| 669 | 670 | ) !u64 { |
| 670 | | const this_sym_index = try self.getOrCreateMetadataForDecl(elf_file, decl_index); |
| 671 | const zcu = pt.zcu; |
| 672 | const ip = &zcu.intern_pool; |
| 673 | const decl = zcu.declPtr(decl_index); |
| 674 | log.debug("getDeclVAddr {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| 675 | const this_sym_index = if (decl.isExtern(zcu)) blk: { |
| 676 | const name = decl.name.toSlice(ip); |
| 677 | const lib_name = if (decl.getOwnedExternFunc(zcu)) |ext_fn| |
| 678 | ext_fn.lib_name.toSlice(ip) |
| 679 | else |
| 680 | decl.getOwnedVariable(zcu).?.lib_name.toSlice(ip); |
| 681 | break :blk try self.getGlobalSymbol(elf_file, name, lib_name); |
| 682 | } else try self.getOrCreateMetadataForDecl(elf_file, decl_index); |
| 671 | 683 | const this_sym = self.symbol(this_sym_index); |
| 672 | 684 | const vaddr = this_sym.address(.{}, elf_file); |
| 673 | 685 | const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?; |
| ... | ... | @@ -810,10 +822,8 @@ fn freeDeclMetadata(self: *ZigObject, elf_file: *Elf, sym_index: Symbol.Index) v |
| 810 | 822 | |
| 811 | 823 | pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: InternPool.DeclIndex) void { |
| 812 | 824 | const gpa = elf_file.base.comp.gpa; |
| 813 | | const mod = elf_file.base.comp.module.?; |
| 814 | | const decl = mod.declPtr(decl_index); |
| 815 | 825 | |
| 816 | | log.debug("freeDecl {*}", .{decl}); |
| 826 | log.debug("freeDecl ({d})", .{decl_index}); |
| 817 | 827 | |
| 818 | 828 | if (self.decls.fetchRemove(decl_index)) |const_kv| { |
| 819 | 829 | var kv = const_kv; |
| ... | ... | @@ -923,7 +933,7 @@ fn updateDeclCode( |
| 923 | 933 | const ip = &mod.intern_pool; |
| 924 | 934 | const decl = mod.declPtr(decl_index); |
| 925 | 935 | |
| 926 | | log.debug("updateDeclCode {}{*}", .{ decl.fqn.fmt(ip), decl }); |
| 936 | log.debug("updateDeclCode {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| 927 | 937 | |
| 928 | 938 | const required_alignment = decl.getAlignment(pt).max( |
| 929 | 939 | target_util.minFunctionAlignment(mod.getTarget()), |
| ... | ... | @@ -1023,7 +1033,7 @@ fn updateTlv( |
| 1023 | 1033 | const gpa = mod.gpa; |
| 1024 | 1034 | const decl = mod.declPtr(decl_index); |
| 1025 | 1035 | |
| 1026 | | log.debug("updateTlv {} ({*})", .{ decl.fqn.fmt(ip), decl }); |
| 1036 | log.debug("updateTlv {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| 1027 | 1037 | |
| 1028 | 1038 | const required_alignment = decl.getAlignment(pt); |
| 1029 | 1039 | |
| ... | ... | @@ -1077,11 +1087,14 @@ pub fn updateFunc( |
| 1077 | 1087 | defer tracy.end(); |
| 1078 | 1088 | |
| 1079 | 1089 | const mod = pt.zcu; |
| 1090 | const ip = &mod.intern_pool; |
| 1080 | 1091 | const gpa = elf_file.base.comp.gpa; |
| 1081 | 1092 | const func = mod.funcInfo(func_index); |
| 1082 | 1093 | const decl_index = func.owner_decl; |
| 1083 | 1094 | const decl = mod.declPtr(decl_index); |
| 1084 | 1095 | |
| 1096 | log.debug("updateFunc {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| 1097 | |
| 1085 | 1098 | const sym_index = try self.getOrCreateMetadataForDecl(elf_file, decl_index); |
| 1086 | 1099 | self.freeUnnamedConsts(elf_file, decl_index); |
| 1087 | 1100 | self.symbol(sym_index).atom(elf_file).?.freeRelocs(elf_file); |
| ... | ... | @@ -1139,12 +1152,12 @@ pub fn updateDecl( |
| 1139 | 1152 | defer tracy.end(); |
| 1140 | 1153 | |
| 1141 | 1154 | const mod = pt.zcu; |
| 1155 | const ip = &mod.intern_pool; |
| 1142 | 1156 | const decl = mod.declPtr(decl_index); |
| 1143 | 1157 | |
| 1144 | | if (decl.val.getExternFunc(mod)) |_| { |
| 1145 | | return; |
| 1146 | | } |
| 1158 | log.debug("updateDecl {}({d})", .{ decl.fqn.fmt(ip), decl_index }); |
| 1147 | 1159 | |
| 1160 | if (decl.val.getExternFunc(mod)) |_| return; |
| 1148 | 1161 | if (decl.isExtern(mod)) { |
| 1149 | 1162 | // Extern variable gets a .got entry only. |
| 1150 | 1163 | const variable = decl.getOwnedVariable(mod).?; |
| ... | ... | @@ -1485,7 +1498,7 @@ pub fn updateDeclLineNumber( |
| 1485 | 1498 | |
| 1486 | 1499 | const decl = pt.zcu.declPtr(decl_index); |
| 1487 | 1500 | |
| 1488 | | log.debug("updateDeclLineNumber {}{*}", .{ decl.fqn.fmt(&pt.zcu.intern_pool), decl }); |
| 1501 | log.debug("updateDeclLineNumber {}({d})", .{ decl.fqn.fmt(&pt.zcu.intern_pool), decl_index }); |
| 1489 | 1502 | |
| 1490 | 1503 | if (self.dwarf) |*dw| { |
| 1491 | 1504 | try dw.updateDeclLineNumber(pt.zcu, decl_index); |