From: Julian Seward Date: Tue, 17 Jan 2006 01:42:56 +0000 (+0000) Subject: Give the ppc64 guest state a 16-entry pseudo-register array, X-Git-Tag: svn/VALGRIND_3_2_3^2~122 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4364bd7c74a9d0d38d342cd93818df45a7f58f60;p=thirdparty%2Fvalgrind.git Give the ppc64 guest state a 16-entry pseudo-register array, 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 --- diff --git a/VEX/priv/guest-ppc/ghelpers.c b/VEX/priv/guest-ppc/ghelpers.c index 54d1767020..a070c91d36 100644 --- a/VEX/priv/guest-ppc/ghelpers.c +++ b/VEX/priv/guest-ppc/ghelpers.c @@ -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) } }; diff --git a/VEX/pub/libvex_guest_ppc64.h b/VEX/pub/libvex_guest_ppc64.h index eee7094e2a..b03db616d3 100644 --- a/VEX/pub/libvex_guest_ppc64.h +++ b/VEX/pub/libvex_guest_ppc64.h @@ -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; */ }