Skip to content

Commit

Permalink
Indirect tail calls can be PC-relative and should be treated as indir…
Browse files Browse the repository at this point in the history
…ect calls during relocation
  • Loading branch information
mxz297 committed Jul 28, 2016
1 parent 895d3fa commit 8f85a86
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dyninstAPI/src/Relocation/Transformers/Movement-adhoc.C
Expand Up @@ -59,7 +59,8 @@ bool adhocMovementTransformer::process(RelocBlock *cur, RelocGraph *cfg) {

RelocBlock::WidgetList &elements = cur->elements();

relocation_cerr << "PCRelTrans: processing block "
relocation_cerr << "PCRelTrans: processing block (ID= "
<< cur->id() << ") "
<< cur << " with "
<< elements.size() << " elements." << endl;

Expand Down Expand Up @@ -93,7 +94,6 @@ bool adhocMovementTransformer::process(RelocBlock *cur, RelocGraph *cfg) {

// Cache this so we don't re-decode...
InsnPtr insn = (*iter)->insn();

if (!insn) continue;

Address target = 0;
Expand Down
4 changes: 3 additions & 1 deletion dyninstAPI/src/Relocation/Widgets/CFWidget.C
Expand Up @@ -275,7 +275,9 @@ bool CFWidget::generate(const codeGen &templ,
// this for the memory emulation effort. Huzzah!
if (!generateAddressTranslator(buffer, templ, reg, trace))
return false;
if (isCall_) {
// If this is an indirect tail call, we still treat it
// as an indirect call
if (isCall_ || trace->block()->llb()->isIndirectTailCallBlock()) {
if (!generateIndirectCall(buffer,
reg,
insn_,
Expand Down
17 changes: 16 additions & 1 deletion dyninstAPI/src/parse-cfg.C
Expand Up @@ -358,7 +358,22 @@ bool parse_block::isCallBlock()
}
return false;
}

bool parse_block::isIndirectTailCallBlock()
{
const Block::edgelist & trgs = targets();
if(!trgs.empty())
{
for (Block::edgelist::const_iterator eit = trgs.begin();
eit != trgs.end();
eit++)
{
if ((*eit)->type() == INDIRECT && (*eit)->interproc()) {
return true;
}
}
}
return false;
}
image *parse_block::img()
{
vector<Function*> funcs;
Expand Down
1 change: 1 addition & 0 deletions dyninstAPI/src/parse-cfg.h
Expand Up @@ -79,6 +79,7 @@ class parse_block : public codeRange, public ParseAPI::Block {
bool isShared() const { return containingFuncs() > 1; }
bool isExitBlock();
bool isCallBlock();
bool isIndirectTailCallBlock();
bool isEntryBlock(parse_func * f) const;
parse_func *getEntryFunc() const; // func starting with this bock

Expand Down

0 comments on commit 8f85a86

Please sign in to comment.