mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Propagation of data-types across signed comparisons
This commit is contained in:
parent
c524ecfbe8
commit
193ad764e5
3 changed files with 38 additions and 0 deletions
|
@ -25,6 +25,7 @@ src/decompile/datatests/noforloop_iterused.xml||GHIDRA||||END|
|
|||
src/decompile/datatests/offsetarray.xml||GHIDRA||||END|
|
||||
src/decompile/datatests/promotecompare.xml||GHIDRA||||END|
|
||||
src/decompile/datatests/readvolatile.xml||GHIDRA||||END|
|
||||
src/decompile/datatests/sbyte.xml||GHIDRA||||END|
|
||||
src/decompile/datatests/threedim.xml||GHIDRA||||END|
|
||||
src/decompile/datatests/twodim.xml||GHIDRA||||END|
|
||||
src/decompile/datatests/wayoffarray.xml||GHIDRA||||END|
|
||||
|
|
|
@ -4305,6 +4305,8 @@ bool ActionInferTypes::propagateGoodEdge(PcodeOp *op,int4 inslot,int4 outslot,Va
|
|||
case CPUI_MULTIEQUAL:
|
||||
if ((inslot!=-1)&&(outslot!=-1)) return false; // Must propagate input <-> output
|
||||
break;
|
||||
case CPUI_INT_SLESS:
|
||||
case CPUI_INT_SLESSEQUAL:
|
||||
case CPUI_INT_LESS:
|
||||
case CPUI_INT_LESSEQUAL:
|
||||
if ((inslot==-1)||(outslot==-1)) return false; // Must propagate input <-> input
|
||||
|
@ -4400,6 +4402,11 @@ bool ActionInferTypes::propagateTypeEdge(TypeFactory *typegrp,PcodeOp *op,int4 i
|
|||
else
|
||||
newtype = alttype;
|
||||
break;
|
||||
case CPUI_INT_SLESS:
|
||||
case CPUI_INT_SLESSEQUAL:
|
||||
if (alttype->getMetatype() != TYPE_INT) return false; // Only propagate signed things
|
||||
newtype = alttype;
|
||||
break;
|
||||
case CPUI_NEW:
|
||||
{
|
||||
Varnode *invn = op->getIn(0);
|
||||
|
|
30
Ghidra/Features/Decompiler/src/decompile/datatests/sbyte.xml
Normal file
30
Ghidra/Features/Decompiler/src/decompile/datatests/sbyte.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<decompilertest>
|
||||
<binaryimage arch="x86:LE:64:default:gcc">
|
||||
<!--
|
||||
Contrived example comparing a signed byte. The decompiler
|
||||
should not use the 'char' data-type.
|
||||
-->
|
||||
<bytechunk space="ram" offset="0x100000" readonly="true">
|
||||
0fb647043c0a0f94c13cf70f94c208d1
|
||||
75043c617e1a8b17488d3513000000bf
|
||||
0100000031c0e9dd0f0000
|
||||
</bytechunk>
|
||||
<bytechunk space="ram" offset="0x100030" readonly="true">
|
||||
f3c3
|
||||
</bytechunk>
|
||||
</binaryimage>
|
||||
<script>
|
||||
<com>map fun r0x101008 printf nocode</com>
|
||||
<com>map fun r0x100000 printStruct</com>
|
||||
<com>parse line struct mystruct { int4 val; int1 thebyte; };</com>
|
||||
<com>parse line extern void printStruct(mystruct *ptr);</com>
|
||||
<com>override flow r0x100026 callreturn</com>
|
||||
<com>decompile</com>
|
||||
<com>print C</com>
|
||||
<com>quit</com>
|
||||
</script>
|
||||
<stringmatch name="Signed byte #1" min="1" max="1">Var1 = ptr->thebyte</stringmatch>
|
||||
<stringmatch name="Signed byte #2" min="1" max="1">Var1 != 10</stringmatch>
|
||||
<stringmatch name="Signed byte #3" min="1" max="1">Var1 != -9</stringmatch>
|
||||
<stringmatch name="Signed byte #4" min="1" max="1">Var1 < 0x62</stringmatch>
|
||||
</decompilertest>
|
Loading…
Add table
Add a link
Reference in a new issue