6.2 DWARF integration

Actually the dwarf support is activated by rabin when the binary have this information. This is just asm.dwarf=true, so when loading radare will add comments inside the assembly lines referencing the C/C++/Vala/Java.. sources lines.

Here's an example:

$ cat hello.c
main() {
  printf("Hello World\n");
}
$ gcc -g hello.c

$ rabin -rI ~/a.out| grep dwarf
e dbg.dwarf = true

$ rsc dwarf-lines a.out
CC      1       main() { @ 0x8048374
CC      2         printf("Hello World\n"); @ 0x8048385
CC      3       } @ 0x8048391
CC      3       } @ 0x804839a

This rsc script uses addr2line to get the correspondencies between source code line and memory address when the program is loaded in memory by the ELF loader.

And the result is:

[0x080482F0]> pdf @ sym.main
     ; 1        main() { 
0x08048374, / sym.main: lea ecx, [esp+0x4]
0x08048378, |           and esp, 0xf0
0x0804837b  |           push dword [ecx-0x4]
0x0804837e  |           push ebp
0x0804837f  |           mov ebp, esp
0x08048381  |           push ecx
     ; Stack size +4 
0x08048382  |           sub esp, 0x4
     ; 2          printf("Hello World\n"); 
0x08048385  |           mov dword [esp], 0x8048460 ; str.Hello_World
0x0804838c, |           call 0x80482d4  ; 1 = imp_puts
     ; Stack size -4 
     ; 3        } 
0x08048391  |           add esp, 0x4
0x08048394, |           pop ecx
0x08048395  |           pop ebp
0x08048396  |           lea esp, [ecx-0x4]
0x08048399  \           ret 
0x08048399           ; ------------------------------------ 
     ; 3        } 

Enable this mode with dbg.dwarf=true