[DynInst_API:] Call Redirection to a Library Function


Date: Sun, 27 Apr 2014 16:01:38 +0200
From: "Sergej Proskurin" <prosig@xxxxxxx>
Subject: [DynInst_API:] Call Redirection to a Library Function
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?

---
...

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
 
[← Prev in Thread] Current Thread [Next in Thread→]