authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-10 19:28:11+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-10 19:28:11+02:00
log0e08cd63e236314750f18d28f8ede98a2188c6d2
tree0cf05b79c2820425fedb46414ba4ada48f1dea15
parentc2086efb412f17bb52514e931016e79c65bed442

zld: fix debug info for regulars synthed from tentative


2 files changed, 22 insertions(+), 2 deletions(-)

src/link/MachO/Symbol.zig+4
...@@ -61,6 +61,10 @@ pub const Regular = struct {...@@ -61,6 +61,10 @@ pub const Regular = struct {
61 size: u64,61 size: u64,
62 } = null,62 } = null,
6363
64 /// True if symbol was already committed into the final
65 /// symbol table.
66 visited: bool = false,
67
64 pub const base_type: Symbol.Type = .regular;68 pub const base_type: Symbol.Type = .regular;
6569
66 pub const Linkage = enum {70 pub const Linkage = enum {
src/link/MachO/Zld.zig+18-2
...@@ -1194,6 +1194,10 @@ fn allocateTentativeSymbols(self: *Zld) !void {...@@ -1194,6 +1194,10 @@ fn allocateTentativeSymbols(self: *Zld) !void {
1194 .section = section,1194 .section = section,
1195 .weak_ref = false,1195 .weak_ref = false,
1196 .file = tent.file,1196 .file = tent.file,
1197 .stab = .{
1198 .kind = .global,
1199 .size = 0,
1200 },
1197 };1201 };
11981202
1199 try self.globals.putNoClobber(self.allocator, reg.base.name, &reg.base);1203 try self.globals.putNoClobber(self.allocator, reg.base.name, &reg.base);
...@@ -2772,8 +2776,17 @@ fn writeDebugInfo(self: *Zld) !void {...@@ -2772,8 +2776,17 @@ fn writeDebugInfo(self: *Zld) !void {
2772 });2776 });
27732777
2774 for (object.symbols.items) |sym| {2778 for (object.symbols.items) |sym| {
2775 if (sym.@"type" != .regular) continue;2779 const reg = reg: {
2776 const reg = sym.cast(Symbol.Regular) orelse unreachable;2780 switch (sym.@"type") {
2781 .regular => break :reg sym.cast(Symbol.Regular) orelse unreachable,
2782 .tentative => {
2783 const final = sym.getTopmostAlias().cast(Symbol.Regular) orelse unreachable;
2784 if (object != final.file) continue;
2785 break :reg final;
2786 },
2787 else => continue,
2788 }
2789 };
27772790
2778 if (reg.isTemp() or reg.stab == null) continue;2791 if (reg.isTemp() or reg.stab == null) continue;
2779 const stab = reg.stab orelse unreachable;2792 const stab = reg.stab orelse unreachable;
...@@ -2877,6 +2890,7 @@ fn writeSymbolTable(self: *Zld) !void {...@@ -2877,6 +2890,7 @@ fn writeSymbolTable(self: *Zld) !void {
28772890
2878 const reg = final.cast(Symbol.Regular) orelse unreachable;2891 const reg = final.cast(Symbol.Regular) orelse unreachable;
2879 if (reg.isTemp()) continue;2892 if (reg.isTemp()) continue;
2893 if (reg.visited) continue;
28802894
2881 switch (reg.linkage) {2895 switch (reg.linkage) {
2882 .translation_unit => {2896 .translation_unit => {
...@@ -2898,6 +2912,8 @@ fn writeSymbolTable(self: *Zld) !void {...@@ -2898,6 +2912,8 @@ fn writeSymbolTable(self: *Zld) !void {
2898 });2912 });
2899 },2913 },
2900 }2914 }
2915
2916 reg.visited = true;
2901 }2917 }
2902 }2918 }
29032919