Language Processing Systems
10/11/24, 3:11 PM Language Processing Systems
https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 1/4
C Compilers
A typical C compiler is usually set up as a driver program which runs other separate programs.
For example, with gcc:
Compiler cc1
Compiled *.c C file to *.s assembly language file.
Assembler as
Assembles *.s assembly language file to *.o object file. The object file is a binary
file in a specific format which exports certain symbols and imports symbols it depends
on.
Linker ld
Links several object files together with libraries to produce an executable. There are
two kinds of linkers:
Static linker: Links in all code and produces a fully self-contained executable.
Dynamic linker: Links in all the object files but only links in references to the
libraries. The executable is not self-contained and the libraries will be linked in when
the executable is run.
Most modern systems use Dynamic Linked Libraries (DLLs). There are
disadvantages like DLL Hell, but has big advantages like smaller executables and the
possibility of having multiple concurrently executing programs share the same library
code in memory (AKA Dynamic Shared Objects, explaining the .so library
extension used in Unix).
10/11/24, 3:11 PM Language Processing Systems
https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 2/4
A Demo Program
File main.c:
#include "f1.h"
#include "f2.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char *argv[]) {
int a = atoi(argv[1]);
int b = atoi(argv[2]);
printf("value is %dn", f1(a, b) + f2(a, b));
return 0;
}
File f1.c:
#include "f1.h"
int f1(int a, int b) {
return a + b;
}
File f2.c:
#include "f2.h"
int f2(int a, int b) {
return a * b;
}
f1.s assembly code; f2.s assembly code.
10/11/24, 3:11 PM Language Processing Systems
https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 3/4
Compiler Flow
10/11/24, 3:11 PM Language Processing Systems
https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 4/4

Language Processing Systems and definition

  • 1.
    Language Processing Systems 10/11/24,3:11 PM Language Processing Systems https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 1/4 C Compilers A typical C compiler is usually set up as a driver program which runs other separate programs. For example, with gcc: Compiler cc1 Compiled *.c C file to *.s assembly language file. Assembler as Assembles *.s assembly language file to *.o object file. The object file is a binary file in a specific format which exports certain symbols and imports symbols it depends on. Linker ld Links several object files together with libraries to produce an executable. There are two kinds of linkers: Static linker: Links in all code and produces a fully self-contained executable. Dynamic linker: Links in all the object files but only links in references to the libraries. The executable is not self-contained and the libraries will be linked in when the executable is run. Most modern systems use Dynamic Linked Libraries (DLLs). There are disadvantages like DLL Hell, but has big advantages like smaller executables and the possibility of having multiple concurrently executing programs share the same library code in memory (AKA Dynamic Shared Objects, explaining the .so library extension used in Unix). 10/11/24, 3:11 PM Language Processing Systems https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 2/4
  • 2.
    A Demo Program Filemain.c: #include "f1.h" #include "f2.h" #include <stdio.h> #include <stdlib.h> int main(int argc, const char *argv[]) { int a = atoi(argv[1]); int b = atoi(argv[2]); printf("value is %dn", f1(a, b) + f2(a, b)); return 0; } File f1.c: #include "f1.h" int f1(int a, int b) { return a + b; } File f2.c: #include "f2.h" int f2(int a, int b) { return a * b; } f1.s assembly code; f2.s assembly code. 10/11/24, 3:11 PM Language Processing Systems https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 3/4 Compiler Flow 10/11/24, 3:11 PM Language Processing Systems https://zdu.binghamton.edu/cs571/slides/c-compiler-phases/c-compiler-phases.html 4/4