Ejemplo n.º 1
0
        public void AppBld_BindOutParameter()
        {
            ab = new ApplicationBuilder(arch, frame, new CallSite(4, 0), new Identifier("foo", PrimitiveType.Word32, null), sig, false);
            var o = ab.Bind(regOut);

            Assert.AreEqual("edx", o.ToString());
        }
Ejemplo n.º 2
0
        public void AppBld_BindReturnValue()
        {
            ab = new ApplicationBuilder(arch, frame, new CallSite(4, 0), new Identifier("foo", PrimitiveType.Word32, null), sig, false);
            var r = ab.Bind(ret);

            Assert.AreEqual("eax", r.ToString());
        }
Ejemplo n.º 3
0
        public override void VisitCallInstruction(CallInstruction ci)
        {
            ProcedureSignature sig = GetProcedureSignature(ci.Callee);

            if (sig != null && sig.ParametersValid)
            {
                var procCallee = ((ProcedureConstant)ci.Callee).Procedure;
                var ab         = new ApplicationBuilder(
                    program.Architecture,
                    Procedure.Frame,
                    ci.CallSite,
                    new ProcedureConstant(program.Platform.PointerType, procCallee),
                    sig,
                    false);
                if (sig.ReturnValue != null)
                {
                    varLive.Def(ab.Bind(sig.ReturnValue));
                }
                foreach (Identifier arg in sig.Parameters)
                {
                    if (arg.Storage is OutArgumentStorage)
                    {
                        varLive.Def(ab.Bind(arg));
                    }
                }

                foreach (Identifier arg in sig.Parameters)
                {
                    if (!(arg.Storage is OutArgumentStorage))
                    {
                        varLive.Use(ab.Bind(arg));
                    }
                }
            }
            else
            {
                var pc = ci.Callee as ProcedureConstant;
                if (pc == null)
                {
                    return;
                }
                var procCallee = pc.Procedure as Procedure;
                if (procCallee == null)
                {
                    return;
                }

                if (state.PropagateThroughExitNodes)
                {
                    PropagateToCalleeExitBlocks(stmCur);
                }

                // Update trash information.

                ProcedureFlow pi   = mpprocData[procCallee];
                ProcedureFlow item = mpprocData[Procedure];

                // The registers that are still live before a call are those
                // that were live after the call and were bypassed by the called function
                // or used by the called function.

                var ids = new HashSet <RegisterStorage>(pi.TrashedRegisters);
                ids.ExceptWith(pi.ByPass);
                varLive.Identifiers.ExceptWith(ids);
                varLive.Identifiers.UnionWith(pi.MayUse);
                // varLive.BitSet = pi.MayUse | ((pi.ByPass    | ~pi.TrashedRegisters) & varLive.BitSet);
                varLive.Grf = pi.grfMayUse | ((pi.grfByPass | ~pi.grfTrashed) & varLive.Grf);
                // Any stack parameters are also considered live.
                MarkLiveStackParameters(ci);
            }
        }
Ejemplo n.º 4
0
        public void AppBld_BindOutParameter()
		{
            ab = new ApplicationBuilder(arch, frame, new CallSite(4, 0), new Identifier("foo", PrimitiveType.Word32, null), sig, false);
            var o = ab.Bind(regOut);
			Assert.AreEqual("edx", o.ToString());
		}
Ejemplo n.º 5
0
        public void AppBld_BindReturnValue()
		{
            ab  = new ApplicationBuilder(arch, frame, new CallSite(4, 0), new Identifier("foo", PrimitiveType.Word32, null), sig, false);
			var r = ab.Bind(ret);
			Assert.AreEqual("eax", r.ToString());
		}