| author | |
| committer | |
| log | ec03619dcfa025442f6a70cbdfeafd5882591b64 |
| tree | bb12250c1bc67c0e6d7dc662c65f17cae71fb600 |
| parent | 052984c5ae43a9846f012c3b3b1449c8aef47d2f |
3 files changed, 10 insertions(+), 18 deletions(-)
src/link/MachO.zig+6-6| ... | @@ -530,7 +530,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -530,7 +530,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 530 | 530 | ||
| 531 | try self.writeLinkeditSegmentData(); | 531 | try self.writeLinkeditSegmentData(); |
| 532 | 532 | ||
| 533 | var codesig: ?CodeSignature = if (self.requiresCodeSignature()) blk: { | 533 | var codesig: ?CodeSignature = if (requiresCodeSignature(&self.base.options)) blk: { |
| 534 | // Preallocate space for the code signature. | 534 | // Preallocate space for the code signature. |
| 535 | // We need to do this at this stage so that we have the load commands with proper values | 535 | // We need to do this at this stage so that we have the load commands with proper values |
| 536 | // written out to the file. | 536 | // written out to the file. |
| ... | @@ -4767,11 +4767,11 @@ pub inline fn getPageSize(cpu_arch: std.Target.Cpu.Arch) u16 { | ... | @@ -4767,11 +4767,11 @@ pub inline fn getPageSize(cpu_arch: std.Target.Cpu.Arch) u16 { |
| 4767 | }; | 4767 | }; |
| 4768 | } | 4768 | } |
| 4769 | 4769 | ||
| 4770 | pub fn requiresCodeSignature(self: MachO) bool { | 4770 | pub fn requiresCodeSignature(options: *const link.Options) bool { |
| 4771 | if (self.base.options.entitlements) |_| return true; | 4771 | if (options.entitlements) |_| return true; |
| 4772 | const cpu_arch = self.base.options.target.cpu.arch; | 4772 | const cpu_arch = options.target.cpu.arch; |
| 4773 | const os_tag = self.base.options.target.os.tag; | 4773 | const os_tag = options.target.os.tag; |
| 4774 | const abi = self.base.options.target.abi; | 4774 | const abi = options.target.abi; |
| 4775 | if (cpu_arch == .aarch64 and (os_tag == .macos or abi == .simulator)) return true; | 4775 | if (cpu_arch == .aarch64 and (os_tag == .macos or abi == .simulator)) return true; |
| 4776 | return false; | 4776 | return false; |
| 4777 | } | 4777 | } |
src/link/MachO/load_commands.zig+3-11| ... | @@ -91,17 +91,8 @@ fn calcLCsSize(gpa: Allocator, options: *const link.Options, ctx: CalcLCsSizeCtx | ... | @@ -91,17 +91,8 @@ fn calcLCsSize(gpa: Allocator, options: *const link.Options, ctx: CalcLCsSizeCtx |
| 91 | ); | 91 | ); |
| 92 | } | 92 | } |
| 93 | // LC_CODE_SIGNATURE | 93 | // LC_CODE_SIGNATURE |
| 94 | { | 94 | if (MachO.requiresCodeSignature(options)) { |
| 95 | const target = options.target; | 95 | sizeofcmds += @sizeOf(macho.linkedit_data_command); |
| 96 | const requires_codesig = blk: { | ||
| 97 | if (options.entitlements) |_| break :blk true; | ||
| 98 | if (target.cpu.arch == .aarch64 and (target.os.tag == .macos or target.abi == .simulator)) | ||
| 99 | break :blk true; | ||
| 100 | break :blk false; | ||
| 101 | }; | ||
| 102 | if (requires_codesig) { | ||
| 103 | sizeofcmds += @sizeOf(macho.linkedit_data_command); | ||
| 104 | } | ||
| 105 | } | 96 | } |
| 106 | 97 | ||
| 107 | return @as(u32, @intCast(sizeofcmds)); | 98 | return @as(u32, @intCast(sizeofcmds)); |
| ... | @@ -374,3 +365,4 @@ const mem = std.mem; | ... | @@ -374,3 +365,4 @@ const mem = std.mem; |
| 374 | 365 | ||
| 375 | const Allocator = mem.Allocator; | 366 | const Allocator = mem.Allocator; |
| 376 | const Dylib = @import("Dylib.zig"); | 367 | const Dylib = @import("Dylib.zig"); |
| 368 | const MachO = @import("../MachO.zig"); |
src/link/MachO/zld.zig+1-1| ... | @@ -529,7 +529,7 @@ pub fn linkWithZld( | ... | @@ -529,7 +529,7 @@ pub fn linkWithZld( |
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | // Write code signature padding if required | 531 | // Write code signature padding if required |
| 532 | var codesig: ?CodeSignature = if (macho_file.requiresCodeSignature()) blk: { | 532 | var codesig: ?CodeSignature = if (MachO.requiresCodeSignature(&macho_file.base.options)) blk: { |
| 533 | // Preallocate space for the code signature. | 533 | // Preallocate space for the code signature. |
| 534 | // We need to do this at this stage so that we have the load commands with proper values | 534 | // We need to do this at this stage so that we have the load commands with proper values |
| 535 | // written out to the file. | 535 | // written out to the file. |