| ... | ... | @@ -82,8 +82,8 @@ data_in_code_cmd_index: ?u16 = null, |
| 82 | 82 | function_starts_cmd_index: ?u16 = null, |
| 83 | 83 | main_cmd_index: ?u16 = null, |
| 84 | 84 | dylib_id_cmd_index: ?u16 = null, |
| 85 | | version_min_cmd_index: ?u16 = null, |
| 86 | 85 | source_version_cmd_index: ?u16 = null, |
| 86 | build_version_cmd_index: ?u16 = null, |
| 87 | 87 | uuid_cmd_index: ?u16 = null, |
| 88 | 88 | code_signature_cmd_index: ?u16 = null, |
| 89 | 89 | /// Path to libSystem |
| ... | ... | @@ -2716,27 +2716,6 @@ fn populateMetadata(self: *MachO) !void { |
| 2716 | 2716 | try self.load_commands.append(self.base.allocator, .{ .Dylib = dylib_cmd }); |
| 2717 | 2717 | } |
| 2718 | 2718 | |
| 2719 | | if (self.version_min_cmd_index == null) { |
| 2720 | | self.version_min_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 2721 | | const cmd: u32 = switch (self.base.options.target.os.tag) { |
| 2722 | | .macos => macho.LC_VERSION_MIN_MACOSX, |
| 2723 | | .ios => macho.LC_VERSION_MIN_IPHONEOS, |
| 2724 | | .tvos => macho.LC_VERSION_MIN_TVOS, |
| 2725 | | .watchos => macho.LC_VERSION_MIN_WATCHOS, |
| 2726 | | else => unreachable, // wrong OS |
| 2727 | | }; |
| 2728 | | const ver = self.base.options.target.os.version_range.semver.min; |
| 2729 | | const version = ver.major << 16 | ver.minor << 8 | ver.patch; |
| 2730 | | try self.load_commands.append(self.base.allocator, .{ |
| 2731 | | .VersionMin = .{ |
| 2732 | | .cmd = cmd, |
| 2733 | | .cmdsize = @sizeOf(macho.version_min_command), |
| 2734 | | .version = version, |
| 2735 | | .sdk = version, |
| 2736 | | }, |
| 2737 | | }); |
| 2738 | | } |
| 2739 | | |
| 2740 | 2719 | if (self.source_version_cmd_index == null) { |
| 2741 | 2720 | self.source_version_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 2742 | 2721 | try self.load_commands.append(self.base.allocator, .{ |
| ... | ... | @@ -2748,6 +2727,39 @@ fn populateMetadata(self: *MachO) !void { |
| 2748 | 2727 | }); |
| 2749 | 2728 | } |
| 2750 | 2729 | |
| 2730 | if (self.build_version_cmd_index == null) { |
| 2731 | self.build_version_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 2732 | const cmdsize = @intCast(u32, mem.alignForwardGeneric( |
| 2733 | u64, |
| 2734 | @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version), |
| 2735 | @sizeOf(u64), |
| 2736 | )); |
| 2737 | const ver = self.base.options.target.os.version_range.semver.min; |
| 2738 | const version = ver.major << 16 | ver.minor << 8 | ver.patch; |
| 2739 | var cmd = commands.emptyGenericCommandWithData(macho.build_version_command{ |
| 2740 | .cmd = macho.LC_BUILD_VERSION, |
| 2741 | .cmdsize = cmdsize, |
| 2742 | .platform = switch (self.base.options.target.os.tag) { |
| 2743 | .macos => macho.PLATFORM_MACOS, |
| 2744 | .ios => macho.PLATFORM_IOSSIMULATOR, |
| 2745 | .watchos => macho.PLATFORM_WATCHOS, |
| 2746 | .tvos => macho.PLATFORM_TVOS, |
| 2747 | else => unreachable, |
| 2748 | }, |
| 2749 | .minos = version, |
| 2750 | .sdk = version, |
| 2751 | .ntools = 1, |
| 2752 | }); |
| 2753 | const ld_ver = macho.build_tool_version{ |
| 2754 | .tool = macho.TOOL_LD, |
| 2755 | .version = 0x0, |
| 2756 | }; |
| 2757 | cmd.data = try self.base.allocator.alloc(u8, cmdsize - @sizeOf(macho.build_version_command)); |
| 2758 | mem.set(u8, cmd.data, 0); |
| 2759 | mem.copy(u8, cmd.data, mem.asBytes(&ld_ver)); |
| 2760 | try self.load_commands.append(self.base.allocator, .{ .BuildVersion = cmd }); |
| 2761 | } |
| 2762 | |
| 2751 | 2763 | if (self.uuid_cmd_index == null) { |
| 2752 | 2764 | self.uuid_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 2753 | 2765 | var uuid_cmd: macho.uuid_command = .{ |
| ... | ... | @@ -4334,26 +4346,37 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 4334 | 4346 | }); |
| 4335 | 4347 | self.load_commands_dirty = true; |
| 4336 | 4348 | } |
| 4337 | | if (self.version_min_cmd_index == null) { |
| 4338 | | self.version_min_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 4339 | | const cmd: u32 = switch (self.base.options.target.os.tag) { |
| 4340 | | .macos => macho.LC_VERSION_MIN_MACOSX, |
| 4341 | | .ios => macho.LC_VERSION_MIN_IPHONEOS, |
| 4342 | | .tvos => macho.LC_VERSION_MIN_TVOS, |
| 4343 | | .watchos => macho.LC_VERSION_MIN_WATCHOS, |
| 4344 | | else => unreachable, // wrong OS |
| 4345 | | }; |
| 4349 | if (self.build_version_cmd_index == null) { |
| 4350 | self.build_version_cmd_index = @intCast(u16, self.load_commands.items.len); |
| 4351 | const cmdsize = @intCast(u32, mem.alignForwardGeneric( |
| 4352 | u64, |
| 4353 | @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version), |
| 4354 | @sizeOf(u64), |
| 4355 | )); |
| 4346 | 4356 | const ver = self.base.options.target.os.version_range.semver.min; |
| 4347 | 4357 | const version = ver.major << 16 | ver.minor << 8 | ver.patch; |
| 4348 | | try self.load_commands.append(self.base.allocator, .{ |
| 4349 | | .VersionMin = .{ |
| 4350 | | .cmd = cmd, |
| 4351 | | .cmdsize = @sizeOf(macho.version_min_command), |
| 4352 | | .version = version, |
| 4353 | | .sdk = version, |
| 4358 | var cmd = commands.emptyGenericCommandWithData(macho.build_version_command{ |
| 4359 | .cmd = macho.LC_BUILD_VERSION, |
| 4360 | .cmdsize = cmdsize, |
| 4361 | .platform = switch (self.base.options.target.os.tag) { |
| 4362 | .macos => macho.PLATFORM_MACOS, |
| 4363 | .ios => macho.PLATFORM_IOSSIMULATOR, |
| 4364 | .watchos => macho.PLATFORM_WATCHOS, |
| 4365 | .tvos => macho.PLATFORM_TVOS, |
| 4366 | else => unreachable, |
| 4354 | 4367 | }, |
| 4368 | .minos = version, |
| 4369 | .sdk = version, |
| 4370 | .ntools = 1, |
| 4355 | 4371 | }); |
| 4356 | | self.load_commands_dirty = true; |
| 4372 | const ld_ver = macho.build_tool_version{ |
| 4373 | .tool = macho.TOOL_LD, |
| 4374 | .version = 0x0, |
| 4375 | }; |
| 4376 | cmd.data = try self.base.allocator.alloc(u8, cmdsize - @sizeOf(macho.build_version_command)); |
| 4377 | mem.set(u8, cmd.data, 0); |
| 4378 | mem.copy(u8, cmd.data, mem.asBytes(&ld_ver)); |
| 4379 | try self.load_commands.append(self.base.allocator, .{ .BuildVersion = cmd }); |
| 4357 | 4380 | } |
| 4358 | 4381 | if (self.source_version_cmd_index == null) { |
| 4359 | 4382 | self.source_version_cmd_index = @intCast(u16, self.load_commands.items.len); |