HP-UX Reference (11i v3 07/02) - 1 User Commands A-M (vol 1)
l
ld_pa(1)
PA-RISC Systems Only
ld_pa(1)
On 64-bit, link a shared bound program in standard mode. Note that
crt0.o is not specified because for
shared links, it is no longer necessary.
ld himom.o +std -lc
On 64-bit, link a compatibility mode program.
crt0.o is included because this is an archive link.
ld /opt/langtools/lib/pa20_64/crt0.o himom.o +compat -a archive -lc
Create a shared library:
ld -b -o libfunc.sl func1.o func2.o func3.o
Create a shared library with an internal name:
ld -b -o libfoo1.1 foo1.o foo2.o +h libfoo1.1
ln -s libfoo1.1 libfoo1.sl
cc -g mytest.c -L . -lfoo1
chatr a.out
...
shared library list:
dynamic ./libfoo1.1
If you do not use +h, the shared library does not have an internal name. The linker does not check
whether .sl is a symbolic link. It records the library name that it looks at, if it does not have the internal
name.
chatr a.out
...
shared library list:
dynamic ./libfoo1.sl
On 32-bit, link a program with libfunc.sl but use the archive version of the C library. Specify the
immediate binding mode together with the nonfatal modifier and allow verbose diagnostics to be displayed:
ld /usr/ccs/lib/crt0.o -B immediate -B nonfatal -B verbose \
program.o -L . -lfunc -a archive -lc
To do this on 64-bit:
ld -B immediate -B nonfatal -B verbose \
program.o -L . -lfunc -a archive -lc
On 32-bit, link a Pascal program:
ld /usr/ccs/lib/crt0.o main.o -lcl -lm -lc
Note that in the above examples, /usr/ccs/lib/crt0.o
can be replaced by
/opt/langtools/lib/crt0.o
.
WARNINGS
ld recognizes several names as having special meanings. The symbol _end is reserved by the linker to
refer to the first address beyond the end of the program’s address space. Similarly, the symbol
_edata
refers to the first address beyond the initialized data, and the symbol _etext refers to the first address
beyond the program text. The symbols end, edata, and etext are also defined by the linker, but only if
the program contains a reference to these symbols and does not define them (see end(3C) for details). On
32-bit, the symbol __tdsize is the total thread local storage size required by the program or shared
library.
On 64-bit, the linker defines a few more symbols. The symbol __TLS_SIZE is the total thread local
storage size. The symbol _FPU_STATUS is the initial status of the FPU status register. The symbol
__SYSTEM_ID is the largest architecture revision level used by any compilation unit.
The linker treats a user definition of any of the symbols listed here as an error.
Through its options, the link editor gives users great flexibility. However, those who invoke the linker
directly must assume some added responsibilities. Input options should ensure the following properties for
programs:
• When the link editor is called through cc(1), a start-up routine is linked with the user’s program. This
routine calls exit(2) after execution of the main program. If users call ld directly, they must ensure that
the program always calls exit() rather than falling through the end of the entry routine.
HP-UX 11i Version 3: February 2007 − 20 − Hewlett-Packard Company 557