From 1f16561faca5d4094211edfc91add369821c108a Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 23 Jul 2024 19:59:51 +0530 Subject: [PATCH 1/2] mach-o: disable MachoSigner for non-Arm --- lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib.rs b/lib.rs index fba9011..4f86149 100644 --- a/lib.rs +++ b/lib.rs @@ -542,9 +542,13 @@ impl Macho { pub fn build_and_sign(self, writer: W) -> Result<(), Error> { let mut data = Vec::new(); self.build(&mut data)?; - - let codesign = apple_codesign::MachoSigner::new(data)?; - codesign.sign(writer) + if self.header.cputype & CPU_TYPE_ARM != 0 { + let codesign = apple_codesign::MachoSigner::new(data)?; + codesign.sign(writer) + } else { + writer.write_all(&data)?; + Ok(()) + } } } From 05cef2cdd2e088e95e6895cffbb4162cb529b8a4 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 23 Jul 2024 20:03:21 +0530 Subject: [PATCH 2/2] x --- lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib.rs b/lib.rs index 4f86149..41ded7b 100644 --- a/lib.rs +++ b/lib.rs @@ -539,15 +539,14 @@ impl Macho { Ok(()) } - pub fn build_and_sign(self, writer: W) -> Result<(), Error> { - let mut data = Vec::new(); - self.build(&mut data)?; + pub fn build_and_sign(self, mut writer: W) -> Result<(), Error> { if self.header.cputype & CPU_TYPE_ARM != 0 { + let mut data = Vec::new(); + self.build(&mut data)?; let codesign = apple_codesign::MachoSigner::new(data)?; codesign.sign(writer) } else { - writer.write_all(&data)?; - Ok(()) + self.build(&mut writer) } } }