From: Florian Krohm Date: Mon, 22 Sep 2014 21:43:37 +0000 (+0000) Subject: Constification part 2. X-Git-Tag: svn/VALGRIND_3_11_0^2~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb9ce98b6eee880393c33b4ce8178818feab63ec;p=thirdparty%2Fvalgrind.git Constification part 2. Constify parameters of the LibVEX_Chain/Unchain/PatchProfInc. git-svn-id: svn://svn.valgrind.org/vex/trunk@2956 --- diff --git a/VEX/priv/host_amd64_defs.c b/VEX/priv/host_amd64_defs.c index 9a4aa3e769..f13a35f48d 100644 --- a/VEX/priv/host_amd64_defs.c +++ b/VEX/priv/host_amd64_defs.c @@ -3552,8 +3552,8 @@ Int evCheckSzB_AMD64 ( VexEndness endness_host ) emitInstr case for XDirect, above. */ VexInvalRange chainXDirect_AMD64 ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ) + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ) { vassert(endness_host == VexEndnessLE); @@ -3599,7 +3599,7 @@ VexInvalRange chainXDirect_AMD64 ( VexEndness endness_host, */ /* This is the delta we need to put into a JMP d32 insn. It's relative to the start of the next insn, hence the -5. */ - Long delta = (Long)((UChar*)place_to_jump_to - (UChar*)p) - (Long)5; + Long delta = (Long)((const UChar *)place_to_jump_to - (const UChar*)p) - 5; Bool shortOK = delta >= -1000*1000*1000 && delta < 1000*1000*1000; static UInt shortCTR = 0; /* DO NOT MAKE NON-STATIC */ @@ -3641,8 +3641,8 @@ VexInvalRange chainXDirect_AMD64 ( VexEndness endness_host, emitInstr case for XDirect, above. */ VexInvalRange unchainXDirect_AMD64 ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ) + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ) { vassert(endness_host == VexEndnessLE); @@ -3678,7 +3678,7 @@ VexInvalRange unchainXDirect_AMD64 ( VexEndness endness_host, /* It's the short form. Check the offset is right. */ Int s32 = *(Int*)(&p[1]); Long s64 = (Long)s32; - if ((UChar*)p + 5 + s64 == (UChar*)place_to_jump_to_EXPECTED) { + if ((UChar*)p + 5 + s64 == place_to_jump_to_EXPECTED) { valid = True; if (0) vex_printf("QQQ unchainXDirect_AMD64: found short form\n"); @@ -3708,7 +3708,7 @@ VexInvalRange unchainXDirect_AMD64 ( VexEndness endness_host, created by the Ain_ProfInc case for emit_AMD64Instr. */ VexInvalRange patchProfInc_AMD64 ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ) + const ULong* location_of_counter ) { vassert(endness_host == VexEndnessLE); vassert(sizeof(ULong*) == 8); diff --git a/VEX/priv/host_amd64_defs.h b/VEX/priv/host_amd64_defs.h index c8b49c96f0..e16ed8e32c 100644 --- a/VEX/priv/host_amd64_defs.h +++ b/VEX/priv/host_amd64_defs.h @@ -789,18 +789,18 @@ extern Int evCheckSzB_AMD64 ( VexEndness endness_host ); /* Perform a chaining and unchaining of an XDirect jump. */ extern VexInvalRange chainXDirect_AMD64 ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ); + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ); extern VexInvalRange unchainXDirect_AMD64 ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ); + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ); /* Patch the counter location into an existing ProfInc point. */ extern VexInvalRange patchProfInc_AMD64 ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ); + const ULong* location_of_counter ); #endif /* ndef __VEX_HOST_AMD64_DEFS_H */ diff --git a/VEX/priv/host_arm64_defs.c b/VEX/priv/host_arm64_defs.c index f39f933ea4..d08748e473 100644 --- a/VEX/priv/host_arm64_defs.c +++ b/VEX/priv/host_arm64_defs.c @@ -5137,8 +5137,8 @@ Int evCheckSzB_ARM64 ( VexEndness endness_host ) emitInstr case for XDirect, above. */ VexInvalRange chainXDirect_ARM64 ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ) + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ) { vassert(endness_host == VexEndnessLE); @@ -5183,8 +5183,8 @@ VexInvalRange chainXDirect_ARM64 ( VexEndness endness_host, emitInstr case for XDirect, above. */ VexInvalRange unchainXDirect_ARM64 ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ) + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ) { vassert(endness_host == VexEndnessLE); @@ -5227,7 +5227,7 @@ VexInvalRange unchainXDirect_ARM64 ( VexEndness endness_host, created by the ARM64in_ProfInc case for emit_ARM64Instr. */ VexInvalRange patchProfInc_ARM64 ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ) + const ULong* location_of_counter ) { vassert(sizeof(ULong*) == 8); vassert(endness_host == VexEndnessLE); diff --git a/VEX/priv/host_arm64_defs.h b/VEX/priv/host_arm64_defs.h index 4dbc59f610..0b37338a26 100644 --- a/VEX/priv/host_arm64_defs.h +++ b/VEX/priv/host_arm64_defs.h @@ -953,18 +953,18 @@ extern Int evCheckSzB_ARM64 ( VexEndness endness_host ); /* Perform a chaining and unchaining of an XDirect jump. */ extern VexInvalRange chainXDirect_ARM64 ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ); + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ); extern VexInvalRange unchainXDirect_ARM64 ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ); + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ); /* Patch the counter location into an existing ProfInc point. */ extern VexInvalRange patchProfInc_ARM64 ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ); + const ULong* location_of_counter ); #endif /* ndef __VEX_HOST_ARM64_DEFS_H */ diff --git a/VEX/priv/host_arm_defs.c b/VEX/priv/host_arm_defs.c index ed41344ef5..98e3c11ae9 100644 --- a/VEX/priv/host_arm_defs.c +++ b/VEX/priv/host_arm_defs.c @@ -4705,8 +4705,8 @@ Int evCheckSzB_ARM ( VexEndness endness_host ) emitInstr case for XDirect, above. */ VexInvalRange chainXDirect_ARM ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ) + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ) { vassert(endness_host == VexEndnessLE); @@ -4751,7 +4751,7 @@ VexInvalRange chainXDirect_ARM ( VexEndness endness_host, /* This is the delta we need to put into a B insn. It's relative to the start of the next-but-one insn, hence the -8. */ - Long delta = (Long)((UChar*)place_to_jump_to - (UChar*)p) - (Long)8; + Long delta = (Long)((const UChar *)place_to_jump_to - (const UChar*)p) - 8; Bool shortOK = delta >= -30*1000*1000 && delta < 30*1000*1000; vassert(0 == (delta & (Long)3)); @@ -4788,8 +4788,8 @@ VexInvalRange chainXDirect_ARM ( VexEndness endness_host, emitInstr case for XDirect, above. */ VexInvalRange unchainXDirect_ARM ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ) + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ) { vassert(endness_host == VexEndnessLE); @@ -4824,7 +4824,7 @@ VexInvalRange unchainXDirect_ARM ( VexEndness endness_host, /* It's the short form. Check the displacement is right. */ Int simm24 = p[0] & 0x00FFFFFF; simm24 <<= 8; simm24 >>= 8; - if ((UChar*)p + (simm24 << 2) + 8 == (UChar*)place_to_jump_to_EXPECTED) { + if ((UChar*)p + (simm24 << 2) + 8 == place_to_jump_to_EXPECTED) { valid = True; if (0) vex_printf("QQQ unchainXDirect_ARM: found short form\n"); @@ -4852,7 +4852,7 @@ VexInvalRange unchainXDirect_ARM ( VexEndness endness_host, created by the ARMin_ProfInc case for emit_ARMInstr. */ VexInvalRange patchProfInc_ARM ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ) + const ULong* location_of_counter ) { vassert(endness_host == VexEndnessLE); vassert(sizeof(ULong*) == 4); diff --git a/VEX/priv/host_arm_defs.h b/VEX/priv/host_arm_defs.h index 74889822a9..15316c4d56 100644 --- a/VEX/priv/host_arm_defs.h +++ b/VEX/priv/host_arm_defs.h @@ -1057,18 +1057,18 @@ extern Int evCheckSzB_ARM ( VexEndness endness_host ); /* Perform a chaining and unchaining of an XDirect jump. */ extern VexInvalRange chainXDirect_ARM ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ); + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ); extern VexInvalRange unchainXDirect_ARM ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ); + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ); /* Patch the counter location into an existing ProfInc point. */ extern VexInvalRange patchProfInc_ARM ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ); + const ULong* location_of_counter ); #endif /* ndef __VEX_HOST_ARM_DEFS_H */ diff --git a/VEX/priv/host_mips_defs.c b/VEX/priv/host_mips_defs.c index 58e50d45e6..28663c2b72 100644 --- a/VEX/priv/host_mips_defs.c +++ b/VEX/priv/host_mips_defs.c @@ -4326,8 +4326,8 @@ Int evCheckSzB_MIPS ( VexEndness endness_host ) emitInstr case for XDirect, above. */ VexInvalRange chainXDirect_MIPS ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to, + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to, Bool mode64 ) { vassert(endness_host == VexEndnessLE || endness_host == VexEndnessBE); @@ -4374,8 +4374,8 @@ VexInvalRange chainXDirect_MIPS ( VexEndness endness_host, emitInstr case for XDirect, above. */ VexInvalRange unchainXDirect_MIPS ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me, + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me, Bool mode64 ) { vassert(endness_host == VexEndnessLE || endness_host == VexEndnessBE); @@ -4420,7 +4420,8 @@ VexInvalRange unchainXDirect_MIPS ( VexEndness endness_host, created by the Min_ProfInc case for emit_MIPSInstr. */ VexInvalRange patchProfInc_MIPS ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter, Bool mode64 ) + const ULong* location_of_counter, + Bool mode64 ) { vassert(endness_host == VexEndnessLE || endness_host == VexEndnessBE); if (mode64) { diff --git a/VEX/priv/host_mips_defs.h b/VEX/priv/host_mips_defs.h index cfce11b285..f3039938e4 100644 --- a/VEX/priv/host_mips_defs.h +++ b/VEX/priv/host_mips_defs.h @@ -747,20 +747,20 @@ extern Int evCheckSzB_MIPS ( VexEndness endness_host ); /* Perform a chaining and unchaining of an XDirect jump. */ extern VexInvalRange chainXDirect_MIPS ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to, + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to, Bool mode64 ); extern VexInvalRange unchainXDirect_MIPS ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me, + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me, Bool mode64 ); /* Patch the counter location into an existing ProfInc point. */ extern VexInvalRange patchProfInc_MIPS ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter, + const ULong* location_of_counter, Bool mode64 ); #endif /* ndef __VEX_HOST_MIPS_DEFS_H */ diff --git a/VEX/priv/host_ppc_defs.c b/VEX/priv/host_ppc_defs.c index 70b65fc609..e4c8b91415 100644 --- a/VEX/priv/host_ppc_defs.c +++ b/VEX/priv/host_ppc_defs.c @@ -5834,8 +5834,8 @@ Int evCheckSzB_PPC ( VexEndness endness_host ) emitInstr case for XDirect, above. */ VexInvalRange chainXDirect_PPC ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to, + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to, Bool mode64 ) { if (mode64) { @@ -5888,8 +5888,8 @@ VexInvalRange chainXDirect_PPC ( VexEndness endness_host, emitInstr case for XDirect, above. */ VexInvalRange unchainXDirect_PPC ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me, + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me, Bool mode64 ) { if (mode64) { @@ -5942,7 +5942,7 @@ VexInvalRange unchainXDirect_PPC ( VexEndness endness_host, created by the Pin_ProfInc case for emit_PPCInstr. */ VexInvalRange patchProfInc_PPC ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter, + const ULong* location_of_counter, Bool mode64 ) { if (mode64) { diff --git a/VEX/priv/host_ppc_defs.h b/VEX/priv/host_ppc_defs.h index 7f3043f9f9..c32eea5a4c 100644 --- a/VEX/priv/host_ppc_defs.h +++ b/VEX/priv/host_ppc_defs.h @@ -1168,20 +1168,20 @@ extern Int evCheckSzB_PPC ( VexEndness endness_host ); /* Perform a chaining and unchaining of an XDirect jump. */ extern VexInvalRange chainXDirect_PPC ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to, + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to, Bool mode64 ); extern VexInvalRange unchainXDirect_PPC ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me, + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me, Bool mode64 ); /* Patch the counter location into an existing ProfInc point. */ extern VexInvalRange patchProfInc_PPC ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter, + const ULong* location_of_counter, Bool mode64 ); diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index a8e1eed8c9..bf178f83df 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -10099,7 +10099,7 @@ evCheckSzB_S390(VexEndness endness_host) generated by s390_insn_profinc_emit. */ VexInvalRange patchProfInc_S390(VexEndness endness_host, - void *code_to_patch, ULong *location_of_counter) + void *code_to_patch, const ULong *location_of_counter) { vassert(sizeof(ULong *) == 8); @@ -10119,8 +10119,8 @@ patchProfInc_S390(VexEndness endness_host, VexInvalRange chainXDirect_S390(VexEndness endness_host, void *place_to_chain, - void *disp_cp_chain_me_EXPECTED, - void *place_to_jump_to) + const void *disp_cp_chain_me_EXPECTED, + const void *place_to_jump_to) { vassert(endness_host == VexEndnessBE); @@ -10159,7 +10159,8 @@ chainXDirect_S390(VexEndness endness_host, /* This is the delta we need to put into a BRCL insn. Note, that the offset in BRCL is in half-words. Hence division by 2. */ - Long delta = (Long)((UChar *)place_to_jump_to - (UChar *)place_to_chain) / 2; + Long delta = + (Long)((const UChar *)place_to_jump_to - (const UChar *)place_to_chain) / 2; Bool shortOK = delta >= -1000*1000*1000 && delta < 1000*1000*1000; static UInt shortCTR = 0; /* DO NOT MAKE NON-STATIC */ @@ -10207,8 +10208,8 @@ chainXDirect_S390(VexEndness endness_host, VexInvalRange unchainXDirect_S390(VexEndness endness_host, void *place_to_unchain, - void *place_to_jump_to_EXPECTED, - void *disp_cp_chain_me) + const void *place_to_jump_to_EXPECTED, + const void *disp_cp_chain_me) { vassert(endness_host == VexEndnessBE); diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 7db43040dd..8706a6c706 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -750,18 +750,18 @@ Int evCheckSzB_S390(VexEndness endness_host); /* Perform a chaining and unchaining of an XDirect jump. */ VexInvalRange chainXDirect_S390(VexEndness endness_host, void *place_to_chain, - void *disp_cp_chain_me_EXPECTED, - void *place_to_jump_to); + const void *disp_cp_chain_me_EXPECTED, + const void *place_to_jump_to); VexInvalRange unchainXDirect_S390(VexEndness endness_host, void *place_to_unchain, - void *place_to_jump_to_EXPECTED, - void *disp_cp_chain_me); + const void *place_to_jump_to_EXPECTED, + const void *disp_cp_chain_me); /* Patch the counter location into an existing ProfInc point. */ VexInvalRange patchProfInc_S390(VexEndness endness_host, void *code_to_patch, - ULong *location_of_counter); + const ULong *location_of_counter); /* KLUDGE: See detailled comment in host_s390_defs.c. */ extern UInt s390_host_hwcaps; diff --git a/VEX/priv/host_x86_defs.c b/VEX/priv/host_x86_defs.c index 54bad38099..3a5546d12e 100644 --- a/VEX/priv/host_x86_defs.c +++ b/VEX/priv/host_x86_defs.c @@ -3346,8 +3346,8 @@ Int evCheckSzB_X86 ( VexEndness endness_host ) emitInstr case for XDirect, above. */ VexInvalRange chainXDirect_X86 ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ) + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ) { vassert(endness_host == VexEndnessLE); @@ -3373,7 +3373,7 @@ VexInvalRange chainXDirect_X86 ( VexEndness endness_host, */ /* This is the delta we need to put into a JMP d32 insn. It's relative to the start of the next insn, hence the -5. */ - Long delta = (Long)((UChar*)place_to_jump_to - (UChar*)p) - (Long)5; + Long delta = (Long)((const UChar *)place_to_jump_to - p) - 5; /* And make the modifications. */ p[0] = 0xE9; @@ -3394,8 +3394,8 @@ VexInvalRange chainXDirect_X86 ( VexEndness endness_host, emitInstr case for XDirect, above. */ VexInvalRange unchainXDirect_X86 ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ) + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ) { vassert(endness_host == VexEndnessLE); @@ -3412,7 +3412,7 @@ VexInvalRange unchainXDirect_X86 ( VexEndness endness_host, && p[5] == 0x0F && p[6] == 0x0B) { /* Check the offset is right. */ Int s32 = *(Int*)(&p[1]); - if ((UChar*)p + 5 + s32 == (UChar*)place_to_jump_to_EXPECTED) { + if ((UChar*)p + 5 + s32 == place_to_jump_to_EXPECTED) { valid = True; if (0) vex_printf("QQQ unchainXDirect_X86: found valid\n"); @@ -3440,7 +3440,7 @@ VexInvalRange unchainXDirect_X86 ( VexEndness endness_host, created by the Xin_ProfInc case for emit_X86Instr. */ VexInvalRange patchProfInc_X86 ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ) + const ULong* location_of_counter ) { vassert(endness_host == VexEndnessLE); vassert(sizeof(ULong*) == 4); diff --git a/VEX/priv/host_x86_defs.h b/VEX/priv/host_x86_defs.h index 49676c9777..a2c71076d1 100644 --- a/VEX/priv/host_x86_defs.h +++ b/VEX/priv/host_x86_defs.h @@ -751,18 +751,18 @@ extern Int evCheckSzB_X86 ( VexEndness endness_host ); /* Perform a chaining and unchaining of an XDirect jump. */ extern VexInvalRange chainXDirect_X86 ( VexEndness endness_host, void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ); + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ); extern VexInvalRange unchainXDirect_X86 ( VexEndness endness_host, void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ); + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ); /* Patch the counter location into an existing ProfInc point. */ extern VexInvalRange patchProfInc_X86 ( VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ); + const ULong* location_of_counter ); #endif /* ndef __VEX_HOST_X86_DEFS_H */ diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index d970ef9c2f..bd29019a6b 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -999,24 +999,38 @@ VexTranslateResult LibVEX_Translate ( VexTranslateArgs* vta ) /* --------- Chain/Unchain XDirects. --------- */ -VexInvalRange LibVEX_Chain ( VexArch arch_host, - VexEndness endness_host, - void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ) +VexInvalRange LibVEX_Chain ( VexArch arch_host, + VexEndness endness_host, + void* place_to_chain, + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ) { - VexInvalRange (*chainXDirect)(VexEndness, void*, void*, void*) = NULL; switch (arch_host) { case VexArchX86: - chainXDirect = chainXDirect_X86; break; + return chainXDirect_X86(endness_host, + place_to_chain, + disp_cp_chain_me_EXPECTED, + place_to_jump_to); case VexArchAMD64: - chainXDirect = chainXDirect_AMD64; break; + return chainXDirect_AMD64(endness_host, + place_to_chain, + disp_cp_chain_me_EXPECTED, + place_to_jump_to); case VexArchARM: - chainXDirect = chainXDirect_ARM; break; + return chainXDirect_ARM(endness_host, + place_to_chain, + disp_cp_chain_me_EXPECTED, + place_to_jump_to); case VexArchARM64: - chainXDirect = chainXDirect_ARM64; break; + return chainXDirect_ARM64(endness_host, + place_to_chain, + disp_cp_chain_me_EXPECTED, + place_to_jump_to); case VexArchS390X: - chainXDirect = chainXDirect_S390; break; + return chainXDirect_S390(endness_host, + place_to_chain, + disp_cp_chain_me_EXPECTED, + place_to_jump_to); case VexArchPPC32: return chainXDirect_PPC(endness_host, place_to_chain, @@ -1040,31 +1054,40 @@ VexInvalRange LibVEX_Chain ( VexArch arch_host, default: vassert(0); } - vassert(chainXDirect); - VexInvalRange vir - = chainXDirect(endness_host, place_to_chain, - disp_cp_chain_me_EXPECTED, place_to_jump_to); - return vir; } -VexInvalRange LibVEX_UnChain ( VexArch arch_host, - VexEndness endness_host, - void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ) +VexInvalRange LibVEX_UnChain ( VexArch arch_host, + VexEndness endness_host, + void* place_to_unchain, + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ) { - VexInvalRange (*unchainXDirect)(VexEndness, void*, void*, void*) = NULL; switch (arch_host) { case VexArchX86: - unchainXDirect = unchainXDirect_X86; break; + return unchainXDirect_X86(endness_host, + place_to_unchain, + place_to_jump_to_EXPECTED, + disp_cp_chain_me); case VexArchAMD64: - unchainXDirect = unchainXDirect_AMD64; break; + return unchainXDirect_AMD64(endness_host, + place_to_unchain, + place_to_jump_to_EXPECTED, + disp_cp_chain_me); case VexArchARM: - unchainXDirect = unchainXDirect_ARM; break; + return unchainXDirect_ARM(endness_host, + place_to_unchain, + place_to_jump_to_EXPECTED, + disp_cp_chain_me); case VexArchARM64: - unchainXDirect = unchainXDirect_ARM64; break; + return unchainXDirect_ARM64(endness_host, + place_to_unchain, + place_to_jump_to_EXPECTED, + disp_cp_chain_me); case VexArchS390X: - unchainXDirect = unchainXDirect_S390; break; + return unchainXDirect_S390(endness_host, + place_to_unchain, + place_to_jump_to_EXPECTED, + disp_cp_chain_me); case VexArchPPC32: return unchainXDirect_PPC(endness_host, place_to_unchain, @@ -1088,11 +1111,6 @@ VexInvalRange LibVEX_UnChain ( VexArch arch_host, default: vassert(0); } - vassert(unchainXDirect); - VexInvalRange vir - = unchainXDirect(endness_host, place_to_unchain, - place_to_jump_to_EXPECTED, disp_cp_chain_me); - return vir; } Int LibVEX_evCheckSzB ( VexArch arch_host, @@ -1127,20 +1145,24 @@ Int LibVEX_evCheckSzB ( VexArch arch_host, VexInvalRange LibVEX_PatchProfInc ( VexArch arch_host, VexEndness endness_host, void* place_to_patch, - ULong* location_of_counter ) + const ULong* location_of_counter ) { - VexInvalRange (*patchProfInc)(VexEndness,void*,ULong*) = NULL; switch (arch_host) { case VexArchX86: - patchProfInc = patchProfInc_X86; break; + return patchProfInc_X86(endness_host, place_to_patch, + location_of_counter); case VexArchAMD64: - patchProfInc = patchProfInc_AMD64; break; + return patchProfInc_AMD64(endness_host, place_to_patch, + location_of_counter); case VexArchARM: - patchProfInc = patchProfInc_ARM; break; + return patchProfInc_ARM(endness_host, place_to_patch, + location_of_counter); case VexArchARM64: - patchProfInc = patchProfInc_ARM64; break; + return patchProfInc_ARM64(endness_host, place_to_patch, + location_of_counter); case VexArchS390X: - patchProfInc = patchProfInc_S390; break; + return patchProfInc_S390(endness_host, place_to_patch, + location_of_counter); case VexArchPPC32: return patchProfInc_PPC(endness_host, place_to_patch, location_of_counter, False/*!mode64*/); @@ -1156,10 +1178,6 @@ VexInvalRange LibVEX_PatchProfInc ( VexArch arch_host, default: vassert(0); } - vassert(patchProfInc); - VexInvalRange vir - = patchProfInc(endness_host, place_to_patch, location_of_counter); - return vir; } diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 6805f81f08..5700ba6d5e 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -787,22 +787,22 @@ typedef currently contains a call to the dispatcher specified by disp_cp_chain_me_EXPECTED. */ extern -VexInvalRange LibVEX_Chain ( VexArch arch_host, - VexEndness endhess_host, - void* place_to_chain, - void* disp_cp_chain_me_EXPECTED, - void* place_to_jump_to ); +VexInvalRange LibVEX_Chain ( VexArch arch_host, + VexEndness endhess_host, + void* place_to_chain, + const void* disp_cp_chain_me_EXPECTED, + const void* place_to_jump_to ); /* Undo an XDirect jump located at place_to_unchain, so it is converted back into a call to disp_cp_chain_me. It is expected (and checked) that this site currently contains a jump directly to the address specified by place_to_jump_to_EXPECTED. */ extern -VexInvalRange LibVEX_UnChain ( VexArch arch_host, - VexEndness endness_host, - void* place_to_unchain, - void* place_to_jump_to_EXPECTED, - void* disp_cp_chain_me ); +VexInvalRange LibVEX_UnChain ( VexArch arch_host, + VexEndness endness_host, + void* place_to_unchain, + const void* place_to_jump_to_EXPECTED, + const void* disp_cp_chain_me ); /* Returns a constant -- the size of the event check that is put at the start of every translation. This makes it possible to @@ -816,10 +816,10 @@ Int LibVEX_evCheckSzB ( VexArch arch_host, /* Patch the counter location into an existing ProfInc point. The specified point is checked to make sure it is plausible. */ extern -VexInvalRange LibVEX_PatchProfInc ( VexArch arch_host, - VexEndness endness_host, - void* place_to_patch, - ULong* location_of_counter ); +VexInvalRange LibVEX_PatchProfInc ( VexArch arch_host, + VexEndness endness_host, + void* place_to_patch, + const ULong* location_of_counter ); /*-------------------------------------------------------*/