questions:
when a executable starts,
1. how to resolve symbols in that are in shared library.
2. can we upgrade/replace shared lib when executable is running? (can we upgrade executable when it is running?)
3. do we need restart executable after we upgrade shared lib so it can use new lib?
4. do we need recompile executable with new shared lib?
answers:
1. when executable starts, the dynamic linker is firstly executed. The programs ld.so and ld-linux.so* (dynamic linker) find and load the shared objects (shared libraries) needed by a program, prepare the program to run, and then run it.
dynamic linker read ELF of executable, to determine which lib to load, where to find shared lib. Here is good article about it.
2. As here said (answered by Anders Waldenborg), we can if we do it right. we can first remove lib, then put the new lib. To note, the new lib is not used by running executable now, the old one is used and hasn't been deleted actually, please see the link for detail. For upgrade executable, we need first remove it and restart.
3. I think yes, we need a restart. As 1 suggests, the symbol is resolved at the beginning, before executable starts. So after a upgrade shared lib, it will not be mapped to executable until next symbol resolve which is when it starts.
4. I think no, and it's one of reasons to use shared libs. I remember I've upgrade shared libs to test without recompile executable.