HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 13 (of 101)
Chapter 11 Software Development
October 29, 2013
On IA:
$ c++filt _Z3subc _Z3subi
sub(char)
sub(int)
$
nm++(1) is a script that calls nm(1) internally and uses c++filt(1) to demangle the mangled
names in its output. Java and aC++ on HP-UX use the same name mangling algorithm, so
c++filt(1) can also be used to demangle java method names.
Linking
The purpose of the linker is to create an executable file from a number of objects. Programs and
shared libraries are considered to be executable files, and the linker can create both. A shared
library is a collection of code and data that can be loaded to a program at runtime. The linker is
often also referenced to as the loader.
The Link Process
The linker ld reads all specified objects, puts them together into the binary file, calculates the
final addresses of all symbols and updates references to them. Libraries can be linked to the
binary using the -lname option. This causes the linker to search for a shared and an archive
library (in that order per default) with the name libname.*. The default search path and
extension of the library differ on the different platforms:
Platform
Location
Extension for
Shared Libs
Archive Libs
PA-RISC 32-bit
/usr/lib
.sl
.a
PA-RISC 64-bit
/usr/lib/pa20_64
IA64 32-bit
/usr/lib/hpux32
.so
IA64 64-bit
/usr/lib/hpux64
Other search paths can be added using the L linker option.
If a shared library has been found, only a reference to it is stored in the binary. If the archive
version is used, the objects that contain the referenced symbols are extracted and put into the
binary in the same way as the objects specified on the command line.
Assuming we have two objects a.o and b.o and a shared library libXYZ.sl, linking them to an
executable would work like this: