avast / avast/retdec

Symbol name not used for local static variable

Open
#171 0 comments 0 reactions 0 assignees View on GitHub
bug C-bin2llvmir P-output
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

In decompilation of binary [test.zip](https://github.com/avast-tl/retdec/files/1702811/test.zip) created from the following source is not used symbol for local static variable:
```c
int foo() {
static int xxx = 1;
return xxx;
}

int main() {
return foo();
}
```
Output:
```c
// --------------------- Global Variables ---------------------

int32_t g1 = 1;

// ------------------------ Functions -------------------------

// Address range: 0x80483db - 0x80483e4
int32_t foo(void) {
// entry
return g1;
}

// Address range: 0x80483e5 - 0x80483ee
int main(int argc, char ** argv) {
// entry
return foo();
}
```
There is a symbol that could be used:
```
$ fileinfo -v test.elf | grep xxx
39 xxx.1727 DATA OBJECT LOCAL Default visibility 25 134520856 4
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the decompilation from the attached test.zip and compare the generated output with fileinfo -v test.elf, focusing on the local symbol named xxx. The work is done when the decompiled local static variable uses that symbol instead of the generated global name g1 and the existing regression behavior remains correct.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.