From 35250b3f5630e23cfb80821f4c76e33c4eb7860f Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 25 Sep 2021 11:30:45 +0800 Subject: [PATCH] libdyld: fixed symbol relocation Note that in libdyld/src/lib.rs #117-118, image pointer is already added to the symbol offset, so we do not need to add the pointer again --- src/libdyld/src/reloc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libdyld/src/reloc.rs b/src/libdyld/src/reloc.rs index 85667d07..056e04c2 100644 --- a/src/libdyld/src/reloc.rs +++ b/src/libdyld/src/reloc.rs @@ -123,7 +123,7 @@ pub fn relocate( if let Some(addr) = lib.lookup(sym_name) { // First, try to resolve against itself. trace!("looked up symbol {} in image", format_sym_name(sym_name)); - value = lib.image.ptr() as u32 + addr; + value = addr; } else if let Some(addr) = resolve(sym_name) { // Second, call the user-provided function. trace!("resolved symbol {:?}", format_sym_name(sym_name));