-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fall through edge of call instructions #7
Comments
It is actually vice versa :) This graph output includes only intraprocedural edges, and interprocedural edges are pruned, so a call that doesn't return won't have any output edges at all. Well, unless it is a conditional jump that doesn't return, e.g., in arm you can do
With that said, there is no need to do any graph analysis if all you want is to collect calls that do not return. You can do this programmatically, or by just greping the output of bap, e.g.,
it will output stuff like:
And you might ask a question: "Why is it calling This is a valid question :) This is due to the compiler optimization named tail-call optimization. For example, this is the example code from /bin/true, as disassembled with bap:
and the same with IDA Pro
and here is the IR:
and here is how it is decompiled: void *__fastcall sub_4038D0(size_t n)
{
void *v1; // rax
v1 = (void *)sub_403760();
return memset(v1, 0, n);
} as you can see this is a call that doesn't have a fallthrough and not all calls are made via the So depending on what you need this is fine or not :) |
Great! 👍 |
Hi! |
Which this? ;) Are you talking about this one? Then to get it you need to install the toolkit ( |
Sorry, I forget to paste the link. Yes, correct! Thank you! |
Hi, I want to build this with-no-return pass. However, I got this error:
The version of opam is 2.0.6, bap is 2.0.0. And the build command is |
You need to install the development version of bap for that, e.g., using opam
or you if you prefer Docker, then just build it in the bap-toolkit folder with |
Hi, I ran the with-no-return pass to get non-return function. But I am not clear why bap deems this function(0x8163b50) as non-return:
Although bap deems that 8164b5b is a function start, but should it follows the edge(0x8163b59 -> 8163b5b) to determine the return status of 8164b5b? By the way, I conclude the status of 8163b50 as non-return from this statements:
And this is not a tail call. The ir code of related basic blocks is shown as belows:
|
calculix_base.amd64-m32-ccr-Ofast.zip Thanks! |
A status update, after a thorough discussion with @gitoleg, we can confirm that this is a bug in the algorithm (we implicitly assumed that if a tail-call doesn't return to the caller it won't return to the caller of the caller, which is not true of course, and we have a good counter-example, thanks for it). We will update the algorithm and push the updated version. Thanks for tracking it! |
@gitoleg, can you provide a status update on this issue? |
Hi, I am trying to identify non-return function according to the cfg output from
bap
. This is thecfg
plugin that I used. here.Here is my method:
If a basic block's terminator is a
call
instruction and it doesn't have fall through edge, I deem that it calls anon-return
function. But when I checked the cfg result, it seems that there is no fall through edge of call instruction.I am curious whether I can output the fall through edge of call instructions?
Thanks!
The text was updated successfully, but these errors were encountered: