| author | |
| committer | |
| log | ab400ad62406e5ed7660d01d7065dc14081b10f6 |
| tree | 51b0e315337bf776a99a6b62d1b9181e56e8edfd |
| parent | 4d6849ceb89fc90c1bc5e198a30624d07dedf9e5 |
2 files changed, 24 insertions(+), 1 deletions(-)
src/link.zig+1-1| ... | @@ -643,7 +643,7 @@ pub const File = struct { | ... | @@ -643,7 +643,7 @@ pub const File = struct { |
| 643 | .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl), | 643 | .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl), |
| 644 | .elf => return @fieldParentPtr(Elf, "base", base).getDeclVAddr(decl), | 644 | .elf => return @fieldParentPtr(Elf, "base", base).getDeclVAddr(decl), |
| 645 | .macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl), | 645 | .macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl), |
| 646 | .plan9 => @panic("GET VADDR"), | 646 | .plan9 => return @fieldParentPtr(Plan9, "base", base).getDeclVAddr(decl), |
| 647 | .c => unreachable, | 647 | .c => unreachable, |
| 648 | .wasm => unreachable, | 648 | .wasm => unreachable, |
| 649 | .spirv => unreachable, | 649 | .spirv => unreachable, |
src/link/Plan9.zig+23| ... | @@ -740,3 +740,26 @@ pub fn allocateDeclIndexes(self: *Plan9, decl: *Module.Decl) !void { | ... | @@ -740,3 +740,26 @@ pub fn allocateDeclIndexes(self: *Plan9, decl: *Module.Decl) !void { |
| 740 | _ = self; | 740 | _ = self; |
| 741 | _ = decl; | 741 | _ = decl; |
| 742 | } | 742 | } |
| 743 | pub fn getDeclVAddr(self: *Plan9, decl: *const Module.Decl) u64 { | ||
| 744 | if (decl.ty.zigTypeTag() == .Fn) { | ||
| 745 | var start = self.bases.text; | ||
| 746 | var it_file = self.fn_decl_table.iterator(); | ||
| 747 | while (it_file.next()) |fentry| { | ||
| 748 | var symidx_and_submap = fentry.value_ptr; | ||
| 749 | var submap_it = symidx_and_submap.functions.iterator(); | ||
| 750 | while (submap_it.next()) |entry| { | ||
| 751 | if (entry.key_ptr.* == decl) return start; | ||
| 752 | start += entry.value_ptr.code.len; | ||
| 753 | } | ||
| 754 | } | ||
| 755 | unreachable; | ||
| 756 | } else { | ||
| 757 | var start = self.bases.data + self.got_len * if (!self.sixtyfour_bit) @as(u32, 4) else 8; | ||
| 758 | var it = self.data_decl_table.iterator(); | ||
| 759 | while (it.next()) |kv| { | ||
| 760 | if (decl == kv.key_ptr.*) return start; | ||
| 761 | start += kv.value_ptr.len; | ||
| 762 | } | ||
| 763 | unreachable; | ||
| 764 | } | ||
| 765 | } |