Date: | Mon, 27 Apr 2015 11:10:36 -0500 |
---|---|
From: | Emily Gember-Jacobson <jacobson@xxxxxxxxxxx> |
Subject: | [DynInst_API:] Proposed Interface for Stack Modifications |
Hi all,
I've been doing some work with modifying the stack frame layout of functions, and we're now planning on integrating this into Dyninst. ÂCurrently, this is primarily intended for use in binary rewriting; there are some potentially unresolved issues with dynamic instrumentation. After some internal discussion, I'm sending this out for wider feedback. I'm including a proposed interface, with an overview of how we expect these features to work. Feedback is welcome. A new abstract class: StackMod. A StackMod defines the modification that will be performed. We propose 5 child classes for StackMod (I've included constructors): Insert(low, high); This modification inserts stack space in the range [low, high), where low and high are stack offsets. Remove(low, high); This modification removes stack space in the range [low, high). Move(sLow, sHigh, dLow); ThisÂmodificationÂmoves stack space [sLow, sHigh) to [dlow, dLow+(sHigh-sLow)). Canary(); ThisÂmodificationÂinserts a stack canary at function entry and corresponding canary check atÂfunction exit (uses the same canary/canary check as gcc's -fstack-protector). Randomize(); ThisÂmodificationÂdiversifies the stack frame by randomizing the locations of DWARF-identified localÂvariables. We define stack modifications to have function scope. Each stack modification defines both a change to the stack frame layout as well as a series of code changes required to perform such a change. Internally, we use stack analysis to determine any locations in the function where new code must be added to support a given modification. For example, to insert stack space, we emit code to shift the stack pointer by the specified amount. Some stack modifications require a second, paired modification (e.g., inserting stack space requires a corresponding remove before function exit); defining stack modifications at function scope allows use to easily add the corresponding cleanup. Further, a sensitivity analysis has been added to determine which instructions access relocated stack memory or stack memory shifted due to modifications; these instructions are updated during relocation to access the new stack locations. StackMods are installed with a new member function for BPatch_function: bool addMods(std::set<StackMod*>); This function performs error checking, generates padding when required for stack alignment, handles modifications the require cleanup, and generates the appropriate ASTs. If you're interested, a slightly longer explanation of the abstractions and analyses we use:
Emily |
[← Prev in Thread] | Current Thread | [Next in Thread→] |
---|---|---|
|
Previous by Date: | [DynInst_API:] Tools Workshop, Barton Miller |
---|---|
Next by Date: | [DynInst_API:] COMMIT: dyninst, testsuite more properly component-aware, Bill Williams |
Previous by Thread: | Re: [DynInst_API:] Profiling OS/kernel code using DynInst, Josh Stone |
Next by Thread: | [DynInst_API:] release 9.1 updates, Bill Williams |
Indexes: | [Date] [Thread] |