mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-3873 Data-type alignment support in decompiler
This commit is contained in:
parent
6508088623
commit
64a58bdeab
29 changed files with 456 additions and 149 deletions
|
@ -5669,9 +5669,9 @@ bool AddTreeState::initAlternateForm(void)
|
|||
if (baseType->isVariableLength())
|
||||
size = 0; // Open-ended size being pointed to, there will be no "multiples" component
|
||||
else
|
||||
size = AddrSpace::byteToAddressInt(baseType->getSize(),ct->getWordSize());
|
||||
size = AddrSpace::byteToAddressInt(baseType->getAlignSize(),ct->getWordSize());
|
||||
int4 unitsize = AddrSpace::addressToByteInt(1,ct->getWordSize());
|
||||
isDegenerate = (baseType->getSize() <= unitsize && baseType->getSize() > 0);
|
||||
isDegenerate = (baseType->getAlignSize() <= unitsize && baseType->getAlignSize() > 0);
|
||||
preventDistribution = false;
|
||||
clear();
|
||||
return true;
|
||||
|
@ -5699,7 +5699,7 @@ AddTreeState::AddTreeState(Funcdata &d,PcodeOp *op,int4 slot)
|
|||
if (baseType->isVariableLength())
|
||||
size = 0; // Open-ended size being pointed to, there will be no "multiples" component
|
||||
else
|
||||
size = AddrSpace::byteToAddressInt(baseType->getSize(),ct->getWordSize());
|
||||
size = AddrSpace::byteToAddressInt(baseType->getAlignSize(),ct->getWordSize());
|
||||
correct = 0;
|
||||
offset = 0;
|
||||
valid = true; // Valid until proven otherwise
|
||||
|
@ -5708,7 +5708,7 @@ AddTreeState::AddTreeState(Funcdata &d,PcodeOp *op,int4 slot)
|
|||
isSubtype = false;
|
||||
distributeOp = (PcodeOp *)0;
|
||||
int4 unitsize = AddrSpace::addressToByteInt(1,ct->getWordSize());
|
||||
isDegenerate = (baseType->getSize() <= unitsize && baseType->getSize() > 0);
|
||||
isDegenerate = (baseType->getAlignSize() <= unitsize && baseType->getAlignSize() > 0);
|
||||
}
|
||||
|
||||
/// Even if the current base data-type is not an array, the pointer expression may incorporate
|
||||
|
@ -6089,7 +6089,7 @@ Varnode *AddTreeState::buildExtra(void)
|
|||
bool AddTreeState::buildDegenerate(void)
|
||||
|
||||
{
|
||||
if (baseType->getSize() < ct->getWordSize())
|
||||
if (baseType->getAlignSize() < ct->getWordSize())
|
||||
// If the size is really less than scale, there is
|
||||
// probably some sort of padding going on
|
||||
return false; // Don't transform at all
|
||||
|
@ -6563,7 +6563,7 @@ int4 RulePtraddUndo::applyOp(PcodeOp *op,Funcdata &data)
|
|||
basevn = op->getIn(0);
|
||||
tp = (TypePointer *)basevn->getTypeReadFacing(op);
|
||||
if (tp->getMetatype() == TYPE_PTR) // Make sure we are still a pointer
|
||||
if (tp->getPtrTo()->getSize()==AddrSpace::addressToByteInt(size,tp->getWordSize())) { // of the correct size
|
||||
if (tp->getPtrTo()->getAlignSize()==AddrSpace::addressToByteInt(size,tp->getWordSize())) { // of the correct size
|
||||
Varnode *indVn = op->getIn(1);
|
||||
if ((!indVn->isConstant()) || (indVn->getOffset() != 0)) // and that index isn't zero
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue