Exemplo n.º 1
0
        public bool VisitReturn(RtlReturn ret)
        {
            if ((ret.Class & RtlClass.Delay) != 0)
            {
                // Get next instruction cluster from the delay slot.
                rtlStream.MoveNext();
                ProcessRtlCluster(rtlStream.Current);
            }
            var proc = blockCur.Procedure;

            Emit(new ReturnInstruction());
            proc.ControlGraph.AddEdge(blockCur, proc.ExitBlock);

            int returnAddressBytes = ret.ReturnAddressBytes;
            var address            = ric.Address;

            scanner.SetProcedureReturnAddressBytes(proc, returnAddressBytes, address);

            int stackDelta = ret.ReturnAddressBytes + ret.ExtraBytesPopped;

            if (proc.Signature.StackDelta != 0 && proc.Signature.StackDelta != stackDelta)
            {
                scanner.Warn(
                    ric.Address,
                    "Multiple different values of stack delta in procedure {0} when processing RET instruction; was {1} previously.",
                    proc.Name,
                    proc.Signature.StackDelta);
            }
            else
            {
                proc.Signature.StackDelta = stackDelta;
            }
            state.OnProcedureLeft(proc.Signature);
            scanner.TerminateBlock(blockCur, rtlStream.Current.Address + ric.Length);
            return(false);
        }