From 711eabc05867440ca2d743f0eb2ab37588a3d9c5 Mon Sep 17 00:00:00 2001 From: Tristan Ravitch Date: Wed, 4 Oct 2017 15:53:03 -0700 Subject: [PATCH] Implement postCallAbsState and absEvalArchStmt absEvalArchStmt is trivial (for now) --- macaw-ppc/src/Data/Macaw/PPC/Eval.hs | 12 ++++++++++-- macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/macaw-ppc/src/Data/Macaw/PPC/Eval.hs b/macaw-ppc/src/Data/Macaw/PPC/Eval.hs index 1a300677..8aef497c 100644 --- a/macaw-ppc/src/Data/Macaw/PPC/Eval.hs +++ b/macaw-ppc/src/Data/Macaw/PPC/Eval.hs @@ -59,8 +59,16 @@ absEvalArchStmt :: proxy ppc -> AbsProcessorState (ArchReg ppc) ids absEvalArchStmt _ s _ = s -postCallAbsState :: proxy ppc +-- | There should be no difference in stack height before and after a call, as +-- the callee pushes the return address if required. Return values are also +-- passed in registers. +postCallAbsState :: (PPCWidth ppc) + => proxy ppc -> AbsBlockState (ArchReg ppc) -> ArchSegmentOff ppc -> AbsBlockState (ArchReg ppc) -postCallAbsState = undefined +postCallAbsState proxy = MA.absEvalCall params + where + params = MA.CallParams { MA.postCallStackDelta = 0 + , MA.preserveReg = \r -> S.member (Some r) (linuxCalleeSaveRegisters proxy) + } diff --git a/macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs b/macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs index ba28be47..a5d750c3 100644 --- a/macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs +++ b/macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs @@ -13,6 +13,7 @@ module Data.Macaw.PPC.PPCReg ( PPCReg(..), linuxSystemCallPreservedRegisters, + linuxCalleeSaveRegisters, PPCWidth, ArchWidth(..) ) where @@ -77,6 +78,12 @@ linuxSystemCallPreservedRegisters :: (w ~ MC.RegAddrWidth (PPCReg ppc), 1 <= w) linuxSystemCallPreservedRegisters _ = S.fromList [ Some (PPC_GP (D.GPR rnum)) | rnum <- [14..31] ] +linuxCalleeSaveRegisters :: (w ~ MC.RegAddrWidth (PPCReg ppc), 1 <= w) + => proxy ppc + -> S.Set (Some (PPCReg ppc)) +linuxCalleeSaveRegisters _ = + S.fromList [ Some (PPC_GP (D.GPR rnum)) | rnum <- [14..31] ] + type instance MC.RegAddrWidth (PPCReg PPC32.PPC) = 32 type instance MC.RegAddrWidth (PPCReg PPC64.PPC) = 64