| ... | ... | @@ -69,11 +69,12 @@ pub fn calcAdhocSignature(self: *CodeSignature, bin_file: *const MachO) !void { |
| 69 | 69 | const text_segment = bin_file.load_commands.items[bin_file.text_segment_cmd_index.?].Segment; |
| 70 | 70 | const data_segment = bin_file.load_commands.items[bin_file.data_segment_cmd_index.?].Segment; |
| 71 | 71 | const linkedit_segment = bin_file.load_commands.items[bin_file.linkedit_segment_cmd_index.?].Segment; |
| 72 | | const symtab = bin_file.load_commands.items[bin_file.symtab_cmd_index.?].Symtab; |
| 72 | const code_sig_cmd = bin_file.load_commands.items[bin_file.code_signature_cmd_index.?].LinkeditData; |
| 73 | 73 | |
| 74 | 74 | const execSegBase: u64 = text_segment.fileoff; |
| 75 | 75 | const execSegLimit: u64 = text_segment.filesize; |
| 76 | 76 | const execSegFlags: u64 = if (bin_file.base.options.output_mode == .Exe) macho.CS_EXECSEG_MAIN_BINARY else 0; |
| 77 | const file_size = code_sig_cmd.dataoff; |
| 77 | 78 | var cdir = CodeDirectory{ |
| 78 | 79 | .inner = .{ |
| 79 | 80 | .magic = macho.CSMAGIC_CODEDIRECTORY, |
| ... | ... | @@ -84,7 +85,7 @@ pub fn calcAdhocSignature(self: *CodeSignature, bin_file: *const MachO) !void { |
| 84 | 85 | .identOffset = 0, |
| 85 | 86 | .nSpecialSlots = 0, |
| 86 | 87 | .nCodeSlots = 0, |
| 87 | | .codeLimit = 0, |
| 88 | .codeLimit = @intCast(u32, file_size), |
| 88 | 89 | .hashSize = hash_size, |
| 89 | 90 | .hashType = macho.CS_HASHTYPE_SHA256, |
| 90 | 91 | .platform = 0, |
| ... | ... | @@ -100,7 +101,6 @@ pub fn calcAdhocSignature(self: *CodeSignature, bin_file: *const MachO) !void { |
| 100 | 101 | }, |
| 101 | 102 | }; |
| 102 | 103 | |
| 103 | | const file_size = symtab.stroff + symtab.strsize; |
| 104 | 104 | const total_pages = mem.alignForward(file_size, page_size) / page_size; |
| 105 | 105 | log.debug("Total file size: {}; total number of pages: {}\n", .{ file_size, total_pages }); |
| 106 | 106 | |