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

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

Open
radare opened this issue Jan 20, 2020 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers test-attached test-required

Comments

@radare
Copy link
Contributor

radare commented Jan 20, 2020

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;
}
@ITAYC0HEN ITAYC0HEN changed the title bad decompilation on arm code hello world r2ghidra does not properly show a string argument on ARM hello-world program Jan 20, 2020
@romansavrulin
Copy link

romansavrulin commented Jan 23, 2020

Looks the same as #66 to me

@XVilka XVilka added bug Something isn't working good first issue Good for newcomers labels Jan 21, 2021
@XVilka XVilka changed the title r2ghidra does not properly show a string argument on ARM hello-world program rz-ghidra does not properly show a string argument on ARM hello-world program Jan 21, 2021
@XVilka
Copy link
Member

XVilka commented Jan 23, 2023

Still happens with the latest Rizin & Rz-ghidra (rizinorg/rizin@ead6016 and 0c9ab92 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]> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers test-attached test-required
Projects
None yet
Development

No branches or pull requests

3 participants