| ... | @@ -1,35 +1,36 @@ | ... | @@ -1,35 +1,36 @@ |
| 1 | const MachO = @This(); | 1 | const MachO = @This(); |
| 2 | | 2 | |
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const Allocator = std.mem.Allocator; | 4 | const build_options = @import("build_options"); |
| 5 | const assert = std.debug.assert; | 5 | const assert = std.debug.assert; |
| 6 | const fmt = std.fmt; | 6 | const fmt = std.fmt; |
| 7 | const fs = std.fs; | 7 | const fs = std.fs; |
| 8 | const log = std.log.scoped(.link); | 8 | const log = std.log.scoped(.link); |
| 9 | const macho = std.macho; | 9 | const macho = std.macho; |
| 10 | const codegen = @import("../codegen.zig"); | | |
| 11 | const aarch64 = @import("../codegen/aarch64.zig"); | | |
| 12 | const math = std.math; | 10 | const math = std.math; |
| 13 | const mem = std.mem; | 11 | const mem = std.mem; |
| 14 | const meta = std.meta; | 12 | const meta = std.meta; |
| 15 | | 13 | |
| | 14 | const aarch64 = @import("../codegen/aarch64.zig"); |
| 16 | const bind = @import("MachO/bind.zig"); | 15 | const bind = @import("MachO/bind.zig"); |
| 17 | const trace = @import("../tracy.zig").trace; | 16 | const codegen = @import("../codegen.zig"); |
| 18 | const build_options = @import("build_options"); | 17 | const commands = @import("MachO/commands.zig"); |
| 19 | const Module = @import("../Module.zig"); | | |
| 20 | const Compilation = @import("../Compilation.zig"); | | |
| 21 | const link = @import("../link.zig"); | 18 | const link = @import("../link.zig"); |
| 22 | const File = link.File; | | |
| 23 | const Cache = @import("../Cache.zig"); | | |
| 24 | const target_util = @import("../target.zig"); | 19 | const target_util = @import("../target.zig"); |
| | 20 | const trace = @import("../tracy.zig").trace; |
| 25 | | 21 | |
| | 22 | const Allocator = mem.Allocator; |
| | 23 | const Cache = @import("../Cache.zig"); |
| | 24 | const CodeSignature = @import("MachO/CodeSignature.zig"); |
| | 25 | const Compilation = @import("../Compilation.zig"); |
| 26 | const DebugSymbols = @import("MachO/DebugSymbols.zig"); | 26 | const DebugSymbols = @import("MachO/DebugSymbols.zig"); |
| | 27 | const LoadCommand = commands.LoadCommand; |
| | 28 | const Module = @import("../Module.zig"); |
| | 29 | const File = link.File; |
| 27 | const Trie = @import("MachO/Trie.zig"); | 30 | const Trie = @import("MachO/Trie.zig"); |
| 28 | const CodeSignature = @import("MachO/CodeSignature.zig"); | 31 | const SegmentCommand = commands.SegmentCommand; |
| 29 | const Zld = @import("MachO/Zld.zig"); | 32 | const Zld = @import("MachO/Zld.zig"); |
| 30 | | 33 | |
| 31 | usingnamespace @import("MachO/commands.zig"); | | |
| 32 | | | |
| 33 | pub const base_tag: File.Tag = File.Tag.macho; | 34 | pub const base_tag: File.Tag = File.Tag.macho; |
| 34 | | 35 | |
| 35 | base: File, | 36 | base: File, |
| ... | @@ -1841,7 +1842,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { | ... | @@ -1841,7 +1842,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 1841 | @sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH), | 1842 | @sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH), |
| 1842 | @sizeOf(u64), | 1843 | @sizeOf(u64), |
| 1843 | )); | 1844 | )); |
| 1844 | var dylinker_cmd = emptyGenericCommandWithData(macho.dylinker_command{ | 1845 | var dylinker_cmd = commands.emptyGenericCommandWithData(macho.dylinker_command{ |
| 1845 | .cmd = macho.LC_LOAD_DYLINKER, | 1846 | .cmd = macho.LC_LOAD_DYLINKER, |
| 1846 | .cmdsize = cmdsize, | 1847 | .cmdsize = cmdsize, |
| 1847 | .name = @sizeOf(macho.dylinker_command), | 1848 | .name = @sizeOf(macho.dylinker_command), |
| ... | @@ -1855,7 +1856,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { | ... | @@ -1855,7 +1856,7 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 1855 | if (self.libsystem_cmd_index == null) { | 1856 | if (self.libsystem_cmd_index == null) { |
| 1856 | self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len); | 1857 | self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 1857 | | 1858 | |
| 1858 | var dylib_cmd = try createLoadDylibCommand(self.base.allocator, mem.spanZ(LIB_SYSTEM_PATH), 2, 0, 0); | 1859 | var dylib_cmd = try commands.createLoadDylibCommand(self.base.allocator, mem.spanZ(LIB_SYSTEM_PATH), 2, 0, 0); |
| 1859 | errdefer dylib_cmd.deinit(self.base.allocator); | 1860 | errdefer dylib_cmd.deinit(self.base.allocator); |
| 1860 | | 1861 | |
| 1861 | try self.load_commands.append(self.base.allocator, .{ .Dylib = dylib_cmd }); | 1862 | try self.load_commands.append(self.base.allocator, .{ .Dylib = dylib_cmd }); |
| ... | @@ -3105,7 +3106,7 @@ fn writeLoadCommands(self: *MachO) !void { | ... | @@ -3105,7 +3106,7 @@ fn writeLoadCommands(self: *MachO) !void { |
| 3105 | | 3106 | |
| 3106 | /// Writes Mach-O file header. | 3107 | /// Writes Mach-O file header. |
| 3107 | fn writeHeader(self: *MachO) !void { | 3108 | fn writeHeader(self: *MachO) !void { |
| 3108 | var header = emptyHeader(.{ | 3109 | var header = commands.emptyHeader(.{ |
| 3109 | .flags = macho.MH_NOUNDEFS | macho.MH_DYLDLINK | macho.MH_PIE | macho.MH_TWOLEVEL, | 3110 | .flags = macho.MH_NOUNDEFS | macho.MH_DYLDLINK | macho.MH_PIE | macho.MH_TWOLEVEL, |
| 3110 | }); | 3111 | }); |
| 3111 | | 3112 | |