[DynInst_API:] [dyninst/dyninst] 45ba20: Mimic PLT behavior when replacing a call to a PLT ...


Date: Sat, 04 May 2019 14:48:20 -0700
From: Benjamin Welton <noreply@xxxxxxxxxx>
Subject: [DynInst_API:] [dyninst/dyninst] 45ba20: Mimic PLT behavior when replacing a call to a PLT ...
  Branch: refs/heads/welton_diogenes
  Home:   https://github.com/dyninst/dyninst
  Commit: 45ba20d44d2d032bacec32750da69bbdfa4fb0bc
      https://github.com/dyninst/dyninst/commit/45ba20d44d2d032bacec32750da69bbdfa4fb0bc
  Author: Benjamin Welton <welton@xxxxxxxxxxx>
  Date:   2019-05-04 (Sat, 04 May 2019)

  Changed paths:
    M dyninstAPI/src/Relocation/CFG/RelocBlock.h
    M dyninstAPI/src/Relocation/CFG/RelocGraph.C
    M dyninstAPI/src/Relocation/Transformers/Modification.C
    M dyninstAPI/src/Relocation/Widgets/CFWidget-ppc.C
    M dyninstAPI/src/Relocation/Widgets/CFWidget.C
    M dyninstAPI/src/Relocation/Widgets/CFWidget.h
    M dyninstAPI/src/codegen-power.C
    M dyninstAPI/src/codegen-power.h

  Log Message:
  -----------
  Mimic PLT behavior when replacing a call to a PLT stub [PPC]

PLT functions on Power have an instruction that stores the current TOC (R2)
onto the stack at position 24 (i.e. std r2,24(r1)). A new stack frame is not
created by the PLT, R2 is stored in the callers frame.

Upon return, the function that called the PLT stub tries to restore its
TOC from the stack (i.e. "bl pltStub" followed by a "ld r2,24(r1)").
We need to ensure that R2 is on the callers stack for any PLT function
we replace.

What this patch does is for any call to a PLT stub that has been modified,
we insert "std r2,24(r1)" to simulate that a PLT was called (even if we are
calling a function direct). The new pattern written is the following:

if original call was PLT:
	write std r2,24(r1)
<Original CFWidget Call Generation for PPC>

We determine if the original call was a PLT by first saving the original target
of the call instruction in Modification.C, passing this address to the widget,
then checking if the original target address is listed in the image's pltstub list.

 expects to be able to restore R2 from stack position 24


[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] [dyninst/dyninst] 45ba20: Mimic PLT behavior when replacing a call to a PLT ..., Benjamin Welton <=