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

AArch64 floating point conditions are not evaluated properly in the decompiler #7479

Open
dt-12345 opened this issue Feb 11, 2025 · 3 comments
Assignees
Labels
Status: Internal This is being tracked internally by the Ghidra team

Comments

@dt-12345
Copy link

Describe the bug
AArch64 condition codes vs and vc display as false/true in the decompiler when both operands are the same. Some other float comparisons appear to break under certain conditions but I'm not sure how to reproduce them in an isolated environment.

To Reproduce
Compile a simple program like the following:

#include <cmath>

bool vs_example(float foo) {
    return std::isnan(foo);
}

bool vc_example(float foo) {
    return !std::isnan(foo);
}

Then analyze the binary in Ghidra. The decompiler will output return false; for the first function and return true; for the second.

Expected behavior
It should either show the explicit comparison (like param_1 != param_1) or use NaN for these specific cases (maybe something like isnan(param_1).

Screenshots

Image
Image

The weird example I don't know how to reproduce:

Image

Environment (please complete the following information):

  • OS: Windows 10 Home 22H2
  • Java Version: 21.0.4
  • Ghidra Version: 11.3 Release
  • Ghidra Origin: Official GitHub Repository
@ghidracadabra
Copy link
Contributor

There is an option controlling how much to ignore NaN operations in the decompiler output. You can change it via
Edit ->Tool Options-> Decompiler->Analysis>NaN operations. Does changing it help?

@ghidracadabra ghidracadabra self-assigned this Feb 13, 2025
@ghidracadabra ghidracadabra added the Status: Waiting on customer Waiting for customer feedback label Feb 13, 2025
@dt-12345
Copy link
Author

Using Ignore none doesn't seem to change the output even after reimporting + reanalyzing.
Image

@ghidracadabra
Copy link
Contributor

Looks like the pcode for fmcp is not handling the NaN case. Should be an easy fix. Once the pcode has been updated the ignore nan option should behave as expected.

@ghidracadabra ghidracadabra added Status: Prioritize This is currently being prioritized Status: Internal This is being tracked internally by the Ghidra team and removed Status: Waiting on customer Waiting for customer feedback Status: Prioritize This is currently being prioritized labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Internal This is being tracked internally by the Ghidra team
Projects
None yet
Development

No branches or pull requests

2 participants