| ... | @@ -301,7 +301,10 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -301,7 +301,10 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 301 | const tracy = trace(@src()); | 301 | const tracy = trace(@src()); |
| 302 | defer tracy.end(); | 302 | defer tracy.end(); |
| 303 | | 303 | |
| 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) { |
| 305 | .Exe => { | 308 | .Exe => { |
| 306 | if (self.entry_addr) |addr| { | 309 | if (self.entry_addr) |addr| { |
| 307 | // Update LC_MAIN with entry offset. | 310 | // Update LC_MAIN with entry offset. |
| ... | @@ -312,12 +315,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -312,12 +315,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 312 | try self.writeExportTrie(); | 315 | try self.writeExportTrie(); |
| 313 | try self.writeSymbolTable(); | 316 | try self.writeSymbolTable(); |
| 314 | try self.writeStringTable(); | 317 | try self.writeStringTable(); |
| 315 | // Preallocate space for the code signature. | 318 | |
| 316 | // We need to do this at this stage so that we have the load commands with proper values | 319 | if (target.cpu.arch == .aarch64) { |
| 317 | // written out to the file. | 320 | // Preallocate space for the code signature. |
| 318 | // The most important here is to have the correct vm and filesize of the __LINKEDIT segment | 321 | // We need to do this at this stage so that we have the load commands with proper values |
| 319 | // where the code signature goes into. | 322 | // written out to the file. |
| 320 | try self.writeCodeSignaturePadding(); | 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 | } |
| 321 | }, | 327 | }, |
| 322 | .Obj => {}, | 328 | .Obj => {}, |
| 323 | .Lib => return error.TODOImplementWritingLibFiles, | 329 | .Lib => return error.TODOImplementWritingLibFiles, |
| ... | @@ -339,9 +345,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { | ... | @@ -339,9 +345,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 339 | | 345 | |
| 340 | assert(!self.cmd_table_dirty); | 346 | assert(!self.cmd_table_dirty); |
| 341 | | 347 | |
| 342 | switch (self.base.options.output_mode) { | 348 | if (target.cpu.arch == .aarch64) { |
| 343 | .Exe, .Lib => try self.writeCodeSignature(), // code signing always comes last | 349 | switch (output_mode) { |
| 344 | else => {}, | 350 | .Exe, .Lib => try self.writeCodeSignature(), // code signing always comes last |
| | 351 | else => {}, |
| | 352 | } |
| 345 | } | 353 | } |
| 346 | } | 354 | } |
| 347 | | 355 | |