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 {
6161 size: u64,
6262 } = null,
6363
64 /// True if symbol was already committed into the final
65 /// symbol table.
66 visited: bool = false,
67
6468 pub const base_type: Symbol.Type = .regular;
6569
6670 pub const Linkage = enum {
src/link/MachO/Zld.zig+18-2
......@@ -1194,6 +1194,10 @@ fn allocateTentativeSymbols(self: *Zld) !void {
11941194 .section = section,
11951195 .weak_ref = false,
11961196 .file = tent.file,
1197 .stab = .{
1198 .kind = .global,
1199 .size = 0,
1200 },
11971201 };
11981202
11991203 try self.globals.putNoClobber(self.allocator, reg.base.name, &reg.base);
......@@ -2772,8 +2776,17 @@ fn writeDebugInfo(self: *Zld) !void {
27722776 });
27732777
27742778 for (object.symbols.items) |sym| {
2775 if (sym.@"type" != .regular) continue;
2776 const reg = sym.cast(Symbol.Regular) orelse unreachable;
2779 const reg = reg: {
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
27782791 if (reg.isTemp() or reg.stab == null) continue;
27792792 const stab = reg.stab orelse unreachable;
......@@ -2877,6 +2890,7 @@ fn writeSymbolTable(self: *Zld) !void {
28772890
28782891 const reg = final.cast(Symbol.Regular) orelse unreachable;
28792892 if (reg.isTemp()) continue;
2893 if (reg.visited) continue;
28802894
28812895 switch (reg.linkage) {
28822896 .translation_unit => {
......@@ -2898,6 +2912,8 @@ fn writeSymbolTable(self: *Zld) !void {
28982912 });
28992913 },
29002914 }
2915
2916 reg.visited = true;
29012917 }
29022918 }
29032919