-
Notifications
You must be signed in to change notification settings - Fork 954
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
Decompilation incorrectly uses pointer instead of the value it points to #384
Comments
A bit further down in the same function I have the following assembly:
This is translated into:
But
Not sure whether this is caused by the same internal misrepresentation of this value. |
I minimized that problematic function into the following NASM code:
Compiled with
You can see how |
It seems that the incorrect optimization here comes from the |
My bad,
After the optimization it became:
So |
It seems that the bug is here: The analysis here marks variables in a load statement as identical with the statement's argument. I am by no means an expert on LLVM IR, but from what I've seen so far I'm not sure that this is ever correct. For now I removed that block and am testing now whether I get more meaningful output this way. |
This indeed fixed the issue I mentioned in #384 (comment) as well, so it's caused by the same bug. |
With this change I finally got C code that makes sense. It's also 30% larger however, it seems that there were side-effects on the optimization quality which I don't yet understand. |
Ok, the side effect I saw were branches getting duplicated in llvmir2hll. While it isn't clear why the duplication didn't happen when casts were different, this change merely triggered suboptimal behavior. |
Running RetDec built from d57764a. I'm looking at a function that starts like this in the
.dsm
file:In the
.c
file I get the following:So
ecx
is turned intog5
,edi
intostr
andesi
intov5
- so far it all makes sense. However, unlike indicated in the C program,edi
andecx
are not the same. Rather,ecx
points to a structure with two pointers, string start and string end. This appears to be some optimization gone wrong. I would rather expect the following here:The text was updated successfully, but these errors were encountered: