]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Give the ppc64 guest state a 16-entry pseudo-register array,
authorJulian Seward <jseward@acm.org>
Tue, 17 Jan 2006 01:42:56 +0000 (01:42 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 17 Jan 2006 01:42:56 +0000 (01:42 +0000)
guest_REDIR_STACK.  This is used (along with a stack pointer,
guest_REDIR_SP) by Valgrind to support function replacement and
wrapping on ppc64-linux.  Due to the strange ppc64-linux ABI, both
replacement and wrapping require saving (%R2,%LR) pairs on a stack,
and this provides the stack.

git-svn-id: svn://svn.valgrind.org/vex/trunk@1539

VEX/priv/guest-ppc/ghelpers.c
VEX/pub/libvex_guest_ppc64.h

index 54d176702001fb893829fd105550027638e6529c..a070c91d36d7c51ab82462841e1698905ace862b 100644 (file)
@@ -470,6 +470,7 @@ void LibVEX_GuestPPC32_initialise ( /*OUT*/VexGuestPPC32State* vex_state )
 /* VISIBLE TO LIBVEX CLIENT */
 void LibVEX_GuestPPC64_initialise ( /*OUT*/VexGuestPPC64State* vex_state )
 {
+   Int i;
    vex_state->guest_GPR0  = 0;
    vex_state->guest_GPR1  = 0;
    vex_state->guest_GPR2  = 0;
@@ -614,6 +615,10 @@ void LibVEX_GuestPPC64_initialise ( /*OUT*/VexGuestPPC64State* vex_state )
    vex_state->guest_TILEN   = 0;
 
    vex_state->guest_NRADDR = 0;
+
+   vex_state->guest_REDIR_SP = -1;
+   for (i = 0; i < VEX_GUEST_PPC64_REDIR_STACK_SIZE; i++)
+      vex_state->guest_REDIR_STACK[i] = 0;
 }
 
 
@@ -715,7 +720,7 @@ VexGuestLayout
 
           /* Describe any sections to be regarded by Memcheck as
              'always-defined'. */
-          .n_alwaysDefd = 7,
+          .n_alwaysDefd = 8,
 
           .alwaysDefd 
          = { /*  0 */ ALWAYSDEFD32(guest_CIA),
@@ -724,7 +729,8 @@ VexGuestLayout
              /*  3 */ ALWAYSDEFD32(guest_TILEN),
              /*  4 */ ALWAYSDEFD32(guest_VSCR),
              /*  5 */ ALWAYSDEFD32(guest_FPROUND),
-             /*  6 */ ALWAYSDEFD32(guest_RESVN)
+             /*  6 */ ALWAYSDEFD32(guest_RESVN),
+             /*  7 */ ALWAYSDEFD32(guest_NRADDR)
             }
         };
 
@@ -748,7 +754,7 @@ VexGuestLayout
 
           /* Describe any sections to be regarded by Memcheck as
              'always-defined'. */
-          .n_alwaysDefd = 7,
+          .n_alwaysDefd = 10,
 
           .alwaysDefd 
          = { /*  0 */ ALWAYSDEFD64(guest_CIA),
@@ -757,7 +763,10 @@ VexGuestLayout
              /*  3 */ ALWAYSDEFD64(guest_TILEN),
              /*  4 */ ALWAYSDEFD64(guest_VSCR),
              /*  5 */ ALWAYSDEFD64(guest_FPROUND),
-             /*  6 */ ALWAYSDEFD64(guest_RESVN)
+             /*  6 */ ALWAYSDEFD64(guest_RESVN),
+             /*  7 */ ALWAYSDEFD64(guest_NRADDR),
+             /*  8 */ ALWAYSDEFD64(guest_REDIR_SP),
+             /*  9 */ ALWAYSDEFD64(guest_REDIR_STACK)
             }
         };
 
index eee7094e2a81bdd26c5b8392a6e8924391ca27f6..b03db616d39c253b8ddc546d11f059d6e085f225 100644 (file)
@@ -93,6 +93,8 @@ vrsave    Non-volatile 32-bit register
 /*--- Vex's representation of the PPC64 CPU state             ---*/
 /*---------------------------------------------------------------*/
 
+#define VEX_GUEST_PPC64_REDIR_STACK_SIZE 16
+
 typedef
    struct {
       /* General Purpose Registers */
@@ -256,6 +258,13 @@ typedef
          replace-style ones. */
       /* 1112 */ ULong guest_NRADDR;
 
+     /* A grows-upwards stack for hidden saves/restores of LR and R2
+        needed for function interception and wrapping on ppc64-linux.
+        A horrible hack.  REDIR_SP points to the highest live entry,
+        and so starts at -1. */
+      /* 1120 */ ULong guest_REDIR_SP;
+      /* 1128 */ ULong guest_REDIR_STACK[VEX_GUEST_PPC64_REDIR_STACK_SIZE];
+
       /* Padding to make it have an 8-aligned size */
       /* UInt  padding; */
    }