This is a small demo that shows how the linker will always give priority to a symbol found in object files above that very same symbol found in a library. I'm using a static library for convenience, but this works exactly the same for dynamic libraries.
The symbol being shadowed here is
my_print(). The version of that
subroutine that is implemented inside the static library
libslib.a is never
called by the executable
shadowlib, despite it being used internally by the
library itself! Yes, the library grabs the executable's version of
To build this demo, you need:
Build the library first by using:
$ cd slib/ $ make
And then build the executable:
$ cd .. $ make
This demo is published under an MIT/X11/Expat-type License. See
file for copyright and license details.