Ghidra: x87 FPU isn't handled correctly by the decompiler

Created on 29 Oct 2019  路  1Comment  路  Source: NationalSecurityAgency/ghidra

Describe the bug
The decompiler fails to analyze correctly code that is making use of the x87 FPU subset of instructions.

To Reproduce
Import the binary attached(it is a standard PE), several mistakes can be seen at the following adresses:

  • 0x40d770, decompiler output being:
    if ((((bullet->state != 0) && (bullet->state != 5)) &&
        (bullet->sprites[0].additional_infos != (something_56_bytes *)0x0)) &&
       ((!in_PF && (!in_PF)))) {

while the correct output should be something more along the lines of

if bullet->state != 0 && bullet->state != 5 && (bullet->sprites[0].additional_infos) != 0x0 && (30. <= (bullet->sprites[0].additional_infos)->height) && bullet->speed == 0. {
  • 0x40dbc0, where the decompiler is showing a fsincos being unused, while it is actually used in the binary.

Expected behavior
The decompiler analyzing correctly the file

Attachments
binary.txt

Environment (please complete the following information):

  • OS: Gentoo Linux
  • Java Version: 11.0.4
  • Ghidra Version: 9.1 2019-Oct-22
Decompiler Processox86 Bug

Most helpful comment

The first issue is resolved now in the master branch with the addition of full support for the x86 parity flag. The fsincos problem is a different issue with the detection of stack aliases but is also resolved in master; thanks for reporting it. Fixes should be present in the 9.2 release.

>All comments

The first issue is resolved now in the master branch with the addition of full support for the x86 parity flag. The fsincos problem is a different issue with the detection of stack aliases but is also resolved in master; thanks for reporting it. Fixes should be present in the 9.2 release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

astrelsky picture astrelsky  路  3Comments

rrivera1849 picture rrivera1849  路  3Comments

astrelsky picture astrelsky  路  3Comments

ghost picture ghost  路  3Comments

Kerilk picture Kerilk  路  3Comments