-
Notifications
You must be signed in to change notification settings - Fork 958
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
Incorrect translation:Assembly to C #724
Comments
hello, I found the root cause of this issue: // all arch
// all compilers
change_made |= analyse(bb, &IdiomsCommon::exchangeBitShiftSDiv2,
"IdiomsCommon::exchangeBitShiftSDiv2"); The problem is:
So why we perform this conversion for all arch / compilers? |
Hi! Thank you very much for your investigation and input! As you wrote this is indeed unwanted behavior. This might produce some noise in different situations but I think that we should definitely go in the correct way -> in this case shift instead of division. This behavior is only wanted in case of a logic shift (with unsigned int). I will provide a fix for this and I am going to add this good example into RetDec regression tests. |
Disables idiom that exchanged Pattern AShr(X,shift) into divistion SDiv(X, shift). This is because signed division is not equal to the arithmetic shift right all the time. Only when X is signed integer. Example: * AShr(0xA5A5A5A5A5A50020, 8) = 0xFFA5A5A5A5A5A500 * SDiv(0xA5A5A5A5A5A50020, 256) = 0xFFA5A5A5A5A5A501
Disables idiom that exchanged Pattern AShr(X,shift) into divistion SDiv(X, shift). This is because signed division is not equal to the arithmetic shift right all the time. Only when X is positive integer. Example: * AShr(0xA5A5A5A5A5A50020, 8) = 0xFFA5A5A5A5A5A500 * SDiv(0xA5A5A5A5A5A50020, 256) = 0xFFA5A5A5A5A5A501
Disables idiom that exchanged Pattern AShr(X,shift) into divistion SDiv(X, shift). This is because signed division is not equal to the arithmetic shift right all the time. Only when X is positive integer. Example: * AShr(0xA5A5A5A5A5A50020, 8) = 0xFFA5A5A5A5A5A500 * SDiv(0xA5A5A5A5A5A50020, 256) = 0xFFA5A5A5A5A5A501
This case was created from issue: avast/retdec#724
This case was created from issue: avast/retdec#724
Hi
I tested retdec on the test case shown below:
source file
test_driver.c
tested_api.c
tested_api.c
intotested_api.S
Makefile
:Test the function intested_api.S
bytest_driver.c
test.py
run the test
$ cd dir_of_retdec-regression-tests-framework $ python3 runner.py dir_of_testcase_aboce
The output:
The text was updated successfully, but these errors were encountered: