avast / avast/retdec-idaplugin

Custom loader plugin decompilation output is nonsense

Open
#30 0 comments 0 reactions 1 assignee Claimed by @PeterMatula View on GitHub
enhancement P-output
Dominant language
C++
Stars
799
Forks
132
PR merge metrics
No merged PRs in 30d

Description

First all of all, kudos for the custom loader plugin support and `IDA 7.x` support but I'm still not happy with the decompilation output.

Given a function with the following assembly code:

```
.text:02008C5C __PerformSyscall:
.text:02008C5C li r0, 0x12
.text:02008C60 sc
.text:02008C64 blr
```

If I run the `retdec` decompiler on it, it produces the following output:
```
int32_t __PerformSyscall(void) {
// 0x2008c5c
return 0;
}
```

This is false because:
The function does not define a return value (`r3` is not set) hence the return type is `void`. Furthermore, the syscall (`sc` instruction) is not translated at all. A proper decompilation (in my opinion) may look like the following:
```
void __PerformSyscall(void) {
asm volatile
(
"li r0, 0x12\n"
"sc"
);
}
```

Since the syscall instruction does not exist in `C`, it has to use inline assembly.

Note that this is just one of many failing examples (all functions seem to just translate to `return 0`). In fact, `retdec` seemingly cannot deal with the custom plugin at all even though the `IDA` database holds all necessary information to perform the decompilation. Therefore, why does it not operate correctly on the database? I would either expect an error message if something went wrong with reading the right data or a "proper" decompilation. Not a default "no-op" decompilation like this.

Note that this is a follow-up issue to the following issue: https://github.com/avast-tl/retdec-idaplugin/issues/3 (Check it out for more information or to download the custom plugin as well as an example binary)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.