rizinorg / rz-ghidra

Deep ghidra decompiler and sleigh disassembler integration for rizin
GNU Lesser General Public License v3.0
829 stars 88 forks source link

rz-ghidra does not properly show a string argument on ARM hello-world program #73

Open radare opened 4 years ago

radare commented 4 years ago

hello-arm.zip

$ rizin -c 's main;af;pdg' a.out

// WARNING: [r2ghidra] Matching calling convention arm32 of function main failed, args may be inaccurate.
// WARNING: [r2ghidra] Matching calling convention arm32 of function sym.imp.printf failed, args may be inaccurate.

undefined4 main(void)
{
    sym.imp.printf(*(int32_t *)0x490 + 0x47c);
    return 0;
}
[0x00000464]> pdc
function main () {
    //  1 basic blocks

    loc_0x464:

       push (fp, lr)
       fp = sp
       sp = sp - 8
       r0 = [pc + 0x18]         //[0x490:4]=32 ; 1168
       r0 = pc + r0             //"Hello world\n" section..rodata

       int printf("Hello world\n")
       lr = 0
       [sp + 4] = r0
       r0 = lr
       sp = fp                  //(pstr 0x0000049c) "Hello world\n"
       pop (fp, pc)             //section..rodata ; r13
(break)

}
[0x00000464]> pdsf
;-- pc, r15:
0x00000474 "Hello world\n"
0x00000478 bl sym.imp.printf
[0x00000464]>

Expecting:

{
    sym.imp.printf("Hello world\n");
    return 0;
}
romansavrulin commented 4 years ago

Looks the same as #66 to me

XVilka commented 1 year ago

Still happens with the latest Rizin & Rz-ghidra (https://github.com/rizinorg/rizin/commit/ead601655cb8ba3655be278426ad8d6e60382227 and https://github.com/rizinorg/rz-ghidra/commit/0c9ab921afa034cf7186821712d988d06190e07e respectively)

rizin a.out                   
 -- To debug a program, you can call rizin with 'dbg://<path-to-program>' or '-d <path..>'
[0x000003cc]> s main
[0x00000464]> af
[0x00000464]> pdf
╭ int main (int argc, char **argv, char **envp);
│           ; var int32_t var_ch @ stack - 0xc
│           0x00000464      push  {fp, lr}
│           0x00000468      mov   fp, sp
│           0x0000046c      sub   sp, sp, 8
│           0x00000470      ldr   r0, [0x00000490]                     ; [0x490:4]=32 ; 1168
│           0x00000474      add   r0, pc, r0
│           0x00000478      bl    sym.imp.printf                       ; sym.imp.printf ; int printf(const char *format)
│           0x0000047c      movw  lr, 0
│           0x00000480      str   r0, [var_ch]
│           0x00000484      mov   r0, lr
│           0x00000488      mov   sp, fp
╰           0x0000048c      pop   {fp, pc}
[0x00000464]> pdg

undefined4 main(void)
{
    int32_t var_ch;

    sym.imp.printf(0x49c);
    return 0;
}
[0x00000464]>