Skip to content

Commit

Permalink
Add dyninstAPI/src/Relocation/CodeMover.C
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent afb35fb commit 031368f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
15 changes: 15 additions & 0 deletions docs/dyninstAPI/developer/Relocation/CodeMover.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ CodeMover.h
Returns true for success or false for catastrophic failure. The codeGen parameter allows specification of
various codeGen-carried information

We wish to minimize the space required by the relocated code. Since some platforms
may have varying space requirements for certain instructions (e.g., branches) this
requires a fixpoint calculation. We start with the original size and increase from
there.

Reasons for size increase:

1) Instrumentation. It tends to use room. Odd.
2) Transformed instructions. We may need to replace a single instruction with a
sequence to emulate its original behavior
3) Variable-sized instructions. If we increase branch displacements we may need
to increase the corresponding branch instruction sizes.

.. cpp:function:: bool finalize()
.. cpp:function:: void disassemble() const
.. cpp:function:: void extractDefensivePads(AddressSpace *)
Expand All @@ -48,6 +61,8 @@ CodeMover.h
.. cpp:function:: const EntryMap &entryMap()
.. cpp:function:: SpringboardMap &sBoardMap(AddressSpace *as)

Take the current PriorityMap, digest it, and return a sorted list of where we need patches (from and to).

Not const so we can add others to it.

.. cpp:function:: PriorityMap &priorityMap()
Expand Down
24 changes: 0 additions & 24 deletions dyninstAPI/src/Relocation/CodeMover.C
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ void CodeMover::finalizeRelocBlocks() {



///////////////////////


bool CodeMover::transform(Transformer &t) {
if (!finalized_)
finalizeRelocBlocks();
Expand Down Expand Up @@ -159,20 +156,6 @@ bool CodeMover::initialize(const codeGen &templ) {
return true;
}

// And now the fun begins
//
// We wish to minimize the space required by the relocated code. Since some platforms
// may have varying space requirements for certain instructions (e.g., branches) this
// requires a fixpoint calculation. We start with the original size and increase from
// there.
//
// Reasons for size increase:
// 1) Instrumentation. It tends to use room. Odd.
// 2) Transformed instructions. We may need to replace a single instruction with a
// sequence to emulate its original behavior
// 3) Variable-sized instructions. If we increase branch displacements we may need
// to increase the corresponding branch instruction sizes.

bool CodeMover::relocate(Address addr) {
addr_ = addr;

Expand Down Expand Up @@ -201,19 +184,12 @@ codeGen &CodeMover::gen() {
return buffer_.gen();
}

///////////////////////

PriorityMap &CodeMover::priorityMap() {
return priorityMap_;
}

///////////////////////

SpringboardMap &CodeMover::sBoardMap(AddressSpace *) {
// Take the current PriorityMap, digest it,
// and return a sorted list of where we need
// patches (from and to)

relocation_cerr << "Creating springboard request map" << endl;

if (sboardMap_.empty()) {
Expand Down

0 comments on commit 031368f

Please sign in to comment.