ld(1)

 

 

 

 

 

 

 

 

 

 

 

ld(1)

NAME

 

 

 

 

 

 

 

 

 

 

 

 

ld - link editor

 

 

 

 

 

 

 

 

 

 

 

SYNOPSIS

 

 

 

 

 

 

 

 

 

 

 

 

The link editor. Common options:

 

 

 

 

 

 

 

 

ld [-bdmnqrstvxzEGIOPQVZ]

[-asearch ] [-c®lename ] [-dynamic]

 

 

[-eepsym ]

[-hsymbol ] . . .

[-lx®le ] ...

[-l:library ]

 

 

[-m]

[-noshared][-o out®le ] [-u symbol ]

. . .

[-ysymbol ] . . .

 

 

[-B

bind ]

[-Doffset ]

[-L

dir ] . . .

[-R

offset ]

[-Pd][-PD ®le] [-PF

®le]

[+b path_list ]

[+compat]

[+copyobjdebug] [+df ®le ]

 

 

 

 

 

 

[+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 ¯ag ]

 

 

[+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 ¯ag]

 

 

64 Bit (ELF) Link Editor options:

 

[+ildnowarn] [+ildpad percentage]

[+ildrelink]

ld [-k ®lename ] [+fini function] [+ild]

[+init

function]

[+interp

®le]

[+[no]allowunsats]

[+[no]forceload]

[+hideallsymbols] [+nodefaultmap] [+noenvvar] [+nodynhash]

[+nosectionmerge] [+paddata pagesize] [+padtext pagesize] [+pdzero] [+stripunwind ] [+vtype type]

DESCRIPTION

ld takes one or more object ®les or libraries as input and combines them to produce a single (usually exe- cutable) ®le. In doing so it resolves references to external symbols, assigns ®nal addresses to procedures and variables, revises code and data to re¯ect new addresses (a process called "relocation"), and updates symbolic debug information when present in the ®le. 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 ®le that is suitable for further processing by ld (see -rbelow). It can also generate a shared library (see -bbelow). The linker marks the output ®le non-executable if there are any duplicate symbols or any unresolved external references remain. ld may or may not generate an output ®le (see +k option) if any other errors occur during its operation.

ld recognizes three kinds of input ®les: object ®les created by the compilers, assembler, or linker (also known as .o ®les), shared libraries created by the linker, and archives of object ®les (called archive libraries). An archive library contains a table of all the externally-visible symbols from its component object ®les. (The archiver command ar(1) creates and maintains this index.) ld uses this table to resolve references to external symbols.

ld processes ®les 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 de®nition for a currently unresolved reference within the user's program. It is common practice to list libraries following the names of all simple object ®les 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 ®le 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

l