From 603cf5523f52779c8d9b01799b5015cd1fdd573a Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:13:52 -0400 Subject: [PATCH] GP-3518 Additional double precision checks --- .../Decompiler/src/decompile/cpp/double.cc | 18 ++++++++++++++---- .../src/decompile/datatests/partialunion.xml | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc index 8eb11963ef..49dd39f4ea 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc @@ -787,10 +787,14 @@ bool SplitVarnode::isAddrTiedContiguous(Varnode *lo,Varnode *hi,Address &res) if (!hi->isAddrTied()) return false; // Make sure there is no explicit symbol that would prevent the pieces from being joined - SymbolEntry *entry = lo->getSymbolEntry(); - if ((entry != (SymbolEntry *)0)&&(entry->getOffset()==0)) return false; - entry = hi->getSymbolEntry(); - if ((entry != (SymbolEntry *)0)&&(entry->getOffset()==0)) return false; + SymbolEntry *entryLo = lo->getSymbolEntry(); + SymbolEntry *entryHi = hi->getSymbolEntry(); + if (entryLo != (SymbolEntry *)0 || entryHi != (SymbolEntry *)0) { + if (entryLo == (SymbolEntry *)0 || entryHi == (SymbolEntry *)0) + return false; // One is marked with a symbol, the other is not + if (entryLo->getSymbol() != entryHi->getSymbol()) + return false; // They are part of different symbols + } AddrSpace *spc = lo->getSpace(); if (spc != hi->getSpace()) return false; uintb looffset = lo->getOffset(); @@ -3093,6 +3097,12 @@ bool IndirectForm::verify(Varnode *h,Varnode *l,PcodeOp *ind) if (affector != PcodeOp::getOpFromConst(indlo->getIn(1)->getAddr())) continue; // hi and lo must be affected by same op reslo = indlo->getOut(); if (reslo->getSpace()->getType() == IPTR_INTERNAL) return false; // Indirect must not be through a temporary + if (reslo->isAddrTied() || reshi->isAddrTied()) { + Address addr; + // If one piece is address tied, the other must be as well, and they must fit together as contiguous whole + if (!SplitVarnode::isAddrTiedContiguous(reslo, reshi, addr)) + return false; + } return true; } return false; diff --git a/Ghidra/Features/Decompiler/src/decompile/datatests/partialunion.xml b/Ghidra/Features/Decompiler/src/decompile/datatests/partialunion.xml index 489cba0888..55c9e55e7f 100644 --- a/Ghidra/Features/Decompiler/src/decompile/datatests/partialunion.xml +++ b/Ghidra/Features/Decompiler/src/decompile/datatests/partialunion.xml @@ -33,7 +33,7 @@ dec print C lo fu partial1 - map unionfacet structunion 1 r0x1006ee 20603f6a8a0b89 + map unionfacet structunion 1 r0x1006ee 10603f2c20ffa6 dec print C quit