I have some questions about dynamic link libraries in C.
My textbooks uses a picture to illustrate how DLL works,
and it seems that some relocation and symbol table information of libvector.so and libc.so are copied (the arrow is attached to their side), but whenever the assembler encounters a reference to an object whose ultimate location is unknown, it generates a relocation entry that tells the linker how to modify the reference when it merges the object file into an executable. For libc.so, everything is known(it has all definitions), so there shouldn't be any relocation entry for libc.so, isn't it
Q2. My textbook says that:
"a single copy of the .text section of a shared library in memory can be shared by different running processes",
Let's say I have a program that uses printf. Does the .text section of printf stay in RAM forever or does it get evicted from RAM when the first program finishes, and get loaded in RAM when a second process uses printf again?
If the latter is the case, isn't that very inefficient that the .text section of printf gets evicted and loaded in RAM many many times since we have multiple processes that could be running in the background?
