This page provides information about the different phases of compiling and running a C (or C++) program and tools that can be used to examine the results of these different phases.
The different phases examined below are:
More information and examples using some of these tools to examine .o and a.out files (hexdump, strings, objdump, gdb).
// simple.c:
#include <unistd.h>
#define MAX 10
int foo(int y);
main() {
int x, i;
char buf[10];
for(i=0; i < MAX; i++) {
x = foo(i);
// a crazy way to print to stdout
sprintf(buf, "%d", x);
write(0, buf, strlen(buf));
buf[0] = '\n';
write(0, buf, 1);
}
}
int foo(int y) {
return y*y;
}