avast / avast/retdec

Proper handling of user defined functions named as some standard library function

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

Description

User defined function that are named the same as RetDec-recognized standard library functions will confuse the decompilation. E.g. decompilation of this binary [test.zip](https://github.com/avast-tl/retdec/files/1700427/test.zip) compiled from:
```c
void printf() {
puts("hello");
}

int main(int argv, char *argc[]) {
printf();
return 0;
}
```
May produce something like this:
```c
// ------------------------ Functions -------------------------

// Address range: 0x80483a0 - 0x80483ae
int main(int argc, char ** argv) {
// entry
int32_t * format;
printf((char *)&format);
return 0;
}

// --------------- Statically Linked Functions ----------------

// int printf(const char * restrict format, ...);
```
This should be handled better:
- Such functions should not be automatically marked as statically linked.
- Type information should not be applied only based on the function name.

The problem is, that the current behavior is oftentimes ok and greatly improve the output quality. We will need to find some good compromise.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the attached test binary and the C example that defines printf, then trace the standard-library recognition and type-application paths. Done means user-defined functions are not automatically marked as statically linked or typed solely from their names, while valid standard-library recognition still preserves output quality.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.