diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-12-01 17:49:38 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-12-01 18:03:04 +0100 |
| commit | abb697e751cb0febf4e5e26f0190c01d7c5fd922 (patch) | |
| tree | 90e863418f37e9333b11cc9bdd788b36f4db06ba /src/link/MachO.zig | |
| parent | 1f7fb560ab5a3a82af24ab7abe11dce8f877c7fe (diff) | |
| download | zig-abb697e751cb0febf4e5e26f0190c01d7c5fd922.tar.gz zig-abb697e751cb0febf4e5e26f0190c01d7c5fd922.zip | |
macho: unify code signature between stage1 and stage2
Diffstat (limited to 'src/link/MachO.zig')
| -rw-r--r-- | src/link/MachO.zig | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 020faa88b3..921c49763d 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -773,7 +773,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { var signature = CodeSignature.init(self.base.allocator); defer signature.deinit(); const emit = self.base.options.emit.?; - try signature.calcAdhocSignatureFile( + try signature.calcAdhocSignature( out_file, emit.sub_path, text_cmd, @@ -1741,15 +1741,21 @@ fn writeCodeSignaturePadding(self: *MachO) !void { } fn writeCodeSignature(self: *MachO) !void { - const code_sig_cmd = &self.load_commands.items[self.code_signature_cmd_index.?].LinkeditData; + const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment; + const code_sig_cmd = self.load_commands.items[self.code_signature_cmd_index.?].LinkeditData; + var code_sig = CodeSignature.init(self.base.allocator); defer code_sig.deinit(); - - try code_sig.calcAdhocSignature(self); + try code_sig.calcAdhocSignature( + self.base.file.?, + self.base.options.emit.?.sub_path, + text_segment.inner, + code_sig_cmd, + self.base.options.output_mode, + ); var buffer = try self.base.allocator.alloc(u8, code_sig.size()); defer self.base.allocator.free(buffer); - code_sig.write(buffer); log.debug("writing code signature from 0x{x} to 0x{x}\n", .{ code_sig_cmd.dataoff, code_sig_cmd.dataoff + buffer.len }); |
