From 5117c573425d97c62fef531bede77c12da8abae7 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sat, 15 Jan 2022 03:45:08 +0000 Subject: [PATCH] write/macho: support ARM64 relocations (#422) --- 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 {