every .o file start with 0 memory address.
relocate symbols from thier relative locations in the .o files to their final absolute memory location in the executables.
Global symbol = that are defined in one module and can be reference by other module.
External symbol = Gobal symbol that are referenced by a module but are defined in some other module. declared with 'external' keyword
Local symbol = taht are reference in their own module. any global variable or function declared with 'static' keyword.
#include <stdio.h>
void swap();
int buf[2] = {1,2};
int main()
{
swap();
printf("buf[0]= %d, buf[1]= %d \n", buf[0], buf[1]);
return 0;
}
swap is external symbol , main is global symbol , printf is global external symbol
extern int buf[];
int *bufp0 = &buf[0];
static int *bufp1;
void swap()
{
int temp;
bufp1 = &buf[1];
temp = *bufp0;
*bufp0 = *bufp1;
*bufp1 = temp;
}
bufp0 is global symbol , bufp1 is local symbol
linker knows nothing abou temp.
Strong symbol = function names and initialized globals
Weak symbol = uninitialized globals
there cannot be mutiple strong symbol with same name , e.g) mutiple definition of 'main' is not allowed.
'Operating System > System Programming(Arif Butt)' 카테고리의 다른 글
Lec 6, 7) Versioning Systems git-1,2 (0) | 2021.06.15 |
---|---|
Lec05) GNU autotools and cmake (0) | 2021.06.13 |
Lec04) UNIX make utility (0) | 2021.06.12 |
Lec02) C Compilation: A System Programmer Perspective (0) | 2021.06.09 |
Lec1) Introduction to System Programming (0) | 2021.06.08 |