l

ld(1)ld(1)

executable. ld recursively examines the dependencies of shared libraries used by a program that was created by ld. If ld does not ®nd a supporting shared library at the path recorded in the dependency list of a shared library, and if the dependency is the result of an -largument used when the shared library was created, ld will search all the directories that it would search for a library that was speci®ed with -l(see -Land LPATH).

Environment Variables

Arguments can be passed to the linker through the LDOPTS environment variable as well as on the command line. The linker gets the value of LDOPTS and places its contents before any arguments on the command line.

The LD_PXDB environment variable de®nes the full execution path for the debug preprocessor pxdb. The default value is /opt/langtools/bin/pxdb. ld invokes pxdb on its output ®le if that ®le is executable and contains debug information. To defer invocation of pxdb until the ®rst debug session, set LD_PXDB to /bin/true.

The LPATH environment variable can be used to specify default directories to search for library ®les. See the -loption.

Options

The common ld options are listed ®rst, followed by the options supported only in a 32-bit linker, and then the options only supported in a 64-bit linker.

-asearch

Specify whether shared or archive libraries are searched with the -loption. The

 

value of search should be one of archive, shared, archive_shared,

 

shared_archive, or default. This option can appear more than once, inter-

 

spersed among -loptions, to control the searching for each library. The default is to

 

use the shared version of a library if one is available, or the archive version if not.

 

If either archive or shared is active, only the speci®ed library type is accepted.

 

If archive_shared is active, the archive form is preferred, but the shared form is

 

allowed.

 

 

If shared_archive is active, the shared form is preferred but the archive form is

 

allowed.

 

-b

Create a shared library rather than a normal executable ®le. Object ®les processed

 

with this option must contain position-independent code (PIC). See the discussion

 

of PIC in cc(1), CC(1) (part of the optional C++ compiler documentation), f77(1), pc(1),

 

as(1), and Linker and Libraries Online User Guide.

-cfilename

Read ld options from a ®le. Each line contains zero or more arguments separated by

 

white space. Each line in the ®le, including the last line, must end with a newline

 

character. A # character implies that the rest of the line is a comment. To escape a

 

# character, use the sequence ##.

 

-d

Force de®nition of ``common'' storage; that is, assign addresses and sizes, for -rout-

 

put.

 

-eepsym

Set the default entry point address for the output ®le to be that of the symbol epsym.

 

(This option only applies to executable ®les.)

 

-hsymbol

Prior to writing the symbol table to the output ®le, mark this name as ``local'' so that

 

it is no longer externally visible. This ensures that this particular entry will not clash

 

with a de®nition in another ®le during future processing by ld.

 

More than one symbol can be speci®ed, but -hmust precede each one. If used when

 

building a shared library or program, this option prevents the named symbol from

 

being visible to the dynamic loader.

 

-lx

Search a library libx.a or libx.sl, where

x is one or more characters. The

 

current state of the -aoption determines whether the archive (.a) or shared (.sl)

 

version of a library is searched. Because a library is searched when its name is

 

encountered, the placement of a -lis signi®cant. By default, 32-bit libraries are

 

located in /usr/lib and /usr/ccs/lib .

64-bit libraries are located in

 

/usr/lib/pa20_64. If the environment variable LPATH is present in the user's

 

environment, it should contain a colon-separated list of directories to search. These

 

directories are searched instead of the default directories, but -Loptions can still be

Section 1424

− 2 −

HP-UX Release 11i: December 2000