Skip to content

Custom loader plugin decompilation output is nonsense #30

@BullyWiiPlaza

Description

@BullyWiiPlaza

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: #3 (Check it out for more information or to download the custom plugin as well as an example binary)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions