mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
minor change to transformPtr
This commit is contained in:
parent
39d3a5f810
commit
11a86ca06e
1 changed files with 11 additions and 10 deletions
|
@ -5416,7 +5416,7 @@ int4 RulePtrArith::transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Fun
|
|||
const TypePointer *ct;
|
||||
bool yes_subtype,offset_corrected;
|
||||
int4 i,ptrsize;
|
||||
uintb correct,coeff,offset,nonmultbytes,extra;
|
||||
uintb ptrmask,correct,coeff,offset,nonmultbytes,extra;
|
||||
Varnode *ptrbump; // Will contain final result of PTR addition
|
||||
Varnode *fullother; // Will contain anything else not part of PTR add
|
||||
Varnode *newvn;
|
||||
|
@ -5432,19 +5432,20 @@ int4 RulePtrArith::transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Fun
|
|||
|
||||
spanAddTree(bottom_op,&state); // Find multiples and non-multiples of ct->getSize()
|
||||
if (!state.valid) return 0; // Were there any show stoppers
|
||||
state.nonmultsum &= calc_mask(ptrsize); // Make sure we are modulo ptr's space
|
||||
state.multsum &= calc_mask(ptrsize);
|
||||
ptrmask = calc_mask(ptrsize);
|
||||
state.nonmultsum &= ptrmask; // Make sure we are modulo ptr's space
|
||||
state.multsum &= ptrmask;
|
||||
if (state.size == 0)
|
||||
offset = state.nonmultsum;
|
||||
else {
|
||||
intb snonmult = (intb)state.nonmultsum;
|
||||
sign_extend(snonmult,state.ptr->getSize()*8-1);
|
||||
sign_extend(snonmult,ptrsize*8-1);
|
||||
snonmult = snonmult % state.size;
|
||||
offset = (snonmult < 0) ? (uintb)(snonmult + state.size) : (uintb)snonmult;
|
||||
}
|
||||
correct = state.nonmultsum - offset;
|
||||
state.nonmultsum = offset;
|
||||
state.multsum = (state.multsum + correct)&calc_mask(ptrsize); // Some extra multiples of size
|
||||
state.multsum = (state.multsum + correct) & ptrmask; // Some extra multiples of size
|
||||
|
||||
// Figure out if there is any subtype
|
||||
if (state.nonmult.empty()) {
|
||||
|
@ -5459,7 +5460,7 @@ int4 RulePtrArith::transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Fun
|
|||
if (ct->getPtrTo()->getSubType(nonmultbytes,&extra)==(Datatype *)0)
|
||||
return 0; // Cannot find mapped variable but nonmult is non-empty
|
||||
extra = AddrSpace::byteToAddress(extra,ct->getWordSize()); // Convert back to address units
|
||||
offset = (state.nonmultsum - extra)&calc_mask(ptrsize);
|
||||
offset = (state.nonmultsum - extra) & ptrmask;
|
||||
yes_subtype = true;
|
||||
}
|
||||
else if (ct->getPtrTo()->getMetatype()==TYPE_STRUCT) {
|
||||
|
@ -5470,7 +5471,7 @@ int4 RulePtrArith::transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Fun
|
|||
extra = 0; // No field, but pretend there is something there
|
||||
}
|
||||
extra = AddrSpace::byteToAddress(extra,ct->getWordSize()); // Convert back to address units
|
||||
offset = (state.nonmultsum - extra)&calc_mask(ptrsize);
|
||||
offset = (state.nonmultsum - extra) & ptrmask;
|
||||
yes_subtype = true;
|
||||
}
|
||||
else if (ct->getPtrTo()->getMetatype()==TYPE_ARRAY) {
|
||||
|
@ -5483,8 +5484,8 @@ int4 RulePtrArith::transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Fun
|
|||
// Be sure to preserve sign in division below
|
||||
// Calc size-relative constant PTR addition
|
||||
intb smultsum = (intb)state.multsum;
|
||||
sign_extend(smultsum,state.ptr->getSize()*8-1);
|
||||
coeff = (state.size==0) ? (uintb)0 : (smultsum / state.size)&calc_mask(ptrsize);
|
||||
sign_extend(smultsum,ptrsize*8-1);
|
||||
coeff = (state.size==0) ? (uintb)0 : (smultsum / state.size) & ptrmask;
|
||||
if (coeff == 0)
|
||||
ptrbump = (Varnode *)0;
|
||||
else
|
||||
|
@ -5512,7 +5513,7 @@ int4 RulePtrArith::transformPtr(PcodeOp *bottom_op,PcodeOp *ptr_op,int4 slot,Fun
|
|||
else
|
||||
ptrbump = state.ptr;
|
||||
// Add up any remaining pieces
|
||||
correct = (correct+offset)&calc_mask(ptrsize); // Total correction that needs to be made
|
||||
correct = (correct+offset) & ptrmask; // Total correction that needs to be made
|
||||
offset_corrected= (correct==0);
|
||||
fullother = (Varnode *)0;
|
||||
for(i=0;i<state.nonmult.size();++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue