On 04/27/2014 09:01 AM, Sergej Proskurin wrote:
Hello,
The following code snippet tries to redirect an edge of the type CALL to
the first basic block of the function 'func_name', which is included
within a loaded library (simple .so file). Unfortunately, the code gets
an error while trying to redirect the edge to the above mentioned
libarary function. Is there any possibility in Dyninst to address this
kind of issue or is not possible to redirect edges to library functions?
Sergej--
There are many things that could go wrong with code modification in
general, but this is also functionality that's supported through
Dyninst's BPatch layer directly. There are function replacement (all
calls to foo now call bar), function wrapping (all calls to foo call
bar, which then calls foo), and callsite replacement (this call to foo
now calls bar) primitives available, and one of those is likely to be
easier to work with than PatchAPI code modification for a simple
function-level graft.
--bw
---
...
BPatch_Vector<BPatch_function *> funcs;
std::vector<BPatch_basicBlock*> blocks;
BPatch_function *func_epilog;
BPatch_image* img;
PatchBlock *block;
if(out_edge->type() == EdgeTypeEnum::CALL) {
bool res;
img = app->getImage();
img->findFunction(func_name, funcs, true, true, false);
if(!funcs.size()) {
error("Could not find function to be instrumented: " + func_name);
return;
}
func_epilog = funcs[0];
cfg = func_epilog->getCFG();
cfg->getEntryBasicBlock(blocks);
block = PatchAPI::convert(*blocks.rbegin());
res = PatchModifier::redirect(out_edge, block);
if(!res) {
error("Could not redirect edge");
}
}
...
---
I would really appreciate any help with the stated issue.
Thank you very much in advance.
Best regards,
Sergej
_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
--
--bw
Bill Williams
Paradyn Project
bill@xxxxxxxxxxx
|