avast / avast/retdec

x87: missing memory write for 32bit floats for fst

Open
#889 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 FST(void) {
// 0x804b100
g2 = 0x40490fdb;
char v1 = *(char *)&g3; // 0x804b11b
printf("FST(pi as float) should=0xdb 0x0f 0x49 0x40 is=0x%02x 0x%02x 0x%02x 0x%02x\n", 219, (int32_t)v1, (int32_t)g4, (int32_t)g5);
*(float64_t *)&g2 = 3.1415926535897931;
char v2 = *(char *)&g7; // 0x804b153
char v3 = *(char *)&g3; // 0x804b173
printf("FST(pi as double) should=0x18 0x2d 0x44 0x54 0xfb 0x21 0x09 0x40 is=0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", 24, (int32_t)v3, (int32_t)g4, (int32_t)g5, (int32_t)g6, (int32_t)v2, (int32_t)g8, (int32_t)g9);
*(float80_t *)&g2 = 3.141592653589793116L;
unsigned char v4 = *(char *)&g7; // 0x804b1bb
unsigned char v5 = *(char *)&g3; // 0x804b1db
printf("FST(pi as long double) should=0x35 0xc2 0x68 0x21 0xa2 0xda 0x0f 0xc9 0x00 0x40 is=0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", 0, (int32_t)v5, (int32_t)g4, (int32_t)g5, (int32_t)g6, (int32_t)v4, (int32_t)g8, (int32_t)g9, (int32_t)g10, (int32_t)g11);
return 0;
}
```
For the 64bit and 80bit there is a write (`*(float64_t *)&g2 = 3.1415926535897931`,...) visible in the output but not for the first 32bit fst.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked decompiler subject executable and the generated FST output, focusing on the 32-bit float store before the existing 64-bit and 80-bit cases. Compare the emitted memory writes and expected byte sequences; done means the 32-bit fst produces a visible write matching the expected float bytes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.