Incorrect result when decompile inline data
- Dominant language
- C++
- Stars
- 8.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
I found the result is suspicious while decompiling a simple example with RetDec. I think I should report it here.
Example Code:
```
1 #include
2 #include
3 #include
4 int main()
5 {
6 char buf[100] = "hello and welcome~.\n";
7 write(1, buf, strlen(buf));
8 return 0;
9 }
```
Compiled with gcc 7.3.0:
> gcc -fno-stack-protector -no-pie -m32 ./hello.c -o hello32
And the line 6 was compiled into:
```
8048469: call dword 0x8048390
804846e: add ebx, 0x1b92
8048474: mov dword [ebp-0x7c], 0x6c6c6568
804847b: mov dword [ebp-0x78], 0x6e61206f
8048482: mov dword [ebp-0x74], 0x65772064
8048489: mov dword [ebp-0x70], 0x6d6f636c
8048490: mov dword [ebp-0x6c], 0xa2e7e65
8048497: mov dword [ebp-0x68], 0x0
804849e: lea edx, [ebp-0x64]
80484a1: mov eax, 0x0
80484a6: mov ecx, 0x13
80484ab: mov edi, edx
80484ad: rep stosd
```
It semms the hello string was compiled into inline data(from 0x8048474 to 0x8048497), and RetDec failed to recover all this string. This is the main function generated by RetDec:
```
// Address range: 0x8048456 - 0x80484e0
int main(int argc, char ** argv) {
// 0x8048456
int32_t v1;
__x86_get_pc_thunk_bx((int32_t)&v1);
int32_t v2 = 0x6c6c6568; // bp-132
int32_t v3; // bp-108
__asm_rep_stosd_memset((char *)&v3, 0, 19);
int32_t v4 = &v2; // 0x80484b2
function_8048320(1, v4, function_8048300(v4));
return 0;
}
```
Only part of this string was recovered in line 6:
> int32_t v2 = 0x6c6c6568; // bp-132
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with the provided hello.c example and the gcc -fno-stack-protector -no-pie -m32 command. Compare the disassembly around 0x8048474-0x8048497 with RetDec's generated main function; done means the complete inline string is recovered instead of only 0x6c6c6568.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100