Figure 4 Symbols Inside a Shared Library Visible with -B symbolic

Case 2: Building a Shared Library with -h or +e

The -h(hide symbol) and +e (export symbol) options can also optimize the call path in a shared library for symbols that are explicitly hidden. However, only the exported symbols are visible outside of the shared library.

For example, you can hide the gal_to_liter symbol, as shown:

$ ld -b convert.o -h gal_to_liter volume.o -o libunits.sl

or export the convert_rtn symbol:

$ ld -b +e convert_rtn convert.o volume.o -o libunits.sl

In both cases, main2 cannot to resolve its reference to gal_to_liter() because only the convert_rtn() symbol is exported, as shown below in Figure 5 (page 35).

Figure 5 Symbol Hidden in a Shared Library

Using Linker Commands 35