| ... | ... | @@ -3,6 +3,7 @@ const MachO = @This(); |
| 3 | 3 | const std = @import("std"); |
| 4 | 4 | const Allocator = std.mem.Allocator; |
| 5 | 5 | const assert = std.debug.assert; |
| 6 | const fmt = std.fmt; |
| 6 | 7 | const fs = std.fs; |
| 7 | 8 | const log = std.log.scoped(.link); |
| 8 | 9 | const macho = std.macho; |
| ... | ... | @@ -21,6 +22,7 @@ const File = link.File; |
| 21 | 22 | const Cache = @import("../Cache.zig"); |
| 22 | 23 | const target_util = @import("../target.zig"); |
| 23 | 24 | |
| 25 | const DebugSymbols = @import("MachO/DebugSymbols.zig"); |
| 24 | 26 | const Trie = @import("MachO/Trie.zig"); |
| 25 | 27 | const CodeSignature = @import("MachO/CodeSignature.zig"); |
| 26 | 28 | |
| ... | ... | @@ -31,6 +33,9 @@ pub const base_tag: File.Tag = File.Tag.macho; |
| 31 | 33 | |
| 32 | 34 | base: File, |
| 33 | 35 | |
| 36 | /// Debug symbols bundle (or dSym). |
| 37 | d_sym: ?DebugSymbols = null, |
| 38 | |
| 34 | 39 | /// Page size is dependent on the target cpu architecture. |
| 35 | 40 | /// For x86_64 that's 4KB, whereas for aarch64, that's 16KB. |
| 36 | 41 | page_size: u16, |
| ... | ... | @@ -264,6 +269,20 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio |
| 264 | 269 | |
| 265 | 270 | self.base.file = file; |
| 266 | 271 | |
| 272 | // Create dSym bundle. |
| 273 | const d_sym_path = try fmt.allocPrint(allocator, "{}.dSym/Contents/Resources/DWARF/", .{sub_path}); |
| 274 | defer allocator.free(d_sym_path); |
| 275 | var d_sym_bundle = try options.emit.?.directory.handle.makeOpenPath(d_sym_path, .{}); |
| 276 | defer d_sym_bundle.close(); |
| 277 | const d_sym_file = try d_sym_bundle.createFile(sub_path, .{ |
| 278 | .truncate = false, |
| 279 | .read = true, |
| 280 | }); |
| 281 | self.d_sym = .{ |
| 282 | .base = self, |
| 283 | .file = d_sym_file, |
| 284 | }; |
| 285 | |
| 267 | 286 | // Index 0 is always a null symbol. |
| 268 | 287 | try self.local_symbols.append(allocator, .{ |
| 269 | 288 | .n_strx = 0, |
| ... | ... | @@ -943,6 +962,9 @@ fn darwinArchString(arch: std.Target.Cpu.Arch) []const u8 { |
| 943 | 962 | } |
| 944 | 963 | |
| 945 | 964 | pub fn deinit(self: *MachO) void { |
| 965 | if (self.d_sym) |*ds| { |
| 966 | ds.deinit(self.base.allocator); |
| 967 | } |
| 946 | 968 | self.binding_info_table.deinit(self.base.allocator); |
| 947 | 969 | self.lazy_binding_info_table.deinit(self.base.allocator); |
| 948 | 970 | self.pie_fixups.deinit(self.base.allocator); |