다음 두개의 파일에서 symbol type과 section을 나누어 빈칸을 채워라.
- sybol(swap.o / m.o)
- symbol type(local, golbal, extern)
- section(.text, .data, .bss, or COMON)
| Symbol | .symtab entry? | Symbol type | Module where defined | Section |
| buf | ||||
| bufp0 | ||||
| bufp1 | ||||
| swap | ||||
| temp |
//m.c
void swap();
int buf[2] = {1, 2};
int main()
{
swap();
return 0;
}
//swap.c
extern int buf[];
int *bufp0 = &buf[0];
int *bufp1;
void swap()
{
int temp;
bufp1 = &buf[1];
temp = *bufp0;
*bufp0 = *bufp1;
*bufp1 = temp;
}
정답
| Symbol | .symtab entry? | Symbol type | Module where defined | Section |
| buf | o | extern | m.o | .data |
| bufp0 | o | global | swap.c | .data |
| bufp1 | o | global | swap.c | COMMON |
| swap | o | global | swap.c | .text |
| temp | x | - | - | .- |
풀이
temp는 local variable로 symbol entry를 가지고 있지 않다. 나머지는 symbol entry를 가진다.
buf는 extern으로 정의되어 있으며, 나머지는 함수 바깥에 선언되어 global이다. temp는 local variable로 linking에 사용되지 않는다.
.data section에는 initialized global variable이 들어간다.
.txt에는 Code가 들어간다.
bufp1은 initailized가 되어 있지 않아 COMMON으로 표시.
'System programming' 카테고리의 다른 글
| Linking 6 - Library interpositioning (0) | 2022.04.07 |
|---|---|
| Linker 문제2 (0) | 2022.04.06 |
| Linker2 (0) | 2022.04.05 |
| Linking1 (0) | 2022.04.04 |
| 시스템프로그래밍1 - Overview (0) | 2022.04.04 |
댓글