Open esaulenka opened 5 years ago
I've been finding bugs and just generic issues in the SLEIGH (also adjusting SLEIGH for improved pcode) with help from a ghidra dev. The sha
, extr
, and few others (plus their variants) have been problematic translating into SLEIGH with my initial attempts. My current local changes have this as the output:
void FUN_8006f8f4(void)
{
uint uVar1;
uint uVar2;
uVar2 = 0;
do {
if (true) {
uVar1 = uVar2 << 2;
}
else {
uVar1 = uVar2;
if (true) {
uVar1 = 0;
}
}
uVar2 = uVar2 + 1 & 0xff;
*(undefined4 *)(&UNK_d00052e0 + uVar1) = 0;
*(undefined4 *)(&UNK_d0005320 + uVar1) = 0;
} while (uVar2 < 0x10);
a0 = &DAT_d000bc00;
return;
}
void FUN_8006f9be(void)
{
int iVar1;
a0 = &DAT_d000bc00;
iVar1 = FUN_800e3c2c();
if (iVar1 != 1) {
*(char *)(a0 + -0x1e5b) = *(char *)(a0 + -0x1e5b) + '\x01';
}
return;
}
https://github.com/mumbel/ghidra/commit/29f267b02b3e17e15647eebcff7f76de4063e2c2 seems like a noticeable improvement.
{
int iVar1;
uint uVar2;
uVar2 = 0;
do {
iVar1 = uVar2 * 4;
uVar2 = uVar2 + 1 & 0xff;
*(undefined4 *)(&UNK_d00052e0 + iVar1) = 0;
*(undefined4 *)(&UNK_d0005320 + iVar1) = 0;
} while (uVar2 < 0x10);
a0 = &DAT_d000bc00;
return;
}
Thanks, now decompiled text looks much better!
But unfortunately, problem remains: in FUN_8006f9be, FUN_8006fab2, and many others functions decompiler consider, that a0 is variable.
Ghidra produses strange code when meets with inderect addressing.
For example, in pcmflash..._2726.bin register
a0
writes only once - with value0xD000 BC00
. When I set this value (for whole code), i get:Address calculations are correct (
-0x2ffad20
is the same as0xd000bc00 - 0x6920
=0xD00052E0
), but...perhaps there is some way to indicate that result in address registers should be only unsigned ?
Another example:
Here disasm works correct, but decompiler doesn't understand this construction...