Kenwood HP 9000 Personal Computer User Manual


 
Chapter 3 61
Linker Tasks
Using Linker commands
NOTE The +e option overrides the -B symbolic option. For example, you use
+e symbol, only symbol is exported and all other symbols are hidden.
Similarly, if you use +ee symbol, only symbol is exported, but other
symbols exported by default remain visible.
Since all internal calls inside the shared library are resolved inside the
shared library, user-supplied modules with the same name are not seen
by routines inside the library. For example, you could not replace
internal libc.sl malloc() calls with your own version of malloc() if
libc.sl was linked with -B symbolic.
Comparing -B symbolic with -h and +e
Similar to the -h (hide symbol) and +e (export symbol) linker options, -B
symbolic optimizes call paths in a shared library. However, unlike -h and
+e, all functions in a shared library linked with -B symbolic are also
visible outside of the shared library.
Case 1: Building a Shared Library with -B symbolic.
Suppose you have two functions to place in a shared library. The
convert_rtn() calls gal_to_liter().
1. Build the shared library with -b. Optimize the call path inside the
shared library with -B symbolic.
$ ld -B symbolic -b convert.o volume.o -o libunits.sl
2. Two main programs link to the shared library. main1 calls
convert_rtn() and main2 calls gal_to_liter().
$ cc -Aa main1.c libunits.sl -o main1
$ cc -Aa main1.c libunits.sl -o main2
Figure 3-1 shows that a direct call path is established between
convert_rtn() and gal_to_liter() inside the shared library. Both symbols
are visible to outside callers.