From c136527168d76d929740764e5fcc0732ee3027d0 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 14 Jan 2022 15:23:05 +0000 Subject: [PATCH] Support ARM64 relocations when writing a Mach-O object --- src/write/macho.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/write/macho.rs b/src/write/macho.rs index db4a1dab..f689dec5 100644 --- a/src/write/macho.rs +++ b/src/write/macho.rs @@ -584,11 +584,25 @@ impl<'a> Object<'a> { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, + Architecture::Aarch64 => match (reloc.kind, reloc.encoding, reloc.addend) { + (RelocationKind::Absolute, RelocationEncoding::Generic, 0) => { + (false, macho::ARM64_RELOC_UNSIGNED) + } + ( + RelocationKind::MachO { value, relative }, + RelocationEncoding::Generic, + 0, + ) => (relative, value), + _ => { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } + }, _ => { - return Err(Error(format!( - "unimplemented architecture {:?}", - self.architecture - ))); + if let RelocationKind::MachO { value, relative } = reloc.kind { + (relative, value) + } else { + return Err(Error(format!("unimplemented relocation {:?}", reloc))); + } } }; let reloc_info = macho::RelocationInfo {