Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom loader plugin decompilation output is nonsense #30

Open
BullyWiiPlaza opened this issue Jul 11, 2018 · 0 comments
Open

Custom loader plugin decompilation output is nonsense #30

BullyWiiPlaza opened this issue Jul 11, 2018 · 0 comments

Comments

@BullyWiiPlaza
Copy link

BullyWiiPlaza commented Jul 11, 2018

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants