❑ PIC(Position Independent Code) : A code that can be located anywhere in virtual memory. It is used when creating a shared library.
* PIC is loaded by the dynamic linker.
* If PIC is not applied, all the code you want to share is placed at a fixed address.
❑ Library with PIC
❍ When calling a function, PLT is used.
❍ Fast function call : No relocation required.
❍ Small file size : No need for relocation information(.rel.dyn)
* Method 1 : gcc -c -fPIC [File name].c → gcc -shared -o [File name].so [File name].o
* Method 2 : gcc -shared -fPIC -o [File name].so [File name].c
❑ Library without PIC
❍ When calling a function, .text section is used.
❍ Slow function call : Relocation required.
❍ Big file size : Need for relocation information(.rel.dyn).
❍ It is impossible to share code with other processes since copy-on-write problem occurs.