From 0a9088bd0684a517961b35bff458962174099677 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sat, 5 Mar 2022 17:19:06 +0100 Subject: [PATCH] macho: remove anon_struct_type which is now redundant --- src/arch/x86_64/Emit.zig | 18 ++++++++++++++++-- src/link/MachO.zig | 2 +- src/link/MachO/DebugSymbols.zig | 26 +++++++++----------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/arch/x86_64/Emit.zig b/src/arch/x86_64/Emit.zig index f4d365dc4fce9df55c8d7b1143470dc8596cbec9..86cdf8dcdb7435874a9b03ec68c080a97d74d6ab 100644 --- a/src/arch/x86_64/Emit.zig +++ b/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 diff --git a/src/link/MachO.zig b/src/link/MachO.zig index c1b9c44f1c08fb8d876f525488660fe1c640ce2e..6bf7d183df91d8eb22253eaa4c9f22b6906aa803 100644 --- a/src/link/MachO.zig +++ b/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; diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig index 5173682f2bd57db146f4e23b2e4bd5e645a894ce..024c1d1535d857b8441b2311d3074f726906b067 100644 --- a/src/link/MachO/DebugSymbols.zig +++ b/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 -- 2.54.0