-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Fold conditional flags into original ones #171
base: master
Are you sure you want to change the base?
Conversation
@HMPerson1 @kriw @chinmaydd @sushant94 please check this out and write if you have any ideas/suggestions. |
@ZhangZhuoSJTU I don't quite understand the reasoning for doing this. Do you have any specific or motivating examples for what you expect the transformation to do? |
@HMPerson1 There might be some situations that we need the original conditional predication, instead of flag predication.
if (a < 0xdeadbeef)
func1(a);
else
func2(a); |
@ZhangZhuoSJTU I'd like to see explicit notes in the wiki/source code for the algorithm of For the capture groups in matcher.rs, it may be worth looking into how LLVM does this. I'll add a link when I find it again. |
@ZhangZhuoSJTU ping? |
@ZhangZhuoSJTU ping? |
@XVilka I am not sure whether I can finish this PR before the machine of It would be very easy to check the interval variables calculated in the way in that repo, even for x86. A simple test is to check interval variable after |
Hi @ZhangZhuoSJTU I'd like to help on this PR. Please can elaborate a bit more about what esil-rs is missing / why do you think it is broken? Getting this done would be especially useful to fix #216.
Does this still apply? I can only find 2 definitions (
By 'support group' you mean something like
Nice, but I'm wondering whether such an analyzer could be made architecture-agnostic? In theory Please be patient, I'm new to radeco/radare, so my questions will probably look dumb. Thank you. |
I am so sorry. I am quite busy right now that do not have enough time to finish this PR. But it is really nice that you can help. It's my pressure if I can do anything helpful.
IMO, the main problem of
I think it would be great to reduce this into one function.
I think what
It would be wonderful to be architecture-agnostic, but I think it is hard. The reason is that native code would express conditional predicate in different ways. For example
Above asm code's esil would look like
You can see that there is no
Of course. Thanks you so much that you would like to help. |
OK, I'll give it a try!
Yes,
Let's replace
Let's replace zf and cf in the jump:
Then we just need to grep
As you can see from this simple example we don't really need to know all the obscure architecture specific flags. Some platform agnostic rules (e.g. I'm assuming that |
@Mm7 It sounds interesting. By the way, I remember another shortage of As for the platform-specific issue. I think it is a good idea. One mistake is that |
BTW, maybe we need to do some simplify work after replacing. As the above example, the replacing result would look like
Another thing is that you may need to think about is how to replace Besides that, It would be very helpful if you can check how radare2 handle internal variables. It would benefit a lot to understand how internal variables work and be a good startup of this PR. |
Right now, RadecoIL uses the flag registers to indicate selectors for conditional branches, which is undesirable in decompilation or binary analysis. This PR tracks the progress of work on this.
The basic idea is to use
graph matcher
to find the condition patterns, grep and replace these expressions. Following tasks will be finished in this PR.SSASorter
to sort nodes' operands. It is necessary to keep the invariability through whole analysis process. (Associated with Standardize analysis stages' APIs #172 )hash_subtree
unified. In our code, there is a few hash_subtree functions which have the similar functionality. It need to be set as a basic API for SSA.matcher.rs
to support capture group, which will help use locate the original condition.This PR is associated with #155