mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Adjusting some guard analysis
This commit is contained in:
parent
ed786460ca
commit
163fa4af57
4 changed files with 15 additions and 4 deletions
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
vector<ArchitectureCapability *> ArchitectureCapability::thelist;
|
vector<ArchitectureCapability *> ArchitectureCapability::thelist;
|
||||||
|
|
||||||
const uint4 ArchitectureCapability::majorversion = 3;
|
const uint4 ArchitectureCapability::majorversion = 4;
|
||||||
const uint4 ArchitectureCapability::minorversion = 5;
|
const uint4 ArchitectureCapability::minorversion = 0;
|
||||||
|
|
||||||
/// This builds a list of just the ArchitectureCapability extensions
|
/// This builds a list of just the ArchitectureCapability extensions
|
||||||
void ArchitectureCapability::initialize(void)
|
void ArchitectureCapability::initialize(void)
|
||||||
|
|
|
@ -1033,6 +1033,15 @@ void JumpBasic::analyzeGuards(BlockBasic *bl,int4 pathout)
|
||||||
PcodeOp *cbranch = prevbl->lastOp();
|
PcodeOp *cbranch = prevbl->lastOp();
|
||||||
if ((cbranch==(PcodeOp *)0)||(cbranch->code() != CPUI_CBRANCH))
|
if ((cbranch==(PcodeOp *)0)||(cbranch->code() != CPUI_CBRANCH))
|
||||||
break;
|
break;
|
||||||
|
if (i != 0) {
|
||||||
|
// Check that this CBRANCH isn't protecting some other switch
|
||||||
|
BlockBasic *otherbl = (BlockBasic *)prevbl->getOut(1-indpath);
|
||||||
|
PcodeOp *otherop = otherbl->lastOp();
|
||||||
|
if (otherop != (PcodeOp *)0 && otherop->code() == CPUI_BRANCHIND) {
|
||||||
|
if (otherop != jumptable->getIndirectOp())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool toswitchval = (indpath == 1);
|
bool toswitchval = (indpath == 1);
|
||||||
if (cbranch->isBooleanFlip())
|
if (cbranch->isBooleanFlip())
|
||||||
toswitchval = !toswitchval;
|
toswitchval = !toswitchval;
|
||||||
|
|
|
@ -1066,8 +1066,9 @@ Varnode *CircleRange::pullBack(PcodeOp *op,Varnode **constMarkup,bool usenzmask)
|
||||||
CircleRange nzrange;
|
CircleRange nzrange;
|
||||||
if (!nzrange.setNZMask(res->getNZMask(),res->getSize()))
|
if (!nzrange.setNZMask(res->getNZMask(),res->getSize()))
|
||||||
return res;
|
return res;
|
||||||
if (0!=intersect(nzrange))
|
intersect(nzrange);
|
||||||
return (Varnode *)0;
|
// If the intersect does not succeed (i.e. produces 2 pieces) the original range is
|
||||||
|
// preserved and we still consider this pullback successful.
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2487,6 +2487,7 @@ int4 RuleZextEliminate::applyOp(PcodeOp *op,Funcdata &data)
|
||||||
if (!vn2->isConstant()) return 0;
|
if (!vn2->isConstant()) return 0;
|
||||||
zext = vn1->getDef();
|
zext = vn1->getDef();
|
||||||
if (!zext->getIn(0)->isHeritageKnown()) return 0;
|
if (!zext->getIn(0)->isHeritageKnown()) return 0;
|
||||||
|
if (vn1->loneDescend() != op) return 0; // Make sure extension is not used for anything else
|
||||||
smallsize = zext->getIn(0)->getSize();
|
smallsize = zext->getIn(0)->getSize();
|
||||||
val = vn2->getOffset();
|
val = vn2->getOffset();
|
||||||
if ((val>>(8*smallsize))==0) { // Is zero extension unnecessary
|
if ((val>>(8*smallsize))==0) { // Is zero extension unnecessary
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue