From charlesreid1

No edit summary
No edit summary
Line 1: Line 1:
{{Stub}}
=Simple Disassembly Example=
 
Starting with a simple hello world program:
 
<pre>
#include <stdio.h>
 
int main(void)
{
    printf("Hello world! This is C.\n");
    return 0;
}
</pre>
 
Now compile the program with debug flags:
 
<pre>
$ gcc -g hello_world.c -o hello_from_c.x
</pre>
 
and load it up into gdb:
 
<pre>
$ gdb hello_from_c.x
</pre>
 
Now you can run the program like normal:
 
<pre>
(gdb) run
</pre>
 
and to disassemble the binary into its assembly level instructions,
 
<pre>
(gdb) disassemble main
</pre>


=References=
=References=

Revision as of 04:41, 24 April 2017

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