- 고급 언어 프로그램 (source file)
--> 컴파일러 - 어셈블리 프로그램
--> 어셈블러 - 기계어 프로그램 (object file)
--> 링커 - 기계어 프로그램 (실행파일; executable file): object file + library file
--> 로더 - 메모리
Program Execution과 관련한 System Software
- 컴파일러: 고급 언어 프로그램 --> 어셈블리 프로그램(ex: MIPS)
- 어셈블러: 어셈블리 프로그램 --> 기계어 프로그램(object file)
- 링커: 기계어 프로그램(object file) --> + library file --> 기계어 프로그램(실행파일; executable file)
- 로더: 기계어 프로그램(실행파일; executable file)을 메모리로 올린다.
Programming Language
- 고급 언어(high level language)
- 어셈블리 언어(assembly language)
- 기계어(machine language)
Separate Compile
- Compile: 고급 언어 프로그램(one.c, two.c, three.c) --> 어셈블리 프로그램
- Assemble: 어셈블리 프로그램 --> 기계어 프로그램(object file -- one.o, two.o, three.o)
- Link: 기계어 프로그램(object file) --> 기계어 프로그램(실행파일: x.exe)
▶ Separate compile
: symbol(변수, 함수 등의 이름)의 위치 불명확, type만 파악 --> object file (*.o, *.obj)
▶ Linking
: symbol의 위치 명확 --> execution file (a.out, *.exe)
고급 언어 프로그램 - extern
: 고급 언어 프로그램에서 같은 변수 공유한다. --> extern을 통해 변수를 통합한다.
실행파일 - Symbol Table
- 컴파일러: file.c --> 어셈블리 프로그램
- 어셈블러: 어셈블리 프로그램 --> file.o
- 링커: file.o --> file.o (실행파일)
- file.c --> file.o로 변환할 때, linker는 file의 symbol table을 확인한다.
Compile and Linking
Problem: What if there are so many externs?
Solution: Header file
- #include <x.h> --> extern
C preprocessor
- Preprocess
- Comile
- Link
Library
- 헤더파일에는 라이브러리 함수의 선언만 있고, 실제 함수의 정의는 라이브러리 파일에 있다.
Compile and Linking (Revisited)
1. Compiler: file.c --> 어셈블리 프로그램
2. Assembler: 어셈블리 프로그램 --> file.o
3. Linker: file.o --> file.o(실행파일)
- Static library - Static linking
4. Loader: file.o(실행파일) 실행
- Dynamic library - Dynamic linking
Static Linking vs. Dynamic Linking
- Static linking: 라이브러리가 프로그램의 실행파일 코드에 포함된다. (static library)
- Dynamic linking: 라이브러리가 실행 시 link된다. (shared library)
'시스템sw및실습' 카테고리의 다른 글
[시소실] 5. Linux (0) | 2023.10.04 |
---|---|
[시소실] 4. System Software and Program Execution (2) (0) | 2023.09.26 |
[시소실] 3. Procedure Call in MIPS (3) (0) | 2023.09.21 |
[시소실] 3. Procedure Call in MIPS (2) (0) | 2023.09.18 |
[시소실] 3. Procedure Call in MIPS (1) (0) | 2023.09.14 |