Skip to content

Commit f046f8c

Browse files
authored
mach-o: Fix cputype type (#12)
1 parent 35ce0e0 commit f046f8c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub(crate) struct SegmentCommand64 {
214214
#[repr(C)]
215215
pub(crate) struct Header64 {
216216
magic: u32,
217-
cputype: u32,
217+
cputype: i32,
218218
cpusubtype: u32,
219219
filetype: u32,
220220
ncmds: u32,
@@ -255,7 +255,7 @@ const LC_LINKER_OPTIMIZATION_HINT: u32 = 0x2d;
255255
const LC_DYLD_EXPORTS_TRIE: u32 = 0x8000001e;
256256
const LC_DYLD_CHAINED_FIXUPS: u32 = 0x80000034;
257257

258-
const CPU_TYPE_ARM: u32 = 12;
258+
const CPU_TYPE_ARM_64: i32 = 0x0100000c;
259259

260260
fn align(size: u64, base: u64) -> u64 {
261261
let over = size % base;
@@ -341,7 +341,7 @@ impl Macho {
341341
}
342342

343343
pub fn write_section(mut self, name: &str, sectdata: Vec<u8>) -> Result<Self, Error> {
344-
let page_size = if self.header.cputype & CPU_TYPE_ARM != 0 {
344+
let page_size = if self.header.cputype == CPU_TYPE_ARM_64 {
345345
0x10000
346346
} else {
347347
0x1000
@@ -540,7 +540,7 @@ impl Macho {
540540
}
541541

542542
pub fn build_and_sign<W: Write>(self, mut writer: W) -> Result<(), Error> {
543-
if self.header.cputype & CPU_TYPE_ARM != 0 {
543+
if self.header.cputype == CPU_TYPE_ARM_64 {
544544
let mut data = Vec::new();
545545
self.build(&mut data)?;
546546
let codesign = apple_codesign::MachoSigner::new(data)?;

0 commit comments

Comments
 (0)