Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
l
ld(1) ld(1)
NAME
ld - link editor
SYNOPSIS
The link editor. Common options:
ld [-bdmnqrstvxzEGIOPQVZ][-a search ][-c filename ][-dynamic]
[-e epsym ][-h symbol ] ... [-lx file ] ... [-l: library]
[-m][-noshared ][-o outfile ][-u symbol ] ... [-y symbol ] ...
[-B bind][-D offset ][-L dir] ... [-R offset ][-Pd][-PD file][-PF file][+b path_list ]
[+compat][+copyobjdebug][+df file ]
[+e symbol ][+ee symbol ][+fb][+fbu][+gst]
[+gstsize size][+h internal_name ][+help][+k][+n]
[+nocopyobjdebug][+noobjdebug ][+objdebugonly][+pd size]
[+pgm name ][+pi size][+s][+std][+tools][+v[no]shlibunsats]
[+vallcompatwarnings][+v[no]compatwarnings][+FP flag ]
[+I symbol ][+O[no]fastaccess][+O[no]procelim][+Oreusedir=dir ]
[+Oselectivepercent n][+Oselectivesize size][+OselectiveO3]
[+Ostaticprediction
]
32 Bit (SOM) Link Editor options:
ld [-NST][-A name][-C n][-Fl][-Fw][
-Fz][+cdp oldpath:newpath]
[
+cg pathname][+dpv][+filter shared_library_path]
[
+gstbuckets size][+nosmartbind ][+plabel_cache
flag]
64 Bit (ELF) Link Editor options:
ld [-k lename ][+fini function][+ild][+ildnowarn ][+ildpad
percentage][+ildrelink]
[
+init function][+interp file][+[no]allowunsats
][+[no]forceload]
[
+hideallsymbols][
+nodefaultmap][+noenvvar][+nodynhash ]
[
+nosectionmerge][
+paddata pagesize][+padtext pagesize][+pdzero]
[
+stripunwind ][+vtype type]
DESCRIPTION
ld takes one or more object files or libraries as input and combines them to produce a single (usually exe-
cutable) file. In doing so it resolves references to external symbols, assigns nal addresses to procedures
and variables, revises code and data to reflect new addresses (a process called "relocation"), and updates
symbolic debug information when present in the file. By default, ld produces an executable le that can
be run by the HP-UX loader exec() (see exec(2)). Alternatively, the linker can generate a relocatable file
that is suitable for further processing by ld (see -r below). It can also generate a shared library (see
-b
below). The linker marks the output file non-executable if there are any duplicate symbols or any
unresolved external references remain. ld may or may not generate an output file (see +k option) if any
other errors occur during its operation.
ld recognizes three kinds of input files: object files created by the compilers, assembler, or linker (also
known as .o files), shared libraries created by the linker, and archives of object files (called archive
libraries). An archive library contains a table of all the externally-visible symbols from its component object
files. (The archiver command ar(1) creates and maintains this index.) ld uses this table to resolve refer-
ences to external symbols.
ld processes files in the same order as they appear on the command line. It includes code and data from
an archive library element if and only if that object module provides a definition for a currently unresolved
reference within the user’s program. It is common practice to list libraries following the names of all sim-
ple object files on the command line.
Code and data from shared libraries is never copied into an executable program. The dynamic loader
/usr/lib/dld.sl on 32-bit links is invoked at startup time by the startup file crt0.o if a program
uses shared libraries. Identical copies of
crt0.o can be found in either /usr/ccs/lib/crt0.o or
/opt/langtools/lib/crt0.o. For 64-bit mode, the dynamic loader is
/usr/lib/pa20_64/dld.sl and is invoked by exec for those programs that use shared libraries.
crt0.o is not required in shared bound links. The dynamic loader attaches each required library to the
process and resolves all symbolic references between the program and its libraries.
The text segment of a shared library is shared among all processes that use the library; each process using
the library receives its own copy of the data segment. If pxdb -s on has been run on the executable
that loads the library, the text segment of a shared library is mapped privately for each process running the
HP-UX Release 11i: December 2000 1 Section 1423
___
___