authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-09 11:38:11+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-09 20:36:58+01:00
log184c0f3c4e140d3f0971bac184f0abce00d8d336
treeb04396a82a82f7ff351a7f7a7825f7e4f023fc1f
parent601600dec981e41d43bb72113d9284cbb9e1d9ae

stage2+macho: write code signature only when targeting aarch64


1 files changed, 18 insertions(+), 10 deletions(-)

src/link/MachO.zig+18-10
......@@ -301,7 +301,10 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
301301 const tracy = trace(@src());
302302 defer tracy.end();
303303
304 switch (self.base.options.output_mode) {
304 const output_mode = self.base.options.output_mode;
305 const target = self.base.options.target;
306
307 switch (output_mode) {
305308 .Exe => {
306309 if (self.entry_addr) |addr| {
307310 // Update LC_MAIN with entry offset.
......@@ -312,12 +315,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
312315 try self.writeExportTrie();
313316 try self.writeSymbolTable();
314317 try self.writeStringTable();
315 // Preallocate space for the code signature.
316 // We need to do this at this stage so that we have the load commands with proper values
317 // written out to the file.
318 // The most important here is to have the correct vm and filesize of the __LINKEDIT segment
319 // where the code signature goes into.
320 try self.writeCodeSignaturePadding();
318
319 if (target.cpu.arch == .aarch64) {
320 // Preallocate space for the code signature.
321 // We need to do this at this stage so that we have the load commands with proper values
322 // written out to the file.
323 // The most important here is to have the correct vm and filesize of the __LINKEDIT segment
324 // where the code signature goes into.
325 try self.writeCodeSignaturePadding();
326 }
321327 },
322328 .Obj => {},
323329 .Lib => return error.TODOImplementWritingLibFiles,
......@@ -339,9 +345,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void {
339345
340346 assert(!self.cmd_table_dirty);
341347
342 switch (self.base.options.output_mode) {
343 .Exe, .Lib => try self.writeCodeSignature(), // code signing always comes last
344 else => {},
348 if (target.cpu.arch == .aarch64) {
349 switch (output_mode) {
350 .Exe, .Lib => try self.writeCodeSignature(), // code signing always comes last
351 else => {},
352 }
345353 }
346354}
347355