findConstants.h File Reference

#include "x86InstructionSemantics.h"
#include "integerOps.h"
#include "flowEquations.h"
#include <cassert>
#include <cstdio>
#include <boost/lexical_cast.hpp>
#include "ReadWriteRegisterFragment.h"

Include dependency graph for findConstants.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LatticeElement< Len >
 A LatticeElement contains the value of a register or memory location. More...
struct  XVariable< Len >
struct  XVariablePtr< Len >
 A pointer to an XVariable. More...
struct  MemoryWrite
 Information about the contents of memory at a given address. More...
struct  MemoryWriteSet
 A set of values stored in memory. More...
struct  MemoryVariable
struct  NullaryConstraint< OutputLen >
struct  UnaryConstraint< InputLen, OutputLen >
struct  BinaryConstraint< InputLen1, InputLen2, OutputLen >
struct  TernaryConstraint< InputLen1, InputLen2, InputLen3, OutputLen >
struct  MergeConstraint< Len >
struct  MemoryMergeConstraint
struct  RegisterSet
struct  FindConstantsPolicy
struct  FindConstantsPolicy::Exception
struct  FindConstantsPolicy::NumberConstraint< Len >
class  CdeclFunctionPolicy
 Augment the findConstants policy to do some special things for some instructions. More...
class  FindConstantsABIPolicy
 Instruction semantics policy for API-compliant function calls. More...

Defines

#define UNARY_COMPUTATION(name, InLen, OutLen, Formula)
#define UNARY_COMPUTATION_SPECIAL(name, InLen1, OutLen, Formula)
#define BINARY_COMPUTATION(name, InLen1, InLen2, OutLen, Formula)
#define BINARY_COMPUTATION_SPECIAL(name, InLen1, InLen2, OutLen, Formula)
#define TERNARY_COMPUTATION(name, InLen1, InLen2, InLen3, OutLen, Formula)
#define TERNARY_COMPUTATION_SPECIAL(name, InLen1, InLen2, InLen3, OutLen, Formula)
#define ValueType   XVariablePtr
#define EIP_LOCATION   newIp

Functions

template<size_t Len>
std::ostream & operator<< (std::ostream &o, const LatticeElement< Len > &e)
 Shows values like this (all integers are hexadecimal, offsets are signed): 1.
template<size_t Len>
std::ostream & operator<< (std::ostream &o, XVariablePtr< Len > v)
bool mayAlias (const MemoryWrite &, const MemoryWrite &)
 Returns true if the contents of memory location a could possibly overlap with b.
bool mustAlias (const MemoryWrite &, const MemoryWrite &)
 Returns true if memory locations a and b are the same (note that "same" is more strict than "overlap").
std::ostream & operator<< (std::ostream &o, const RegisterSet &rs)

Variables

uint64_t xvarNameCounter
 Counter to generate unique names for XVariables (and thereby, LatticeElements).
SgAsmx86InstructioncurrentInstruction
 Instruction on which we are currently working.
XVariablePtr< To > unsignedExtend (XVariablePtr< From >)
XVariablePtr< To-From > extract (XVariablePtr< Len >)


Define Documentation

#define UNARY_COMPUTATION ( name,
InLen,
OutLen,
Formula   ) 

Value:

XVariablePtr<(OutLen)> name(XVariablePtr<(InLen)> a) {                                                                     \
        XVariablePtr<(OutLen)> result = new XVariable<(OutLen)>();                                                             \
        struct IC: public UnaryConstraint<(InLen), (OutLen)> {                                                                 \
            IC(XVariablePtr<(OutLen)> result, XVariablePtr<(InLen)> var1)                                                      \
                : UnaryConstraint<(InLen), (OutLen)>(result, var1)                                                             \
                {}                                                                                                             \
            virtual uint64_t compute(uint64_t a) const {                                                                       \
                Formula                                                                                                        \
            }                                                                                                                  \
        };                                                                                                                     \
        (new IC(result, a))->activate();                                                                                       \
        return result;                                                                                                         \
    }

#define UNARY_COMPUTATION_SPECIAL ( name,
InLen1,
OutLen,
Formula   ) 

Value:

XVariablePtr<(OutLen)> name(XVariablePtr<(InLen1)> a) {                                                                    \
        XVariablePtr<(OutLen)> result = new XVariable<(OutLen)>();                                                             \
        struct IC: public UnaryConstraint<(InLen1), (OutLen)> {                                                                \
            IC(XVariablePtr<(OutLen)> result, XVariablePtr<(InLen1)> var1)                                                     \
                : UnaryConstraint<(InLen1), (OutLen)>(result, var1)                                                            \
                {}                                                                                                             \
            virtual void run() const {                                                                                         \
                LatticeElement<(InLen1)> le1 = UnaryConstraint<(InLen1), (OutLen)>::var->get();                                \
                XVariablePtr<(OutLen)> result = UnaryConstraint<(InLen1), (OutLen)>::result;                                   \
                if (le1.isTop) {result->set(LatticeElement<(OutLen)>()); return;}                                              \
                Formula                                                                                                        \
            }                                                                                                                  \
            virtual uint64_t compute(uint64_t) const {abort();}                                                                \
        };                                                                                                                     \
        (new IC(result, a))->activate();                                                                                       \
        return result;                                                                                                         \
    }

#define BINARY_COMPUTATION ( name,
InLen1,
InLen2,
OutLen,
Formula   ) 

Value:

XVariablePtr<(OutLen)> name(XVariablePtr<(InLen1)> a, XVariablePtr<(InLen2)> b) {                                          \
        XVariablePtr<(OutLen)> result = new XVariable<(OutLen)>();                                                             \
        struct IC: public BinaryConstraint<(InLen1), (InLen2), (OutLen)> {                                                     \
            IC(XVariablePtr<(OutLen)> result, XVariablePtr<(InLen1)> var1, XVariablePtr<(InLen2)> var2)                        \
                : BinaryConstraint<(InLen1), (InLen2), (OutLen)>(result, var1, var2)                                           \
                {}                                                                                                             \
            virtual uint64_t compute(uint64_t a, uint64_t b) const {                                                           \
                Formula                                                                                                        \
            }                                                                                                                  \
        };                                                                                                                     \
        (new IC(result, a, b))->activate();                                                                                    \
        return result;                                                                                                         \
    }

#define BINARY_COMPUTATION_SPECIAL ( name,
InLen1,
InLen2,
OutLen,
Formula   ) 

Value:

XVariablePtr<(OutLen)> name(XVariablePtr<(InLen1)> a, XVariablePtr<(InLen2)> b) {                                          \
        XVariablePtr<(OutLen)> result = new XVariable<(OutLen)>();                                                             \
        struct IC: public BinaryConstraint<(InLen1), (InLen2), (OutLen)> {                                                     \
            IC(XVariablePtr<(OutLen)> result, XVariablePtr<(InLen1)> var1, XVariablePtr<(InLen2)> var2)                        \
                : BinaryConstraint<(InLen1), (InLen2), (OutLen)>(result, var1, var2)                                           \
                {}                                                                                                             \
            virtual void run() const {                                                                                         \
                LatticeElement<(InLen1)> le1 = BinaryConstraint<(InLen1), (InLen2), (OutLen)>::var1->get();                    \
                LatticeElement<(InLen2)> le2 = BinaryConstraint<(InLen1), (InLen2), (OutLen)>::var2->get();                    \
                XVariablePtr<(OutLen)> result = BinaryConstraint<(InLen1), (InLen2), (OutLen)>::result;                        \
                if (le1.isTop || le2.isTop) {                                                                                  \
                    result->set(LatticeElement<(OutLen)>());                                                                   \
                    return;                                                                                                    \
                }                                                                                                              \
                Formula                                                                                                        \
            }                                                                                                                  \
            virtual uint64_t compute(uint64_t, uint64_t) const {                                                               \
                abort();                                                                                                       \
            }                                                                                                                  \
        };                                                                                                                     \
        (new IC(result, a, b))->activate();                                                                                    \
        return result;                                                                                                         \
    }

#define TERNARY_COMPUTATION ( name,
InLen1,
InLen2,
InLen3,
OutLen,
Formula   ) 

Value:

XVariablePtr<(OutLen)> name(XVariablePtr<(InLen1)> a, XVariablePtr<(InLen2)> b, XVariablePtr<(InLen3)> c) {                \
        XVariable<(OutLen)>* result = new XVariable<(OutLen)>();                                                               \
        struct IC: public TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)> {                                          \
            IC(XVariablePtr<(OutLen)> result,                                                                                  \
               XVariablePtr<(InLen1)> var1, XVariablePtr<(InLen2)> var2, XVariablePtr<(InLen3)> var3)                          \
                : TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)>(result, var1, var2, var3)                          \
                {}                                                                                                             \
            virtual uint64_t compute(uint64_t a, uint64_t b, uint64_t c) const {                                               \
                Formula                                                                                                        \
            }                                                                                                                  \
        };                                                                                                                     \
        (new IC(result, a, b, c))->activate();                                                                                 \
        return result;                                                                                                         \
    }

#define TERNARY_COMPUTATION_SPECIAL ( name,
InLen1,
InLen2,
InLen3,
OutLen,
Formula   ) 

Value:

XVariablePtr<(OutLen)> name(XVariablePtr<(InLen1)> a, XVariablePtr<(InLen2)> b, XVariablePtr<(InLen3)> c) {                \
        XVariablePtr<(OutLen)> result = new XVariable<(OutLen)>();                                                             \
        struct IC: public TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)> {                                          \
            IC(XVariablePtr<(OutLen)> result,                                                                                  \
               XVariablePtr<(InLen1)> var1, XVariablePtr<(InLen2)> var2, XVariablePtr<(InLen3)> var3)                          \
                : TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)>(result, var1, var2, var3)                          \
                {}                                                                                                             \
            virtual void run() const {                                                                                         \
                LatticeElement<(InLen1)> le1 = TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)>::var1->get();         \
                LatticeElement<(InLen2)> le2 = TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)>::var2->get();         \
                LatticeElement<(InLen3)> le3 = TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)>::var3->get();         \
                XVariablePtr<(OutLen)> result = TernaryConstraint<(InLen1), (InLen2), (InLen3), (OutLen)>::result;             \
                if (le1.isTop || le2.isTop || le3.isTop) {                                                                     \
                    result->set(LatticeElement<(OutLen)>());                                                                   \
                    return;                                                                                                    \
                }                                                                                                              \
                Formula                                                                                                        \
            }                                                                                                                  \
            virtual uint64_t compute(uint64_t, uint64_t, uint64_t) const {                                                     \
                abort();                                                                                                       \
            }                                                                                                                  \
        };                                                                                                                     \
        (new IC(result, a, b, c))->activate();                                                                                 \
        return result;                                                                                                         \
    }

#define ValueType   XVariablePtr

#define EIP_LOCATION   newIp


Function Documentation

template<size_t Len>
std::ostream& operator<< ( std::ostream &  o,
const LatticeElement< Len > &  e 
)

Shows values like this (all integers are hexadecimal, offsets are signed): 1.

Unknown value: v5b9 2. Known offset from unknown value: v5b9+45 3. Constant: 0xfffffffc (-0x4) 4. Top elements: <top>

template<size_t Len>
std::ostream& operator<< ( std::ostream &  o,
XVariablePtr< Len >  v 
)

bool mayAlias ( const MemoryWrite a,
const MemoryWrite b 
)

Returns true if the contents of memory location a could possibly overlap with b.

In other words, returns false only if memory location a cannot overlap with memory location b.

bool mustAlias ( const MemoryWrite ,
const MemoryWrite  
)

Returns true if memory locations a and b are the same (note that "same" is more strict than "overlap").

std::ostream& operator<< ( std::ostream &  o,
const RegisterSet rs 
)


Variable Documentation

uint64_t xvarNameCounter

Counter to generate unique names for XVariables (and thereby, LatticeElements).

SgAsmx86Instruction* currentInstruction

Instruction on which we are currently working.

Set by FindConstantsPolicy::startInstruction, cleared by FindConstantsPolicy::finishInstruction, and accessed by the XVariable constructor.

XVariablePtr<To> unsignedExtend(XVariablePtr< From >)

XVariablePtr<To - From> extract(XVariablePtr< Len >)


Generated on Tue Jan 31 05:32:14 2012 for ROSE by  doxygen 1.4.7