After I have the executable file running I overwrite its .so library file with a new version and this causes the executable to die with segmentation fault. I thought the library file is being accessed only when ELF file is loaded. Am I wrong?
Share
The library file is mapped into the memory when it is loaded (usually, when the executable is loaded – but libraries can also be loaded later with
dlopen()). The actual pages of the file are then demand-loaded as required.Overwriting the file will cause pages from the file mapped
MAP_SHARED(which is most of them) to be updated with the new contents. This is what causes the segmentation faults. Don’t do that – instead, remove the existing .so file, then write the new one in its place.