avast / avast/retdec

No proper handling of external globals

Open
#341 2 comments 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

I was wondering if retdec is able to work with complex executables dependent on other shared libraries. Seems like this scenario does not work:

```c
$ cat test.cc
extern int a;

int main()
{
return a;
}

$ cat a.c
int a = 1023;

// gcc -m32 test.cc -o test -L. -la
```

Comes out with wrong value for `a`:

```
$ cat test.c
//
// This file was generated by the Retargetable Decompiler
// Website: https://retdec.com
// Copyright (c) 2018 Retargetable Decompiler
//

#include

// --------------------- Global Variables ---------------------

int32_t g1 = 0;

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

// Address range: 0x804851b - 0x8048525
int main(int argc, char ** argv) {
// 0x804851b
return g1;
}

// --------------------- Meta-Information ---------------------

// Detected compiler/packer: gcc (5.5.0)
// Detected functions: 1
// Decompilation date: 2018-06-17 02:34:02
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the example from test.cc and a.c, then inspect the generated test.c and compare its handling of the external variable with the executable's result. Trace the decompiler's external-global and shared-library analysis entry points; done means the generated result correctly represents the external global rather than using an incorrect local value.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, 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.