aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-12-27 09:30:03 +0100
committerJakub Konka <kubkon@jakubkonka.com>2020-12-31 10:19:04 +0100
commitbd99a87dc224b7d84e764fc2a8a8f4e3068078b3 (patch)
tree2500fcf9f2e04b1ab192814bfed4b7884a0b42a6 /src/link/MachO
parent0ff56e8bb14273fa8abe4503855e9f53d699c8cd (diff)
downloadzig-bd99a87dc224b7d84e764fc2a8a8f4e3068078b3.tar.gz
zig-bd99a87dc224b7d84e764fc2a8a8f4e3068078b3.zip
macho: create dSym bundle next to final artefact
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.
Diffstat (limited to 'src/link/MachO')
-rw-r--r--src/link/MachO/DebugSymbols.zig40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig
new file mode 100644
index 0000000000..1e30bdf564
--- /dev/null
+++ b/src/link/MachO/DebugSymbols.zig
@@ -0,0 +1,40 @@
+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();
+}