Linker version scripts can be used to provide fine-grained control of symbol visibility.
Suppose we have the following three source files in a shared library:
vis_comm() is only intended for use within the library.
But building in the usual way:
bash$ gcc -g -c -fPIC -Wall vis_comm.c vis_f1.c vis_f2.c bash$ gcc -g -shared -o vis.so vis_comm.o vis_f1.o vis_f2.o
produces a library that exports vis_comm().
We can see this using readelf(1), which lists information from ELF executables.
The following lists the dynamic symbols exported by the library:
bash$ readelf --syms --use-dynamic vis.so | grep vis_ 30 12: 00000790 59 FUNC GLOBAL DEFAULT 10 vis_f1 25 13: 000007d0 73 FUNC GLOBAL DEFAULT 10 vis_f2 27 16: 00000770 20 FUNC GLOBAL DEFAULT 10 vis_comm
(C) 2006, Michael Kerrisk