1


i am working a little bit with Ghidra. My assembly code doesn't match with the decompiled code:

                             *                          FUNCTION                          *
                             **************************************************************
                             undefined __stdcall CalCrc8(undefined4 param_1, int para
                               assume LRset = 0x0
                               assume TMode = 0x1
             undefined         r0:1           <RETURN>
             undefined4        r0:4           param_1
             int               r1:4           param_2
             int               r2:4           param_3
                             CalCrc8                                         XREF[2]:     Entry Point(*), 
                                                                                          Frame_Cap:0005a2b8(c)  
        00059dd8 05 4b           ldr        r3,[DAT_00059df0]                                = 0005F314h
        00059dda 10 b5           push       { r4, lr }
        00059ddc 8a 18           add        param_3,param_2,param_3
        00059dde 7b 44           add        r3,pc
        00059de0 03 e0           b          LAB_00059dea
                             LAB_00059de2                                    XREF[1]:     00059dec(j)  
        00059de2 11 f8 01 4b     ldrb.w     r4,[param_2],#0x1
        00059de6 60 40           eor        param_1,r4
        00059de8 18 5c           ldrb       param_1,[r3,param_1]=>Crc8Table               = 
                             LAB_00059dea                                    XREF[1]:     00059de0(j)  
        00059dea 91 42           cmp        param_2,param_3
        00059dec f9 d1           bne        LAB_00059de2
        00059dee 10 bd           pop        { r4, pc }
                             DAT_00059df0                                    XREF[1]:     CalCrc8:00059dd8(R)  
        00059df0 14 f3 05 00     undefined4 0005F314h                                        ?  ->  0005f314
void CalCrc8(undefined4 param_1,int param_2,int param_3)

{
  param_3 = param_2 + param_3;
  while (param_2 != param_3) {
    param_2 = param_2 + 1;
  }
  return;
}

The XOR (address 00059de6) and fetching the value from the CRC8Table is missing. How do i fix the decompiled code?

The architecture is ARM32v8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.