From charlesreid1

Revision as of 04:41, 24 April 2017 by Admin (talk | contribs)

Simple Disassembly Example

Starting with a simple hello world program:

#include <stdio.h>

int main(void) 
{
    printf("Hello world! This is C.\n");
    return 0;
}

Now compile the program with debug flags:

$ gcc -g hello_world.c -o hello_from_c.x

and load it up into gdb:

$ gdb hello_from_c.x

Now you can run the program like normal:

(gdb) run 

and to disassemble the binary into its assembly level instructions,

(gdb) disassemble main

References

http://www.ibm.com/developerworks/aix/library/au-gdb.html?ca=dgr-lnxw16GDB2

http://www.ibm.com/developerworks/aix/library/au-unix-strace.html

http://stackoverflow.com/questions/1585308/debugging-disassembled-libraries-with-gdb