From 0297c5e469e30092298f8dbbcc35e6123e8b720f Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 20 Jan 2006 21:45:36 +0000 Subject: [PATCH] ppc64-linux: compute the correct initial program counter and tocptr when the interpreter is loaded at a different address than what it asked for. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5576 --- coregrind/m_ume.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/coregrind/m_ume.c b/coregrind/m_ume.c index 1b8c67052..328bae1a6 100644 --- a/coregrind/m_ume.c +++ b/coregrind/m_ume.c @@ -329,6 +329,11 @@ static Int load_ELF(Int fd, const HChar* name, /*MOD*/ExeInfo* info) void *entry; ESZ(Addr) ebase = 0; + /* The difference between where the interpreter got mapped and + where it asked to be mapped. Needed for computing the ppc64 ELF + entry point and initial tocptr (R2) value. */ + ESZ(Word) interp_offset = 0; + #ifdef HAVE_PIE ebase = info->exe_base; #endif @@ -484,6 +489,7 @@ static Int load_ELF(Int fd, const HChar* name, /*MOD*/ExeInfo* info) entry = (void *)(advised - interp_addr + interp->e.e_entry); info->interp_base = (ESZ(Addr))advised; + interp_offset = advised - interp_addr; VG_(free)(interp->p); VG_(free)(interp); @@ -500,6 +506,8 @@ static Int load_ELF(Int fd, const HChar* name, /*MOD*/ExeInfo* info) is the static chain value. */ info->init_ip = ((ULong*)entry)[0]; info->init_toc = ((ULong*)entry)[1]; + info->init_ip += interp_offset; + info->init_toc += interp_offset; #else info->init_ip = (Addr)entry; info->init_toc = 0; /* meaningless on this platform */