From d2b759dd8885d977ae911bf0677c352ff2dbe79c Mon Sep 17 00:00:00 2001
From: jdh8d <jdh8d@git.zephyr-software.com>
Date: Wed, 25 May 2016 20:17:55 +0000
Subject: [PATCH] tweak for sub insn

Former-commit-id: dcbc900992c640b36e183c15f6411697318a5a4c
---
 beaengine/beaengineSources/Includes/instr_set/opcodes_Grp1.c | 3 +++
 libIRDB/src/core/instruction.cpp                             | 2 +-
 tools/selective_cfi/scfi_instr.cpp                           | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_Grp1.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_Grp1.c
index a714f1501..b57080333 100644
--- a/beaengine/beaengineSources/Includes/instr_set/opcodes_Grp1.c
+++ b/beaengine/beaengineSources/Includes/instr_set/opcodes_Grp1.c
@@ -23,6 +23,7 @@ void __bea_callspec__ G1_EbIb(PDISASM pMyDisasm)
 {
     GV.REGOPCODE = ((*((UInt8*)(UIntPtr) (GV.EIP_+1))) >> 3) & 0x7;
     EbIb(pMyDisasm);
+    (*pMyDisasm).Argument1.AccessMode = READ|WRITE;
     if (GV.REGOPCODE == 0) {
         if ((*pMyDisasm).Prefix.LockPrefix == InvalidPrefix) {
             (*pMyDisasm).Prefix.LockPrefix = InUsePrefix;
@@ -125,6 +126,7 @@ void __bea_callspec__ G1_EvIv(PDISASM pMyDisasm)
 {
     GV.REGOPCODE = ((*((UInt8*)(UIntPtr) (GV.EIP_+1))) >> 3) & 0x7;
     EvIv(pMyDisasm);
+    (*pMyDisasm).Argument1.AccessMode = READ|WRITE;
     if (GV.REGOPCODE == 0) {
         if ((*pMyDisasm).Prefix.LockPrefix == InvalidPrefix) {
             (*pMyDisasm).Prefix.LockPrefix = InUsePrefix;
@@ -214,6 +216,7 @@ void __bea_callspec__ G1_EvIb(PDISASM pMyDisasm)
 {
     GV.REGOPCODE = ((*((UInt8*)(UIntPtr) (GV.EIP_+1))) >> 3) & 0x7;
     EvIb(pMyDisasm, 1);
+    (*pMyDisasm).Argument1.AccessMode = READ|WRITE;
     if (GV.REGOPCODE == 0) {
         if ((*pMyDisasm).Prefix.LockPrefix == InvalidPrefix) {
             (*pMyDisasm).Prefix.LockPrefix = InUsePrefix;
diff --git a/libIRDB/src/core/instruction.cpp b/libIRDB/src/core/instruction.cpp
index f774f083f..34d04667d 100644
--- a/libIRDB/src/core/instruction.cpp
+++ b/libIRDB/src/core/instruction.cpp
@@ -240,7 +240,7 @@ bool Instruction_t::IsFunctionExit() const
 
 bool Instruction_t::SetsStackPointer(ARGTYPE* arg)
 {
-	if(arg->AccessMode!=WRITE)
+	if((arg->AccessMode & WRITE ) == 0)
 		return false;
 	int access_type=arg->ArgType & 0xFFFF0000;
 
diff --git a/tools/selective_cfi/scfi_instr.cpp b/tools/selective_cfi/scfi_instr.cpp
index 5732a960c..9d4e47538 100644
--- a/tools/selective_cfi/scfi_instr.cpp
+++ b/tools/selective_cfi/scfi_instr.cpp
@@ -315,6 +315,7 @@ bool SCFI_Instrument::mark_targets()
 					position*=size;
 					position = - position;
 
+					// cfi_nonce=(pos=-1,nv=0x33,sz=1)
 					NonceValueType_t noncevalue=v[i].GetNonceValue();
 					type=string("cfi_nonce=(pos=") +  to_string(position) + ",nv="
 						+ to_string(noncevalue) + ",sz="+ to_string(size)+ ")";
@@ -326,6 +327,7 @@ bool SCFI_Instrument::mark_targets()
 			}
 			else
 			{
+				// cfi_nonce=f4.
 				type="cfi_nonce=";
 				type+=to_string(GetNonce(insn));
 
-- 
GitLab