Thursday, April 23, 2009

Staring at mixed C/assembly code is way easier in Vim. Copy this to ~/.vim/syntax and then from the command line:

[674] objdump -S myprog | vim -c "setfiletype cmix" -

myprog:     file format elf32-i386
...
Disassembly of section .text:
...
08048504 <foo>:
#include <stdio.h>
#include <stdlib.h>

void foo()
{
 8048504:   55                      push   %ebp
 8048505:   89 e5                   mov    %esp,%ebp
 8048507:   83 ec 08                sub    $0x8,%esp
 804850a:   e8 c9 fe ff ff          call   80483d8 <mcount@plt>
    printf("Hello or Good-bye\n");
 804850f:   c7 04 24 50 86 04 08    movl $0x8048650,(%esp)
 8048516:   e8 cd fe ff ff          call 80483e8 <puts@plt>
}
 804851b:   c9                      leave  
 804851c:   c3                      ret    

0804851d <main>: