I'm very confused about position-independent code and its usage for dynamic libraries.
I found this good example about -fPIC option of GCC: GCC -fPIC option and I figure out how it works.
However, I'm struggling to understand why dynamic libraries need code independent of specific address. When a dynamic library is loaded, why we cannot just save its absolute addresses (ex. the address of a function in the library) and use them? Why the usage of relative address becomes mandatory in this case?
A simple program int main() { return 0; }
compiled with "gcc main.c" will be always position dependent?