Dumping C and Assembly with objdump


I just came across the objdump “–source” option, which will display the C source code from a program along with the assembly instructions that were generated from the C code. The following example shows a snippet of what is produced during a typical run:

$ objdump --source curl

08050ed0 <homedir >:

char *homedir(void)
{
8050ed0: 55 push %ebp
char *home;

home = GetEnv("CURL_HOME", FALSE);
8050ed1: 31 d2 xor %edx,%edx
8050ed3: 89 e5 mov %esp,%ebp
8050ed5: b8 01 d0 05 08 mov $0x805d001,%eax
8050eda: 53 push %ebx
8050edb: 83 ec 04 sub $0x4,%esp
8050ede: e8 bd ff ff ff call 8050ea0
if(home)
8050ee3: 85 c0 test %eax,%eax
8050ee5: 89 c3 mov %eax,%ebx
8050ee7: 74 08 je 8050ef1
return home;

This is neat!

This article was posted by Matty on 2006-04-30 21:03:00 -0400 EDT