HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

l
ld(1) ld(1)
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 users 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.
When linking for use with the symbolic debugger dde, the user must ensure that the program con-
tains a routine called main. Also, the user must link in the file
/opt/langtools/lib/end.o
on 32-bit and /opt/langtools/lib/pa20_64/end.o
on 64-bit as the last file named on the command line.
There is no guarantee that the linker will pick up files from archive libraries and include them in the final
program in the same relative order that they occur within the library.
The linker emits warnings wherever it detects any compatibility issues. Among other things, these issues
include architectural ones, as well as functionality that may change over time. Some of these include:
Linking a PA 2.0 object file, which will not run on a PA 1.x system.
Incremental loading with the
-A option.
Procedure call parameter and return type checking, including the
-C option.
Symbols with the same name but different types, such as CODE and DATA.
Checking of unsatisfied symbols by the linker, which sometimes skips certain object files from an
archived library. This warning is only given if the
-v option is also provided.
Versioning of objects within a shared library.
These messages can be turned off with the +vnocompatwarnings option.
As noted in the Options section, certain options no longer exist in a 64-bit linker. They are:
-q
-A
-C
-E
-Q
-S
-T
-X
+dpv
Section 1456 Hewlett-Packard Company 20 HP-UX 11i Version 1: September 2005