Compiler

From Hackepedia
Jump to navigationJump to search

A compiler is a program that parses a high level programming language into machine parsable assembly code. Usually the compiler hands the produced assembly instructions to an assembler which then turns the assembly instructions into binary machine code that is executable by the computer directly without any interpreting programs. A common compiler found is the GNU C compiler (gcc), others include Borland C Compiler, Watcom C, Sun C compiler, Intel C compiler and so on.

Cross platform compilers

GNU C Compiler is capable of cross compiling other platforms from a different architecture. For example you can produce PowerPC assembly instructions with an amd64/i386 machine. There is other compilers that can possibly do this.

Internal procedure of compiling a program with GCC

GCC takes the C programming language code (.c) and changes it internally to a (.a) output (you can set a flag to stop the compiling process here). GAS (GNU Assembler) is then called upon to produce the binary output files (.o). Finally to make the program work, it has to call upon ld (linker) to link any shared libraries or crt0's against the .o file. Most of this is done through pipes within GCC itself as it forks and executes these programs.