Suppose I have a dynamically-linked executable which depends on symbols in libfoo and libbar; and that it works on my system, i.e. it finds appropriate versions of these shared libraries. Now, I want to "replace" the dynamic dependencies on libfoo with compiled code from the libfoo I have on my system, obtaining a new executable which only dynamically depends on libbar.
Is this possible? At least, on a modern(ish) Linux system?
If it helps, you may assume additionally that the executable results from a single C source file; that I have this file; that I compiled with/without debug info or with whatever compilation switch you like.