| ... | ... | @@ -301,7 +301,10 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 301 | 301 | const tracy = trace(@src()); |
| 302 | 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 | 308 | .Exe => { |
| 306 | 309 | if (self.entry_addr) |addr| { |
| 307 | 310 | // Update LC_MAIN with entry offset. |
| ... | ... | @@ -312,12 +315,15 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 312 | 315 | try self.writeExportTrie(); |
| 313 | 316 | try self.writeSymbolTable(); |
| 314 | 317 | 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 | } |
| 321 | 327 | }, |
| 322 | 328 | .Obj => {}, |
| 323 | 329 | .Lib => return error.TODOImplementWritingLibFiles, |
| ... | ... | @@ -339,9 +345,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 339 | 345 | |
| 340 | 346 | assert(!self.cmd_table_dirty); |
| 341 | 347 | |
| 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 | } |
| 345 | 353 | } |
| 346 | 354 | } |
| 347 | 355 | |