]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
ppc64-linux: compute the correct initial program counter and tocptr
authorJulian Seward <jseward@acm.org>
Fri, 20 Jan 2006 21:45:36 +0000 (21:45 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 20 Jan 2006 21:45:36 +0000 (21:45 +0000)
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

index 1b8c67052cfeb25c10c37746e8f3e5cf9b05c027..328bae1a622f64ea1944a591d883592d151014d9 100644 (file)
@@ -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 */