Commit 0a9088bd06

Jakub Konka <kubkon@jakubkonka.com>
2022-03-05 17:19:06
macho: remove anon_struct_type which is now redundant
1 parent 2be003a
Changed files (3)
src
arch
x86_64
link
src/arch/x86_64/Emit.zig
@@ -1019,7 +1019,14 @@ fn genArgDbgInfo(emit: *Emit, inst: Air.Inst.Index, mcv: MCValue, max_stack: u32
             switch (emit.debug_output) {
                 .dwarf => |dbg_out| {
                     try dbg_out.dbg_info.ensureUnusedCapacity(3);
-                    dbg_out.dbg_info.appendAssumeCapacity(link.File.Elf.abbrev_parameter);
+
+                    // TODO this will go away once we pull DWARF into a cross-platform module.
+                    if (emit.bin_file.cast(link.File.MachO)) |_| {
+                        dbg_out.dbg_info.appendAssumeCapacity(link.File.MachO.DebugSymbols.abbrev_parameter);
+                    } else if (emit.bin_file.cast(link.File.Elf)) |_| {
+                        dbg_out.dbg_info.appendAssumeCapacity(link.File.Elf.abbrev_parameter);
+                    } else return emit.fail("TODO DWARF in non-MachO and non-ELF backend", .{});
+
                     dbg_out.dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc
                         1, // ULEB128 dwarf expression length
                         reg.dwarfLocOp(),
@@ -1042,7 +1049,14 @@ fn genArgDbgInfo(emit: *Emit, inst: Air.Inst.Index, mcv: MCValue, max_stack: u32
                     // for example when -fomit-frame-pointer is set.
                     const disp = @intCast(i32, max_stack) - off + 16;
                     try dbg_out.dbg_info.ensureUnusedCapacity(8);
-                    dbg_out.dbg_info.appendAssumeCapacity(link.File.Elf.abbrev_parameter);
+
+                    // TODO this will go away once we pull DWARF into a cross-platform module.
+                    if (emit.bin_file.cast(link.File.MachO)) |_| {
+                        dbg_out.dbg_info.appendAssumeCapacity(link.File.MachO.DebugSymbols.abbrev_parameter);
+                    } else if (emit.bin_file.cast(link.File.Elf)) |_| {
+                        dbg_out.dbg_info.appendAssumeCapacity(link.File.Elf.abbrev_parameter);
+                    } else return emit.fail("TODO DWARF in non-MachO and non-ELF backend", .{});
+
                     const fixup = dbg_out.dbg_info.items.len;
                     dbg_out.dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc
                         1, // we will backpatch it after we encode the displacement in LEB128
src/link/MachO/DebugSymbols.zig
@@ -78,16 +78,15 @@ debug_aranges_section_dirty: bool = false,
 debug_info_header_dirty: bool = false,
 debug_line_header_dirty: bool = false,
 
-const abbrev_compile_unit = 1;
-const abbrev_subprogram = 2;
-const abbrev_subprogram_retvoid = 3;
-const abbrev_base_type = 4;
-const abbrev_ptr_type = 5;
-const abbrev_struct_type = 6;
-const abbrev_anon_struct_type = 7;
-const abbrev_struct_member = 8;
-const abbrev_pad1 = 9;
-const abbrev_parameter = 10;
+pub const abbrev_compile_unit = 1;
+pub const abbrev_subprogram = 2;
+pub const abbrev_subprogram_retvoid = 3;
+pub const abbrev_base_type = 4;
+pub const abbrev_ptr_type = 5;
+pub const abbrev_struct_type = 6;
+pub const abbrev_struct_member = 7;
+pub const abbrev_pad1 = 8;
+pub const abbrev_parameter = 9;
 
 /// The reloc offset for the virtual address of a function in its Line Number Program.
 /// Size is a virtual address integer.
@@ -353,13 +352,6 @@ pub fn flushModule(self: *DebugSymbols, allocator: Allocator, options: link.Opti
             DW.FORM.string,
             0,
             0, // table sentinel
-            abbrev_anon_struct_type,
-            DW.TAG.structure_type,
-            DW.CHILDREN.yes, // header
-            DW.AT.byte_size,
-            DW.FORM.sdata,
-            0,
-            0, // table sentinel
             abbrev_struct_member,
             DW.TAG.member,
             DW.CHILDREN.no, // header
src/link/MachO.zig
@@ -27,7 +27,6 @@ const Atom = @import("MachO/Atom.zig");
 const Cache = @import("../Cache.zig");
 const CodeSignature = @import("MachO/CodeSignature.zig");
 const Compilation = @import("../Compilation.zig");
-const DebugSymbols = @import("MachO/DebugSymbols.zig");
 const Dylib = @import("MachO/Dylib.zig");
 const File = link.File;
 const Object = @import("MachO/Object.zig");
@@ -43,6 +42,7 @@ const TypedValue = @import("../TypedValue.zig");
 const Value = @import("../value.zig").Value;
 
 pub const TextBlock = Atom;
+pub const DebugSymbols = @import("MachO/DebugSymbols.zig");
 
 pub const base_tag: File.Tag = File.Tag.macho;