avast / avast/retdec

x87: wrong modelling of f2xm1

Open
#878 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Subject: https://github.com/rfalke/decompiler-subjects/blob/master/from_holdec/i386_x87_fpu/ia32_elf/subject.exe
Output:
```
int32_t F2XM1(void) {
float64_t v1 = llvm_exp2_f80(-2.0L); // 0x8049eb9
printf("F2XM1(-1): should= -0.500000/ -5.000000e-01 is=%12f/%15e\n", v1, v1);
float64_t v2 = llvm_exp2_f80(-1.0L); // 0x8049ed4
printf("F2XM1(0): should= 0.000000/ 0.000000e+00 is=%12f/%15e\n", v2, v2);
float64_t v3 = llvm_exp2_f80(0.0L); // 0x8049eef
printf("F2XM1(+1): should= 1.000000/ 1.000000e+00 is=%12f/%15e\n", v3, v3);
float64_t v4 = llvm_exp2_f80(-0.681690113816209316048L); // 0x8049f0e
printf("F2XM1(1/pi): should= 0.246869/ 2.468690e-01 is=%12f/%15e\n", v4, v4);
return 0;
}
```

f2xm1(x) calculates "(2^x)-1" and not "2^(x-1)" which retdec uses.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating RetDec's x87 F2XM1 modeling entry point and any tests for the provided i386_x87_fpu subject. Compare its result with the documented f2xm1(x) behavior and the sample output in the issue; done means the decompiler models (2^x)-1 rather than 2^(x-1).

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.