diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-12-09 11:38:11 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-12-09 20:36:58 +0100 |
| commit | 184c0f3c4e140d3f0971bac184f0abce00d8d336 (patch) | |
| tree | b04396a82a82f7ff351a7f7a7825f7e4f023fc1f /src | |
| parent | 601600dec981e41d43bb72113d9284cbb9e1d9ae (diff) | |
| download | zig-184c0f3c4e140d3f0971bac184f0abce00d8d336.tar.gz zig-184c0f3c4e140d3f0971bac184f0abce00d8d336.zip | |
stage2+macho: write code signature only when targeting aarch64
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO.zig | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 120326da96..1466f75486 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -301,7 +301,10 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { const tracy = trace(@src()); defer tracy.end(); - switch (self.base.options.output_mode) { + const output_mode = self.base.options.output_mode; + const target = self.base.options.target; + + switch (output_mode) { .Exe => { if (self.entry_addr) |addr| { // Update LC_MAIN with entry offset. @@ -312,12 +315,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { try self.writeExportTrie(); try self.writeSymbolTable(); try self.writeStringTable(); - // Preallocate space for the code signature. - // We need to do this at this stage so that we have the load commands with proper values - // written out to the file. - // The most important here is to have the correct vm and filesize of the __LINKEDIT segment - // where the code signature goes into. - try self.writeCodeSignaturePadding(); + + if (target.cpu.arch == .aarch64) { + // Preallocate space for the code signature. + // We need to do this at this stage so that we have the load commands with proper values + // written out to the file. + // The most important here is to have the correct vm and filesize of the __LINKEDIT segment + // where the code signature goes into. + try self.writeCodeSignaturePadding(); + } }, .Obj => {}, .Lib => return error.TODOImplementWritingLibFiles, @@ -339,9 +345,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { assert(!self.cmd_table_dirty); - switch (self.base.options.output_mode) { - .Exe, .Lib => try self.writeCodeSignature(), // code signing always comes last - else => {}, + if (target.cpu.arch == .aarch64) { + switch (output_mode) { + .Exe, .Lib => try self.writeCodeSignature(), // code signing always comes last + else => {}, + } } } |
