Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve branches injected by callfixups and other injections #7502

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions Ghidra/Features/Decompiler/src/decompile/cpp/flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -776,36 +776,38 @@ void FlowInfo::generateOps(void)
int4 notreachcnt = 0;
clearProperties();
addrlist.push_back(data.getAddress());
while(!addrlist.empty()) // Recovering as much as possible except jumptables
fallthru();
if (hasInject())
injectPcode();
do {
while(!tablelist.empty()) { // For each jumptable found
vector<JumpTable *> newTables;
recoverJumpTables(newTables, notreached);
tablelist.clear();
for(int4 i=0;i<newTables.size();++i) {
JumpTable *jt = newTables[i];
if (jt == (JumpTable *)0) continue;

int4 num = jt->numEntries();
for(int4 i=0;i<num;++i)
newAddress(jt->getIndirectOp(),jt->getAddressByIndex(i));
while(!addrlist.empty()) // Try to fill in as much more as possible
fallthru();
}
}

checkContainedCall(); // Check for PIC constructions
checkMultistageJumptables();
while(notreachcnt < notreached.size()) {
tablelist.push_back(notreached[notreachcnt]);
notreachcnt += 1;
}
while(!addrlist.empty()) // Recovering as much as possible except jumptables
fallthru();
if (hasInject())
injectPcode();
} while(!tablelist.empty()); // Inlining or multistage may have added new indirect branches
do {
while(!tablelist.empty()) { // For each jumptable found
vector<JumpTable *> newTables;
recoverJumpTables(newTables, notreached);
tablelist.clear();
for(int4 i=0;i<newTables.size();++i) {
JumpTable *jt = newTables[i];
if (jt == (JumpTable *)0) continue;

int4 num = jt->numEntries();
for(int4 i=0;i<num;++i)
newAddress(jt->getIndirectOp(),jt->getAddressByIndex(i));
while(!addrlist.empty()) // Try to fill in as much more as possible
fallthru();
}
}

checkContainedCall(); // Check for PIC constructions
checkMultistageJumptables();
while(notreachcnt < notreached.size()) {
tablelist.push_back(notreached[notreachcnt]);
notreachcnt += 1;
}
if (hasInject())
injectPcode();
} while(!tablelist.empty()); // Inlining or multistage may have added new indirect branches
} while(!addrlist.empty()); // Injections may have added branches
}

void FlowInfo::generateBlocks(void)
Expand Down