zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 184c0f3c4e140d3f0971bac184f0abce00d8d336 (tree)
parent 601600dec981e41d43bb72113d9284cbb9e1d9ae
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Wed,  9 Dec 2020 11:38:11 +0100

stage2+macho: write code signature only when targeting aarch64

Diffstat:
Msrc/link/MachO.zig | 28++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

diff --git 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 => {}, + } } }