From 652842637c31055d26f846e2249c9989104afe67 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 19 Mar 2021 20:05:02 +0100 Subject: [PATCH] zld: continue on invalid/missing debug info --- src/link/MachO/Zld.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/link/MachO/Zld.zig b/src/link/MachO/Zld.zig index c98bacc08a..0ea1932c89 100644 --- a/src/link/MachO/Zld.zig +++ b/src/link/MachO/Zld.zig @@ -2707,7 +2707,15 @@ fn writeDebugInfo(self: *Zld) !void { }; defer debug_info.deinit(self.allocator); - const compile_unit = try debug_info.inner.findCompileUnit(0x0); // We assume there is only one CU. + // We assume there is only one CU. + const compile_unit = debug_info.inner.findCompileUnit(0x0) catch |err| switch (err) { + error.MissingDebugInfo => { + // TODO audit cases with missing debug info and audit our dwarf.zig module. + log.debug("invalid or missing debug info in {s}; skipping", .{object.name}); + continue; + }, + else => |e| return e, + }; const name = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT_name); const comp_dir = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT_comp_dir);