macOS requires the debug symbols to either be part of the intermediate object file `whatever.o` or a companion `whatever.dSym` bundle. The former case seems ill-suited for our needs since it subscribes to the old-fashioned compilation strategy using intermediate compilation units; the latter is what we need however on macOS the debug symbols unlike in Elf are not part of the final artefact; rather they sit next to it in its own Mach-O file.
41 lines
944 B
Zig
41 lines
944 B
Zig
const DebugSymbols = @This();
|
|
|
|
const std = @import("std");
|
|
const fs = std.fs;
|
|
const macho = std.macho;
|
|
const mem = std.mem;
|
|
const DW = std.dwarf;
|
|
const leb = std.leb;
|
|
const Allocator = mem.Allocator;
|
|
|
|
const MachO = @import("../MachO.zig");
|
|
|
|
usingnamespace @import("commands.zig");
|
|
|
|
base: *MachO,
|
|
file: fs.File,
|
|
|
|
/// Mach header
|
|
header: ?macho.mach_header_64 = null,
|
|
|
|
/// Table of all load commands
|
|
load_commands: std.ArrayListUnmanaged(LoadCommand) = .{},
|
|
/// __PAGEZERO segment
|
|
pagezero_segment_cmd_index: ?u16 = null,
|
|
/// __TEXT segment
|
|
text_segment_cmd_index: ?u16 = null,
|
|
/// __DWARF segment
|
|
dwarf_segment_cmd_index: ?u16 = null,
|
|
/// __DATA segment
|
|
data_segment_cmd_index: ?u16 = null,
|
|
/// __LINKEDIT segment
|
|
linkedit_segment_cmd_index: ?u16 = null,
|
|
/// Symbol table
|
|
symtab_cmd_index: ?u16 = null,
|
|
/// UUID load command
|
|
uuid_cmd_index: ?u16 = null,
|
|
|
|
pub fn deinit(self: *DebugSymbols, allocator: *Allocator) void {
|
|
self.file.close();
|
|
}
|