a compiler translates source code into machine level code

  1. preprocessor: inlcudes and macros are expanded
  2. compiler: generates assembly code
  3. compiler: generates binary object code
  4. linker: links object code with std. libr functions (e.g. printf) and creates executable


    • just show assembly from c source file:
      gcc -O2 -S code.c
    • compile and assemble to create object file:
      gcc -O2 -c code.c
    • to disassemble an object file again:
      objdump -d code.o
    • actually creating an executable (linking object files and one needs to have a main file):
      gcc -O2 -o prog code.o main.c

I used these example files:

int accum = 0;

int sum(int x, int y) 4{
  int t = x + y;
  accum += t;
  return t;
int main(){
  return sum(1,3);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s