| ... | @@ -396,16 +396,24 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -396,16 +396,24 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 396 | self.dylibs_map.clearRetainingCapacity(); | 396 | self.dylibs_map.clearRetainingCapacity(); |
| 397 | self.referenced_dylibs.clearRetainingCapacity(); | 397 | self.referenced_dylibs.clearRetainingCapacity(); |
| 398 | | 398 | |
| 399 | const cpu_arch = self.base.options.target.cpu.arch; | | |
| 400 | var dependent_libs = std.fifo.LinearFifo(struct { | 399 | var dependent_libs = std.fifo.LinearFifo(struct { |
| 401 | id: Dylib.Id, | 400 | id: Dylib.Id, |
| 402 | parent: u16, | 401 | parent: u16, |
| 403 | }, .Dynamic).init(arena); | 402 | }, .Dynamic).init(arena); |
| 404 | | 403 | |
| 405 | var parse_error_ctx: union { | 404 | var parse_error_ctx: struct { |
| 406 | none: void, | | |
| 407 | detected_arch: std.Target.Cpu.Arch, | 405 | detected_arch: std.Target.Cpu.Arch, |
| 408 | } = .{ .none = {} }; | 406 | detected_platform: ?Platform, |
| | 407 | detected_stub_targets: []const []const u8, |
| | 408 | } = .{ |
| | 409 | .detected_arch = undefined, |
| | 410 | .detected_platform = null, |
| | 411 | .detected_stub_targets = &[0][]const u8{}, |
| | 412 | }; |
| | 413 | defer { |
| | 414 | for (parse_error_ctx.detected_stub_targets) |target| self.base.allocator.free(target); |
| | 415 | self.base.allocator.free(parse_error_ctx.detected_stub_targets); |
| | 416 | } |
| 409 | | 417 | |
| 410 | for (libs.keys(), libs.values()) |path, lib| { | 418 | for (libs.keys(), libs.values()) |path, lib| { |
| 411 | const in_file = try std.fs.cwd().openFile(path, .{}); | 419 | const in_file = try std.fs.cwd().openFile(path, .{}); |
| ... | @@ -418,25 +426,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -418,25 +426,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 418 | false, | 426 | false, |
| 419 | &dependent_libs, | 427 | &dependent_libs, |
| 420 | &parse_error_ctx, | 428 | &parse_error_ctx, |
| 421 | ) catch |err| switch (err) { | 429 | ) catch |err| try self.handleAndReportParseError(path, err, parse_error_ctx); |
| 422 | error.DylibAlreadyExists => {}, | | |
| 423 | error.UnknownFileType => try self.reportParseError(path, "unknown file type", .{}), | | |
| 424 | error.MissingArchFatLib => try self.reportParseError( | | |
| 425 | path, | | |
| 426 | "missing architecture in universal file, expected '{s}'", | | |
| 427 | .{@tagName(cpu_arch)}, | | |
| 428 | ), | | |
| 429 | error.InvalidArch => try self.reportParseError( | | |
| 430 | path, | | |
| 431 | "invalid architecture '{s}', expected '{s}'", | | |
| 432 | .{ @tagName(parse_error_ctx.detected_arch), @tagName(cpu_arch) }, | | |
| 433 | ), | | |
| 434 | else => |e| try self.reportParseError( | | |
| 435 | path, | | |
| 436 | "parsing library failed with error '{s}'", | | |
| 437 | .{@errorName(e)}, | | |
| 438 | ), | | |
| 439 | }; | | |
| 440 | } | 430 | } |
| 441 | | 431 | |
| 442 | self.parseDependentLibs(&dependent_libs, &parse_error_ctx) catch |err| { | 432 | self.parseDependentLibs(&dependent_libs, &parse_error_ctx) catch |err| { |
| ... | @@ -586,7 +576,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -586,7 +576,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 586 | .version = 0, | 576 | .version = 0, |
| 587 | }); | 577 | }); |
| 588 | { | 578 | { |
| 589 | const platform = load_commands.Platform.fromOptions(&self.base.options); | 579 | const platform = Platform.fromTarget(self.base.options.target); |
| 590 | const sdk_version: ?std.SemanticVersion = if (self.base.options.sysroot) |path| | 580 | const sdk_version: ?std.SemanticVersion = if (self.base.options.sysroot) |path| |
| 591 | load_commands.inferSdkVersionFromSdkPath(path) | 581 | load_commands.inferSdkVersionFromSdkPath(path) |
| 592 | else | 582 | else |
| ... | @@ -738,7 +728,8 @@ fn resolveLib( | ... | @@ -738,7 +728,8 @@ fn resolveLib( |
| 738 | const ParseError = error{ | 728 | const ParseError = error{ |
| 739 | UnknownFileType, | 729 | UnknownFileType, |
| 740 | MissingArchFatLib, | 730 | MissingArchFatLib, |
| 741 | InvalidArch, | 731 | InvalidTarget, |
| | 732 | InvalidLibStubTargets, |
| 742 | DylibAlreadyExists, | 733 | DylibAlreadyExists, |
| 743 | IncompatibleDylibVersion, | 734 | IncompatibleDylibVersion, |
| 744 | OutOfMemory, | 735 | OutOfMemory, |
| ... | @@ -798,19 +789,24 @@ fn parseObject( | ... | @@ -798,19 +789,24 @@ fn parseObject( |
| 798 | }; | 789 | }; |
| 799 | errdefer object.deinit(gpa); | 790 | errdefer object.deinit(gpa); |
| 800 | try object.parse(gpa); | 791 | try object.parse(gpa); |
| 801 | try self.objects.append(gpa, object); | | |
| 802 | | 792 | |
| 803 | const cpu_arch: std.Target.Cpu.Arch = switch (object.header.cputype) { | 793 | const cpu_arch: std.Target.Cpu.Arch = switch (object.header.cputype) { |
| 804 | macho.CPU_TYPE_ARM64 => .aarch64, | 794 | macho.CPU_TYPE_ARM64 => .aarch64, |
| 805 | macho.CPU_TYPE_X86_64 => .x86_64, | 795 | macho.CPU_TYPE_X86_64 => .x86_64, |
| 806 | else => unreachable, | 796 | else => unreachable, |
| 807 | }; | 797 | }; |
| 808 | const self_cpu_arch = self.base.options.target.cpu.arch; | 798 | error_ctx.detected_arch = cpu_arch; |
| 809 | | 799 | |
| 810 | if (self_cpu_arch != cpu_arch) { | 800 | if (object.getPlatform()) |platform| { |
| 811 | error_ctx.detected_arch = cpu_arch; | 801 | error_ctx.detected_platform = platform; |
| 812 | return error.InvalidArch; | 802 | } |
| | 803 | |
| | 804 | if (self.base.options.target.cpu.arch != cpu_arch) return error.InvalidTarget; |
| | 805 | if (error_ctx.detected_platform) |platform| { |
| | 806 | if (!Platform.fromTarget(self.base.options.target).eqlTarget(platform)) return error.InvalidTarget; |
| 813 | } | 807 | } |
| | 808 | |
| | 809 | try self.objects.append(gpa, object); |
| 814 | } | 810 | } |
| 815 | | 811 | |
| 816 | pub fn parseLibrary( | 812 | pub fn parseLibrary( |
| ... | @@ -825,14 +821,12 @@ pub fn parseLibrary( | ... | @@ -825,14 +821,12 @@ pub fn parseLibrary( |
| 825 | const tracy = trace(@src()); | 821 | const tracy = trace(@src()); |
| 826 | defer tracy.end(); | 822 | defer tracy.end(); |
| 827 | | 823 | |
| 828 | const cpu_arch = self.base.options.target.cpu.arch; | | |
| 829 | | | |
| 830 | if (fat.isFatLibrary(file)) { | 824 | if (fat.isFatLibrary(file)) { |
| 831 | const offset = try self.parseFatLibrary(file, cpu_arch); | 825 | const offset = try self.parseFatLibrary(file, self.base.options.target.cpu.arch); |
| 832 | try file.seekTo(offset); | 826 | try file.seekTo(offset); |
| 833 | | 827 | |
| 834 | if (Archive.isArchive(file, offset)) { | 828 | if (Archive.isArchive(file, offset)) { |
| 835 | try self.parseArchive(path, offset, must_link, cpu_arch, error_ctx); | 829 | try self.parseArchive(path, offset, must_link, error_ctx); |
| 836 | } else if (Dylib.isDylib(file, offset)) { | 830 | } else if (Dylib.isDylib(file, offset)) { |
| 837 | try self.parseDylib(file, path, offset, dependent_libs, .{ | 831 | try self.parseDylib(file, path, offset, dependent_libs, .{ |
| 838 | .needed = lib.needed, | 832 | .needed = lib.needed, |
| ... | @@ -840,7 +834,7 @@ pub fn parseLibrary( | ... | @@ -840,7 +834,7 @@ pub fn parseLibrary( |
| 840 | }, error_ctx); | 834 | }, error_ctx); |
| 841 | } else return error.UnknownFileType; | 835 | } else return error.UnknownFileType; |
| 842 | } else if (Archive.isArchive(file, 0)) { | 836 | } else if (Archive.isArchive(file, 0)) { |
| 843 | try self.parseArchive(path, 0, must_link, cpu_arch, error_ctx); | 837 | try self.parseArchive(path, 0, must_link, error_ctx); |
| 844 | } else if (Dylib.isDylib(file, 0)) { | 838 | } else if (Dylib.isDylib(file, 0)) { |
| 845 | try self.parseDylib(file, path, 0, dependent_libs, .{ | 839 | try self.parseDylib(file, path, 0, dependent_libs, .{ |
| 846 | .needed = lib.needed, | 840 | .needed = lib.needed, |
| ... | @@ -850,7 +844,7 @@ pub fn parseLibrary( | ... | @@ -850,7 +844,7 @@ pub fn parseLibrary( |
| 850 | self.parseLibStub(file, path, dependent_libs, .{ | 844 | self.parseLibStub(file, path, dependent_libs, .{ |
| 851 | .needed = lib.needed, | 845 | .needed = lib.needed, |
| 852 | .weak = lib.weak, | 846 | .weak = lib.weak, |
| 853 | }) catch |err| switch (err) { | 847 | }, error_ctx) catch |err| switch (err) { |
| 854 | error.NotLibStub, error.UnexpectedToken => return error.UnknownFileType, | 848 | error.NotLibStub, error.UnexpectedToken => return error.UnknownFileType, |
| 855 | else => |e| return e, | 849 | else => |e| return e, |
| 856 | }; | 850 | }; |
| ... | @@ -872,7 +866,6 @@ fn parseArchive( | ... | @@ -872,7 +866,6 @@ fn parseArchive( |
| 872 | path: []const u8, | 866 | path: []const u8, |
| 873 | fat_offset: u64, | 867 | fat_offset: u64, |
| 874 | must_link: bool, | 868 | must_link: bool, |
| 875 | cpu_arch: std.Target.Cpu.Arch, | | |
| 876 | error_ctx: anytype, | 869 | error_ctx: anytype, |
| 877 | ) ParseError!void { | 870 | ) ParseError!void { |
| 878 | const gpa = self.base.allocator; | 871 | const gpa = self.base.allocator; |
| ... | @@ -899,14 +892,20 @@ fn parseArchive( | ... | @@ -899,14 +892,20 @@ fn parseArchive( |
| 899 | var object = try archive.parseObject(gpa, off); // TODO we are doing all this work to pull the header only! | 892 | var object = try archive.parseObject(gpa, off); // TODO we are doing all this work to pull the header only! |
| 900 | defer object.deinit(gpa); | 893 | defer object.deinit(gpa); |
| 901 | | 894 | |
| 902 | const parsed_cpu_arch: std.Target.Cpu.Arch = switch (object.header.cputype) { | 895 | const cpu_arch: std.Target.Cpu.Arch = switch (object.header.cputype) { |
| 903 | macho.CPU_TYPE_ARM64 => .aarch64, | 896 | macho.CPU_TYPE_ARM64 => .aarch64, |
| 904 | macho.CPU_TYPE_X86_64 => .x86_64, | 897 | macho.CPU_TYPE_X86_64 => .x86_64, |
| 905 | else => unreachable, | 898 | else => unreachable, |
| 906 | }; | 899 | }; |
| 907 | if (cpu_arch != parsed_cpu_arch) { | 900 | error_ctx.detected_arch = cpu_arch; |
| 908 | error_ctx.detected_arch = parsed_cpu_arch; | 901 | |
| 909 | return error.InvalidArch; | 902 | if (object.getPlatform()) |platform| { |
| | 903 | error_ctx.detected_platform = platform; |
| | 904 | } |
| | 905 | |
| | 906 | if (self.base.options.target.cpu.arch != cpu_arch) return error.InvalidTarget; |
| | 907 | if (error_ctx.detected_platform) |platform| { |
| | 908 | if (!Platform.fromTarget(self.base.options.target).eqlTarget(platform)) return error.InvalidTarget; |
| 910 | } | 909 | } |
| 911 | } | 910 | } |
| 912 | | 911 | |
| ... | @@ -945,8 +944,6 @@ fn parseDylib( | ... | @@ -945,8 +944,6 @@ fn parseDylib( |
| 945 | error_ctx: anytype, | 944 | error_ctx: anytype, |
| 946 | ) ParseError!void { | 945 | ) ParseError!void { |
| 947 | const gpa = self.base.allocator; | 946 | const gpa = self.base.allocator; |
| 948 | const self_cpu_arch = self.base.options.target.cpu.arch; | | |
| 949 | | | |
| 950 | const file_stat = try file.stat(); | 947 | const file_stat = try file.stat(); |
| 951 | const file_size = math.cast(usize, file_stat.size - offset) orelse return error.Overflow; | 948 | const file_size = math.cast(usize, file_stat.size - offset) orelse return error.Overflow; |
| 952 | | 949 | |
| ... | @@ -969,12 +966,16 @@ fn parseDylib( | ... | @@ -969,12 +966,16 @@ fn parseDylib( |
| 969 | macho.CPU_TYPE_X86_64 => .x86_64, | 966 | macho.CPU_TYPE_X86_64 => .x86_64, |
| 970 | else => unreachable, | 967 | else => unreachable, |
| 971 | }; | 968 | }; |
| 972 | if (self_cpu_arch != cpu_arch) { | 969 | error_ctx.detected_arch = cpu_arch; |
| 973 | error_ctx.detected_arch = cpu_arch; | 970 | |
| 974 | return error.InvalidArch; | 971 | if (dylib.getPlatform(contents)) |platform| { |
| | 972 | error_ctx.detected_platform = platform; |
| 975 | } | 973 | } |
| 976 | | 974 | |
| 977 | // TODO verify platform | 975 | if (self.base.options.target.cpu.arch != cpu_arch) return error.InvalidTarget; |
| | 976 | if (error_ctx.detected_platform) |platform| { |
| | 977 | if (!Platform.fromTarget(self.base.options.target).eqlTarget(platform)) return error.InvalidTarget; |
| | 978 | } |
| 978 | | 979 | |
| 979 | try self.addDylib(dylib, .{ | 980 | try self.addDylib(dylib, .{ |
| 980 | .needed = dylib_options.needed, | 981 | .needed = dylib_options.needed, |
| ... | @@ -988,6 +989,7 @@ fn parseLibStub( | ... | @@ -988,6 +989,7 @@ fn parseLibStub( |
| 988 | path: []const u8, | 989 | path: []const u8, |
| 989 | dependent_libs: anytype, | 990 | dependent_libs: anytype, |
| 990 | dylib_options: DylibOpts, | 991 | dylib_options: DylibOpts, |
| | 992 | error_ctx: anytype, |
| 991 | ) ParseError!void { | 993 | ) ParseError!void { |
| 992 | const gpa = self.base.allocator; | 994 | const gpa = self.base.allocator; |
| 993 | var lib_stub = try LibStub.loadFromFile(gpa, file); | 995 | var lib_stub = try LibStub.loadFromFile(gpa, file); |
| ... | @@ -995,7 +997,20 @@ fn parseLibStub( | ... | @@ -995,7 +997,20 @@ fn parseLibStub( |
| 995 | | 997 | |
| 996 | if (lib_stub.inner.len == 0) return error.NotLibStub; | 998 | if (lib_stub.inner.len == 0) return error.NotLibStub; |
| 997 | | 999 | |
| 998 | // TODO verify platform | 1000 | // Verify target |
| | 1001 | { |
| | 1002 | var matcher = try Dylib.TargetMatcher.init(gpa, self.base.options.target); |
| | 1003 | defer matcher.deinit(); |
| | 1004 | |
| | 1005 | const first_tbd = lib_stub.inner[0]; |
| | 1006 | const targets = try first_tbd.targets(gpa); |
| | 1007 | if (!matcher.matchesTarget(targets)) { |
| | 1008 | error_ctx.detected_stub_targets = targets; |
| | 1009 | return error.InvalidLibStubTargets; |
| | 1010 | } |
| | 1011 | for (targets) |t| gpa.free(t); |
| | 1012 | gpa.free(targets); |
| | 1013 | } |
| 999 | | 1014 | |
| 1000 | var dylib = Dylib{ .weak = dylib_options.weak }; | 1015 | var dylib = Dylib{ .weak = dylib_options.weak }; |
| 1001 | errdefer dylib.deinit(gpa); | 1016 | errdefer dylib.deinit(gpa); |
| ... | @@ -1104,7 +1119,7 @@ pub fn parseDependentLibs(self: *MachO, dependent_libs: anytype, error_ctx: anyt | ... | @@ -1104,7 +1119,7 @@ pub fn parseDependentLibs(self: *MachO, dependent_libs: anytype, error_ctx: anyt |
| 1104 | self.parseLibStub(file, full_path, dependent_libs, .{ | 1119 | self.parseLibStub(file, full_path, dependent_libs, .{ |
| 1105 | .dependent = true, | 1120 | .dependent = true, |
| 1106 | .weak = weak, | 1121 | .weak = weak, |
| 1107 | }) catch |err| switch (err) { | 1122 | }, error_ctx) catch |err| switch (err) { |
| 1108 | error.NotLibStub, error.UnexpectedToken => continue, | 1123 | error.NotLibStub, error.UnexpectedToken => continue, |
| 1109 | else => |e| return e, | 1124 | else => |e| return e, |
| 1110 | }; | 1125 | }; |
| ... | @@ -4830,6 +4845,53 @@ pub fn getSectionPrecedence(header: macho.section_64) u8 { | ... | @@ -4830,6 +4845,53 @@ pub fn getSectionPrecedence(header: macho.section_64) u8 { |
| 4830 | return (@as(u8, @intCast(segment_precedence)) << 4) + section_precedence; | 4845 | return (@as(u8, @intCast(segment_precedence)) << 4) + section_precedence; |
| 4831 | } | 4846 | } |
| 4832 | | 4847 | |
| | 4848 | pub fn handleAndReportParseError(self: *MachO, path: []const u8, err: ParseError, parse_error_ctx: anytype) !void { |
| | 4849 | const cpu_arch = self.base.options.target.cpu.arch; |
| | 4850 | switch (err) { |
| | 4851 | error.DylibAlreadyExists => {}, |
| | 4852 | error.UnknownFileType => try self.reportParseError(path, "unknown file type", .{}), |
| | 4853 | error.MissingArchFatLib => try self.reportParseError( |
| | 4854 | path, |
| | 4855 | "missing architecture in universal file, expected '{s}'", |
| | 4856 | .{@tagName(cpu_arch)}, |
| | 4857 | ), |
| | 4858 | error.InvalidTarget => if (parse_error_ctx.detected_platform) |platform| { |
| | 4859 | try self.reportParseError(path, "invalid target '{s}-{}', expected '{s}-{}'", .{ |
| | 4860 | @tagName(parse_error_ctx.detected_arch), |
| | 4861 | platform.fmtTarget(), |
| | 4862 | @tagName(cpu_arch), |
| | 4863 | Platform.fromTarget(self.base.options.target).fmtTarget(), |
| | 4864 | }); |
| | 4865 | } else { |
| | 4866 | try self.reportParseError( |
| | 4867 | path, |
| | 4868 | "invalid architecture '{s}', expected '{s}'", |
| | 4869 | .{ @tagName(parse_error_ctx.detected_arch), @tagName(cpu_arch) }, |
| | 4870 | ); |
| | 4871 | }, |
| | 4872 | error.InvalidLibStubTargets => { |
| | 4873 | var targets_string = std.ArrayList(u8).init(self.base.allocator); |
| | 4874 | defer targets_string.deinit(); |
| | 4875 | try targets_string.writer().writeAll("("); |
| | 4876 | for (parse_error_ctx.detected_stub_targets) |t| { |
| | 4877 | try targets_string.writer().print("{s}, ", .{t}); |
| | 4878 | } |
| | 4879 | try targets_string.resize(targets_string.items.len - 2); |
| | 4880 | try targets_string.writer().writeAll(")"); |
| | 4881 | try self.reportParseError(path, "invalid targets '{s}', expected '{s}-{}'", .{ |
| | 4882 | targets_string.items, |
| | 4883 | @tagName(cpu_arch), |
| | 4884 | Platform.fromTarget(self.base.options.target).fmtTarget(), |
| | 4885 | }); |
| | 4886 | }, |
| | 4887 | else => |e| try self.reportParseError( |
| | 4888 | path, |
| | 4889 | "parsing positional argument failed with error '{s}'", |
| | 4890 | .{@errorName(e)}, |
| | 4891 | ), |
| | 4892 | } |
| | 4893 | } |
| | 4894 | |
| 4833 | pub fn reportParseError(self: *MachO, path: []const u8, comptime format: []const u8, args: anytype) !void { | 4895 | pub fn reportParseError(self: *MachO, path: []const u8, comptime format: []const u8, args: anytype) !void { |
| 4834 | const gpa = self.base.allocator; | 4896 | const gpa = self.base.allocator; |
| 4835 | try self.misc_errors.ensureUnusedCapacity(gpa, 1); | 4897 | try self.misc_errors.ensureUnusedCapacity(gpa, 1); |
| ... | @@ -5140,66 +5202,6 @@ pub fn logAtom(self: *MachO, atom_index: Atom.Index, logger: anytype) void { | ... | @@ -5140,66 +5202,6 @@ pub fn logAtom(self: *MachO, atom_index: Atom.Index, logger: anytype) void { |
| 5140 | } | 5202 | } |
| 5141 | } | 5203 | } |
| 5142 | | 5204 | |
| 5143 | const MachO = @This(); | | |
| 5144 | | | |
| 5145 | const std = @import("std"); | | |
| 5146 | const build_options = @import("build_options"); | | |
| 5147 | const builtin = @import("builtin"); | | |
| 5148 | const assert = std.debug.assert; | | |
| 5149 | const dwarf = std.dwarf; | | |
| 5150 | const fs = std.fs; | | |
| 5151 | const log = std.log.scoped(.link); | | |
| 5152 | const macho = std.macho; | | |
| 5153 | const math = std.math; | | |
| 5154 | const mem = std.mem; | | |
| 5155 | const meta = std.meta; | | |
| 5156 | | | |
| 5157 | const aarch64 = @import("../arch/aarch64/bits.zig"); | | |
| 5158 | const calcUuid = @import("MachO/uuid.zig").calcUuid; | | |
| 5159 | const codegen = @import("../codegen.zig"); | | |
| 5160 | const dead_strip = @import("MachO/dead_strip.zig"); | | |
| 5161 | const fat = @import("MachO/fat.zig"); | | |
| 5162 | const link = @import("../link.zig"); | | |
| 5163 | const llvm_backend = @import("../codegen/llvm.zig"); | | |
| 5164 | const load_commands = @import("MachO/load_commands.zig"); | | |
| 5165 | const stubs = @import("MachO/stubs.zig"); | | |
| 5166 | const tapi = @import("tapi.zig"); | | |
| 5167 | const target_util = @import("../target.zig"); | | |
| 5168 | const thunks = @import("MachO/thunks.zig"); | | |
| 5169 | const trace = @import("../tracy.zig").trace; | | |
| 5170 | const zld = @import("MachO/zld.zig"); | | |
| 5171 | | | |
| 5172 | const Air = @import("../Air.zig"); | | |
| 5173 | const Allocator = mem.Allocator; | | |
| 5174 | const Archive = @import("MachO/Archive.zig"); | | |
| 5175 | pub const Atom = @import("MachO/Atom.zig"); | | |
| 5176 | const Cache = std.Build.Cache; | | |
| 5177 | const CodeSignature = @import("MachO/CodeSignature.zig"); | | |
| 5178 | const Compilation = @import("../Compilation.zig"); | | |
| 5179 | const Dwarf = File.Dwarf; | | |
| 5180 | const DwarfInfo = @import("MachO/DwarfInfo.zig"); | | |
| 5181 | const Dylib = @import("MachO/Dylib.zig"); | | |
| 5182 | const File = link.File; | | |
| 5183 | const Object = @import("MachO/Object.zig"); | | |
| 5184 | const LibStub = tapi.LibStub; | | |
| 5185 | const Liveness = @import("../Liveness.zig"); | | |
| 5186 | const LlvmObject = @import("../codegen/llvm.zig").Object; | | |
| 5187 | const Md5 = std.crypto.hash.Md5; | | |
| 5188 | const Module = @import("../Module.zig"); | | |
| 5189 | const InternPool = @import("../InternPool.zig"); | | |
| 5190 | const Relocation = @import("MachO/Relocation.zig"); | | |
| 5191 | const StringTable = @import("strtab.zig").StringTable; | | |
| 5192 | const TableSection = @import("table_section.zig").TableSection; | | |
| 5193 | const Trie = @import("MachO/Trie.zig"); | | |
| 5194 | const Type = @import("../type.zig").Type; | | |
| 5195 | const TypedValue = @import("../TypedValue.zig"); | | |
| 5196 | const Value = @import("../value.zig").Value; | | |
| 5197 | | | |
| 5198 | pub const DebugSymbols = @import("MachO/DebugSymbols.zig"); | | |
| 5199 | pub const Bind = @import("MachO/dyld_info/bind.zig").Bind(*const MachO, SymbolWithLoc); | | |
| 5200 | pub const LazyBind = @import("MachO/dyld_info/bind.zig").LazyBind(*const MachO, SymbolWithLoc); | | |
| 5201 | pub const Rebase = @import("MachO/dyld_info/Rebase.zig"); | | |
| 5202 | | | |
| 5203 | pub const base_tag: File.Tag = File.Tag.macho; | 5205 | pub const base_tag: File.Tag = File.Tag.macho; |
| 5204 | pub const N_DEAD: u16 = @as(u16, @bitCast(@as(i16, -1))); | 5206 | pub const N_DEAD: u16 = @as(u16, @bitCast(@as(i16, -1))); |
| 5205 | | 5207 | |
| ... | @@ -5332,3 +5334,64 @@ pub const default_pagezero_vmsize: u64 = 0x100000000; | ... | @@ -5332,3 +5334,64 @@ pub const default_pagezero_vmsize: u64 = 0x100000000; |
| 5332 | /// the table of load commands. This should be plenty for any | 5334 | /// the table of load commands. This should be plenty for any |
| 5333 | /// potential future extensions. | 5335 | /// potential future extensions. |
| 5334 | pub const default_headerpad_size: u32 = 0x1000; | 5336 | pub const default_headerpad_size: u32 = 0x1000; |
| | 5337 | |
| | 5338 | const MachO = @This(); |
| | 5339 | |
| | 5340 | const std = @import("std"); |
| | 5341 | const build_options = @import("build_options"); |
| | 5342 | const builtin = @import("builtin"); |
| | 5343 | const assert = std.debug.assert; |
| | 5344 | const dwarf = std.dwarf; |
| | 5345 | const fs = std.fs; |
| | 5346 | const log = std.log.scoped(.link); |
| | 5347 | const macho = std.macho; |
| | 5348 | const math = std.math; |
| | 5349 | const mem = std.mem; |
| | 5350 | const meta = std.meta; |
| | 5351 | |
| | 5352 | const aarch64 = @import("../arch/aarch64/bits.zig"); |
| | 5353 | const calcUuid = @import("MachO/uuid.zig").calcUuid; |
| | 5354 | const codegen = @import("../codegen.zig"); |
| | 5355 | const dead_strip = @import("MachO/dead_strip.zig"); |
| | 5356 | const fat = @import("MachO/fat.zig"); |
| | 5357 | const link = @import("../link.zig"); |
| | 5358 | const llvm_backend = @import("../codegen/llvm.zig"); |
| | 5359 | const load_commands = @import("MachO/load_commands.zig"); |
| | 5360 | const stubs = @import("MachO/stubs.zig"); |
| | 5361 | const tapi = @import("tapi.zig"); |
| | 5362 | const target_util = @import("../target.zig"); |
| | 5363 | const thunks = @import("MachO/thunks.zig"); |
| | 5364 | const trace = @import("../tracy.zig").trace; |
| | 5365 | const zld = @import("MachO/zld.zig"); |
| | 5366 | |
| | 5367 | const Air = @import("../Air.zig"); |
| | 5368 | const Allocator = mem.Allocator; |
| | 5369 | const Archive = @import("MachO/Archive.zig"); |
| | 5370 | pub const Atom = @import("MachO/Atom.zig"); |
| | 5371 | const Cache = std.Build.Cache; |
| | 5372 | const CodeSignature = @import("MachO/CodeSignature.zig"); |
| | 5373 | const Compilation = @import("../Compilation.zig"); |
| | 5374 | const Dwarf = File.Dwarf; |
| | 5375 | const DwarfInfo = @import("MachO/DwarfInfo.zig"); |
| | 5376 | const Dylib = @import("MachO/Dylib.zig"); |
| | 5377 | const File = link.File; |
| | 5378 | const Object = @import("MachO/Object.zig"); |
| | 5379 | const LibStub = tapi.LibStub; |
| | 5380 | const Liveness = @import("../Liveness.zig"); |
| | 5381 | const LlvmObject = @import("../codegen/llvm.zig").Object; |
| | 5382 | const Md5 = std.crypto.hash.Md5; |
| | 5383 | const Module = @import("../Module.zig"); |
| | 5384 | const InternPool = @import("../InternPool.zig"); |
| | 5385 | const Platform = load_commands.Platform; |
| | 5386 | const Relocation = @import("MachO/Relocation.zig"); |
| | 5387 | const StringTable = @import("strtab.zig").StringTable; |
| | 5388 | const TableSection = @import("table_section.zig").TableSection; |
| | 5389 | const Trie = @import("MachO/Trie.zig"); |
| | 5390 | const Type = @import("../type.zig").Type; |
| | 5391 | const TypedValue = @import("../TypedValue.zig"); |
| | 5392 | const Value = @import("../value.zig").Value; |
| | 5393 | |
| | 5394 | pub const DebugSymbols = @import("MachO/DebugSymbols.zig"); |
| | 5395 | pub const Bind = @import("MachO/dyld_info/bind.zig").Bind(*const MachO, SymbolWithLoc); |
| | 5396 | pub const LazyBind = @import("MachO/dyld_info/bind.zig").LazyBind(*const MachO, SymbolWithLoc); |
| | 5397 | pub const Rebase = @import("MachO/dyld_info/Rebase.zig"); |