From 8e144e41dedb37f0566b4f95218bc3168f80d543 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 1 Jun 2022 15:34:12 +0800 Subject: [PATCH] reloc: impl ARM_PREL31 handling --- src/libdyld/src/reloc.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libdyld/src/reloc.rs b/src/libdyld/src/reloc.rs index ad6780ea..1bbacea8 100644 --- a/src/libdyld/src/reloc.rs +++ b/src/libdyld/src/reloc.rs @@ -143,9 +143,17 @@ pub fn relocate( _ => unreachable!() } } - } + }; - lib.image.write(rel.offset(), value) + match rel.type_info() { + R_ARM_PREL31 => { + let reloc_word = lib.image.get_ref::(rel.offset()) + .ok_or("relocation offset cannot be read")?; + lib.image.write(rel.offset(), (reloc_word & 0x80000000) | (value & 0x7FFFFFFF)) + }, + + _ => lib.image.write(rel.offset(), value), + } } pub fn rebind(