JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 1: User Commands
search filter icon
search icon

Document Information

Preface

Introduction

User Commands

acctcom(1)

adb(1)

addbib(1)

admin(1)

aedplot(1B)

alias(1)

allocate(1)

amt(1)

answerbook2(1)

appcert(1)

apptrace(1)

apropos(1)

ar(1)

arch(1)

as(1)

asa(1)

at(1)

atoplot(1B)

atq(1)

atrm(1)

audioconvert(1)

audioplay(1)

audiorecord(1)

auths(1)

auto_ef(1)

awk(1)

banner(1)

basename(1)

basename(1B)

batch(1)

bc(1)

bdiff(1)

bfs(1)

bg(1)

bgplot(1B)

biff(1B)

break(1)

cal(1)

calendar(1)

cancel(1)

case(1)

cat(1)

cc(1B)

cd(1)

cdc(1)

cdrw(1)

chdir(1)

checkeq(1)

checknr(1)

chgrp(1)

chkey(1)

chmod(1)

chown(1)

chown(1B)

ckdate(1)

ckgid(1)

ckint(1)

ckitem(1)

ckkeywd(1)

ckpath(1)

ckrange(1)

ckstr(1)

cksum(1)

cktime(1)

ckuid(1)

ckyorn(1)

clear(1)

cmp(1)

cocheck(1F)

cocreate(1F)

codestroy(1F)

col(1)

comb(1)

comm(1)

command(1)

compress(1)

continue(1)

coproc(1F)

coreceive(1F)

cosend(1F)

cp(1)

cpio(1)

cpp(1)

cputrack(1)

crle(1)

crontab(1)

crtplot(1B)

crypt(1)

csh(1)

csplit(1)

ct(1C)

ctags(1)

ctrun(1)

ctstat(1)

ctwatch(1)

cu(1C)

cut(1)

date(1)

dc(1)

deallocate(1)

decrypt(1)

delta(1)

deroff(1)

df(1B)

dhcpinfo(1)

diff(1)

diff3(1)

diffmk(1)

digest(1)

digestp(1)

dircmp(1)

dirname(1)

dirs(1)

dis(1)

disable(1)

dispgid(1)

dispuid(1)

dos2unix(1)

download(1)

dpost(1)

dtappsession(1)

du(1)

du(1B)

dumbplot(1B)

dump(1)

dumpcs(1)

dumpkeys(1)

echo(1)

echo(1B)

echo(1F)

ed(1)

edit(1)

egrep(1)

eject(1)

elfdump(1)

elfsign(1)

enable(1)

encrypt(1)

enhance(1)

env(1)

eqn(1)

errange(1)

errdate(1)

errgid(1)

errint(1)

erritem(1)

error(1)

errpath(1)

errstr(1)

errtime(1)

erruid(1)

erryorn(1)

eval(1)

ex(1)

exec(1)

exit(1)

expand(1)

export(1)

exportfs(1B)

expr(1)

expr(1B)

exstr(1)

face(1)

factor(1)

false(1)

fastboot(1B)

fasthalt(1B)

fc(1)

fdformat(1)

fg(1)

fgrep(1)

file(1)

file(1B)

filep(1)

filesync(1)

filofaxp(1)

find(1)

finger(1)

fmlcut(1F)

fmlexpr(1F)

fmlgrep(1F)

fmli(1)

fmt(1)

fmtmsg(1)

fold(1)

for(1)

foreach(1)

franklinp(1)

from(1B)

ftp(1)

ftpcount(1)

ftpwho(1)

function(1)

gcore(1)

gencat(1)

geniconvtbl(1)

genlayouttbl(1)

genmsg(1)

get(1)

getconf(1)

getfacl(1)

getfrm(1F)

getitems(1F)

getlabel(1)

getopt(1)

getoptcvt(1)

getopts(1)

gettext(1)

gettxt(1)

getzonepath(1)

gigiplot(1B)

glob(1)

goto(1)

gprof(1)

graph(1)

grep(1)

groups(1)

groups(1B)

grpck(1B)

hash(1)

hashcheck(1)

hashmake(1)

hashstat(1)

head(1)

help(1)

helpdate(1)

helpgid(1)

helpint(1)

helpitem(1)

helppath(1)

helprange(1)

helpstr(1)

helptime(1)

helpuid(1)

helpyorn(1)

history(1)

hostid(1)

hostname(1)

hp7221plot(1B)

hpplot(1B)

i286(1)

i386(1)

i486(1)

i860(1)

iAPX286(1)

iconv(1)

idnconv(1)

if(1)

implot(1B)

indicator(1F)

indxbib(1)

install(1B)

ipcrm(1)

ipcs(1)

isainfo(1)

isalist(1)

jobs(1)

join(1)

jsh(1)

kbd(1)

kdestroy(1)

keylogin(1)

keylogout(1)

kill(1)

kinit(1)

klist(1)

kmdb(1)

kmfcfg(1)

kpasswd(1)

krb5-config(1)

ksh(1)

ktutil(1)

lari(1)

last(1)

lastcomm(1)

ld(1)

ld(1B)

ldap(1)

ldapadd(1)

ldapdelete(1)

ldaplist(1)

ldapmodify(1)

ldapmodrdn(1)

ldapsearch(1)

ldd(1)

ld.so.1(1)

let(1)

lex(1)

limit(1)

line(1)

lint(1B)

list_devices(1)

listusers(1)

llc2_autoconfig(1)

llc2_config(1)

llc2_stats(1)

ln(1)

ln(1B)

loadkeys(1)

locale(1)

localedef(1)

logger(1)

logger(1B)

login(1)

logname(1)

logout(1)

longline(1F)

look(1)

lookbib(1)

lorder(1)

lp(1)

lpc(1B)

lpq(1B)

lpr(1B)

lprm(1B)

lpstat(1)

lptest(1B)

ls(1)

ls(1B)

m4(1)

mac(1)

mach(1)

machid(1)

madv.so.1(1)

mail(1)

Mail(1B)

mail(1B)

mailcompat(1)

mailp(1)

mailq(1)

mailstats(1)

mailx(1)

make(1S)

man(1)

mconnect(1)

mcs(1)

mdb(1)

mesg(1)

message(1F)

mixerctl(1)

mkdir(1)

mkmsgs(1)

mkstr(1B)

mktemp(1)

moe(1)

more(1)

mp(1)

mpss.so.1(1)

msgfmt(1)

mt(1)

mv(1)

nawk(1)

nca(1)

ncab2clf(1)

ncakmod(1)

neqn(1)

newform(1)

newgrp(1)

news(1)

newsp(1)

newtask(1)

nice(1)

NIS+(1)

nis+(1)

nis(1)

niscat(1)

nischgrp(1)

nischmod(1)

nischown(1)

nischttl(1)

nisdefaults(1)

niserror(1)

nisgrep(1)

nisgrpadm(1)

nisln(1)

nisls(1)

nismatch(1)

nismkdir(1)

nisopaccess(1)

nispasswd(1)

nisrm(1)

nisrmdir(1)

nistbladm(1)

nistest(1)

nl(1)

nm(1)

nohup(1)

notify(1)

nroff(1)

od(1)

on(1)

onintr(1)

optisa(1)

pack(1)

page(1)

pagesize(1)

pargs(1)

passwd(1)

paste(1)

patch(1)

pathchk(1)

pathconv(1F)

pax(1)

pcat(1)

pcred(1)

pdp11(1)

perl(1)

pfcsh(1)

pfexec(1)

pfiles(1)

pfksh(1)

pflags(1)

pfsh(1)

pg(1)

pgrep(1)

pkginfo(1)

pkgmk(1)

pkgparam(1)

pkgproto(1)

pkgtrans(1)

pkill(1)

pktool(1)

plabel(1)

pldd(1)

plimit(1)

plot(1B)

plottoa(1B)

pmap(1)

popd(1)

postdaisy(1)

postdmd(1)

postio(1)

postmd(1)

postplot(1)

postprint(1)

postreverse(1)

posttek(1)

ppgsz(1)

ppriv(1)

pr(1)

praliases(1)

prctl(1)

preap(1)

prex(1)

print(1)

printenv(1B)

printf(1)

priocntl(1)

proc(1)

prof(1)

profiles(1)

projects(1)

prs(1)

prt(1)

prun(1)

ps(1)

ps(1B)

psig(1)

pstack(1)

pstop(1)

ptime(1)

ptree(1)

pushd(1)

pvs(1)

pwait(1)

pwd(1)

pwdx(1)

ranlib(1)

rcapstat(1)

rcp(1)

rdist(1)

read(1)

readfile(1F)

readonly(1)

red(1)

refer(1)

regcmp(1)

regex(1F)

rehash(1)

reinit(1F)

remote_shell(1)

remsh(1)

renice(1)

repeat(1)

reset(1B)

reset(1F)

return(1)

rksh(1)

rlogin(1)

rm(1)

rmail(1)

rmdel(1)

rmdir(1)

rmformat(1)

roffbib(1)

roles(1)

rpcgen(1)

rpm2cpio(1)

rsh(1)

run(1F)

runat(1)

rup(1)

rup(1C)

ruptime(1)

rusage(1B)

rusers(1)

rwho(1)

sact(1)

sag(1)

sar(1)

sccs(1)

sccs-admin(1)

sccs-cdc(1)

sccs-comb(1)

sccs-delta(1)

sccsdiff(1)

sccs-get(1)

sccs-help(1)

sccs-prs(1)

sccs-prt(1)

sccs-rmdel(1)

sccs-sact(1)

sccs-sccsdiff(1)

sccs-unget(1)

sccs-val(1)

scp(1)

script(1)

sdiff(1)

sed(1)

sed(1B)

select(1)

set(1)

set(1F)

setcolor(1F)

setenv(1)

setfacl(1)

setlabel(1)

setpgrp(1)

settime(1)

sftp(1)

sh(1)

shell(1F)

shell_builtins(1)

shift(1)

shutdown(1B)

size(1)

sleep(1)

snca(1)

snmpstatus(1)

soelim(1)

sort(1)

sortbib(1)

sotruss(1)

source(1)

sparc(1)

spell(1)

spellin(1)

spline(1)

split(1)

srchtxt(1)

ssh(1)

ssh-add(1)

ssh-agent(1)

ssh-http-proxy-connect(1)

ssh-keygen(1)

ssh-keyscan(1)

ssh-socks5-proxy-connect(1)

stop(1)

strchg(1)

strconf(1)

strings(1)

strip(1)

stty(1)

stty(1B)

sum(1)

sum(1B)

sun(1)

suspend(1)

svcprop(1)

svcs(1)

switch(1)

symorder(1)

sysV-make(1)

t300(1)

t300(1B)

t300s(1)

t300s(1B)

t4013(1B)

t4014(1)

t450(1)

t450(1B)

tabs(1)

tail(1)

talk(1)

tar(1)

tbl(1)

tcopy(1)

tee(1)

tek(1)

tek(1B)

telnet(1)

test(1)

test(1B)

test(1F)

tftp(1)

time(1)

timemanp(1)

times(1)

timesysp(1)

timex(1)

tip(1)

tnfdump(1)

tnfxtract(1)

touch(1)

touch(1B)

tplot(1)

tput(1)

tr(1)

tr(1B)

trap(1)

troff(1)

true(1)

truss(1)

tset(1B)

tsort(1)

tty(1)

type(1)

typeset(1)

u370(1)

u3b(1)

u3b15(1)

u3b2(1)

u3b5(1)

ucblinks(1B)

ul(1)

ulimit(1)

umask(1)

unalias(1)

uname(1)

uncompress(1)

unexpand(1)

unget(1)

unhash(1)

unifdef(1)

uniq(1)

units(1)

unix2dos(1)

unlimit(1)

unpack(1)

unset(1)

unset(1F)

unsetenv(1)

until(1)

uptime(1)

users(1B)

uucp(1C)

uudecode(1C)

uuencode(1C)

uuglist(1C)

uulog(1C)

uuname(1C)

uupick(1C)

uustat(1C)

uuto(1C)

uux(1C)

vacation(1)

val(1)

valdate(1)

valgid(1)

valint(1)

valpath(1)

valrange(1)

valstr(1)

valtime(1)

valuid(1)

valyorn(1)

vax(1)

vc(1)

vedit(1)

ver(1)

vgrind(1)

vi(1)

view(1)

vipw(1B)

volcancel(1)

volcheck(1)

volmissing(1)

volrmmount(1)

vplot(1B)

vsig(1F)

w(1)

wait(1)

wc(1)

what(1)

whatis(1)

whence(1)

whereis(1B)

which(1)

while(1)

who(1)

whoami(1B)

whocalls(1)

whois(1)

write(1)

xargs(1)

xgettext(1)

xstr(1)

yacc(1)

yes(1)

ypcat(1)

ypmatch(1)

yppasswd(1)

ypwhich(1)

zcat(1)

zlogin(1)

zonename(1)

ld

- link-editor for object files

Synopsis

/usr/ccs/bin/ld  [-64] [-a |  -r] [-b]   [-c name] [-C]
  [-G] [-i] [-m] [-s] [-t] [-V] [-Bdirect |  nodirect] 
  [-B dynamic |  static] 
  [-B group] [-B local] [-B eliminate]
  [-B reduce] [-B symbolic] [-d y |  n] [-D token,]...
  [-e epsym] [-F name |  -f name] [-h name] [-I name] [-L path]
  [-l x] [-M mapfile] [-N string] [-o outfile] [-p auditlib]
  [-P auditlib] [-Q y |  n] [-R path] [-S supportlib]
  [-u symname] [-Y P,dirlist] [-z absexec] 
  [-z allextract | defaultextract | weakextract] [-z combreloc]
  [-z defs |  nodefs] [-z direct |  nodirect] [-z endfiltee]
  [-z finiarray=function] 
  [-z globalaudit] [-z groupperm | nogroupperm]
  [-z ignore | record] [-z initarray=function] [-z initfirst]
  [-z interpose] [-z lazyload | nolazyload]
  [-z ld32=arg1,arg2,...] [-z ld64=arg1,arg2,...]
  [-z loadfltr] [-z muldefs] [-z nocompstrtab] [-z nodefaultlib]
  [-z nodelete] [-z nodlopen] [-z nodump] [-z noldynsym]
  [-z nopartial] [-z noversion] [-z now] [-z origin]
  [-z preinitarray=function] [-z redlocsym] [-z rescan]
  [-z text |  textwarn |  textoff] [-z verbose] filename...

Description

The ld command combines relocatable object files, performs relocation, and resolves external symbols. ld operates in two modes, static or dynamic, as governed by the -d option. In all cases, the output of ld is left in a.out by default. See NOTES.

In static mode, -dn, relocatable object files that are provided as arguments are combined to produce a static executable file. If the -r option is specified, relocatable object files are combined to produce one relocatable object file. See Static Executables.

In dynamic mode, -dy, the default, relocatable object files that are provided as arguments are combined to produce an executable object file. This file is linked at execution with any shared object files that are provided as arguments. If the -G option is specified, relocatable object files are combined to produce a shared object.

If any argument is a library, ld by default searches the library exactly once at the point the library is encountered on the argument list. The library can be either a shared object or relocatable archive. See ar.h(3HEAD)).

For an archive library, ld loads only those routines that define an unresolved external reference. ld searches the symbol table of the archive library sequentially to resolve external references that can be satisfied by library members. This search is repeated until no external references can be resolved by the archive. Thus, the order of members in the library is functionally unimportant, unless multiple library members exist that define the same external symbol. Archive libraries that have interdependencies can require multiple command-line definitions, or use of the -z rescan option.

A shared object consists of an indivisible, whole unit that has been generated by a previous link-edit of one or more input files. When the link-editor processes a shared object, the entire contents of the shared object become a logical part of the resulting output file image. The shared object is not physically copied during the link-edit as its actual inclusion is deferred until process execution. This logical inclusion means that all symbol entries defined in the shared object are made available to the link-editing process.

No command-line option is required to distinguish 32–bit objects or 64–bit objects. The link-editor uses the ELF class of the first relocatable object file that is found on the command line, to govern the mode in which to operate. The mixing of 32–bit objects and 64–bit objects is not permitted. See also the -64 option and the LD_NOEXEC_64 environment variable.

Static Executables

The creation of static executables has been discouraged for many releases. In fact, 64-bit system archive libraries have never been provided. Because a static executable is built against system archive libraries, the executable contains system implementation details. This self-containment has a number of drawbacks.

With Solaris 10, 32-bit system archive libraries are no longer provided. Without these libraries, specifically libc.a, the creation of static executables is no longer achievable without specialized system knowledge. Note, that the link-editors capability to process static linking options, and the processing of archive libraries, remains unchanged.

Options

The following options are supported:

-64

Creates a 64-bit object. By default, the class of the object being generated is determined from the first ELF object processed from the command line. This option is useful when creating an object directly with ld whose input is solely from an archive library or a mapfile. See the -M option.

-a

In static mode only, produces an executable object file. Undefined references are not permitted. This option is the default behavior for static mode. -a can not be used with the -r option. See Static Executables under DESCRIPTION.

-b

In dynamic mode only, does no special processing for relocations that reference symbols in shared objects. Without the -b option, the link-editor creates special position-independent relocations for references to functions defined in shared objects. In addition, the link-editor arranges for data objects that are defined in shared objects to be copied into the memory image of an executable at runtime.

The -b option is intended for specialized dynamic objects and is not recommended for general use. Its use suppresses all specialized processing required to insure an object's shareability, and can even prevent the relocation of 64–bit executables.

-B direct | nodirect

Options governing direct binding. -B direct establishes direct binding information by recording the relationship between each symbol reference and the dependency that provides the definition. In addition, direct binding information is established between each symbol reference and an associated definition within the object being created. The runtime linker uses this information to search directly for a symbol in the associated object rather than to carry out a default symbol search.

Direct binding information can only be established to dependencies specified with the link-edit. Thus, you should use the -z defs option. Objects that wish to interpose on symbols in a direct binding environment should identify themselves as interposers with the -z interpose option. The use of -B direct enables -z lazyload for all dependencies.

-B nodirect prevents any direct binding to the interfaces offered by the object being created. The object being created can continue to directly bind to external interfaces by specifying the -z direct option.

-B dynamic | static

Options governing library inclusion. -B dynamic is valid in dynamic mode only. These options can be specified any number of times on the command line as toggles: if the -B static option is given, no shared objects are accepted until -B dynamic is seen. See also the -l option.

-B eliminate

Causes any global symbols, not assigned to a version definition, to be eliminated from the symbol table. Version definitions can be supplied by means of a mapfile to indicate the global symbols that should remain visible in the generated object. This option achieves the same symbol elimination as the auto-elimination directive that is available as part of a mapfile version definition. This option can be useful when combining versioned and non-versioned relocatable objects. See also the -B reduce option.

-B group

Establishes a shared object and its dependencies as a group. Objects within the group are bound to other members of the group at runtime. The runtime processing of an object containing this flag mimics that which occurs if the object is added to a process using dlopen(3C) with the RTLD_GROUP mode. An object that has an explicit dependency on a object identified as a group, becomes a member of the group.

As the group must be self contained, use of the -B group option also asserts the -z defs option.

-B local

Causes any global symbols, not assigned to a version definition, to be reduced to local. Version definitions can be supplied by means of a mapfile to indicate the global symbols that should remain visible in the generated object. This option achieves the same symbol reduction as the auto-reduction directive that is available as part of a mapfile version definition. This option can be useful when combining versioned and non-versioned relocatable objects. See also the -B eliminate option.

-B reduce

When generating a relocatable object, causes the reduction of symbolic information defined by any version definitions. Version definitions can be supplied by means of a mapfile to indicate the global symbols that should remain visible in the generated object. By default, when a relocatable object is generated, version definitions are only recorded in the output image. The actual reduction of symbolic information is carried out when the object is used in the construction of a dynamic executable or shared object. This option is applied automatically when a dynamic executable, or shared object is created.

-B symbolic

In dynamic mode only. When building a shared object, binds references to global symbols to their definitions, if available, within the object. Normally, references to global symbols within shared objects are not bound until runtime, even if definitions are available. This model allows definitions of the same symbol in an executable or other shared object to override the object's own definition. ld issues warnings for undefined symbols unless -z defs overrides.

The -B symbolic option is intended for specialized dynamic objects and is not recommended for general use. To reduce the runtime relocation overhead of an object, the creation of a version definition is recommended.

-c name

Records the configuration file name for use at runtime. Configuration files can be employed to alter default search paths, provide a directory cache, and provide alternative object dependencies. See crle(1).

-C

Demangles C++ symbol names displayed in diagnostic messages.

-d y | n

When -d y, the default, is specified, ld uses dynamic linking. When -d n is specified, ld uses static linking. See Static Executables under DESCRIPTION, and -B dynamic|static.

-D token,...

Prints debugging information, as specified by each token, to the standard error. The special token help indicates the full list of tokens available.

-e epsym

Sets the entry point address for the output file to be the symbol epsym.

-f name

Useful only when building a shared object. Specifies that the symbol table of the shared object is used as an auxiliary filter on the symbol table of the shared object specified by name. Multiple instances of this option are allowed. This option can not be combined with the -F option.

-F name

Useful only when building a shared object. Specifies that the symbol table of the shared object is used as a filter on the symbol table of the shared object specified by name. Multiple instances of this option are allowed. This option can not be combined with the -f option.

-G

In dynamic mode only, produces a shared object. Undefined symbols are allowed.

-h name

In dynamic mode only, when building a shared object, records name in the object's dynamic section. name is recorded in any dynamic objects that are linked with this object rather than the object's file system name. Accordingly, name is used by the runtime linker as the name of the shared object to search for at runtime.

-i

Ignores LD_LIBRARY_PATH. This option is useful when an LD_LIBRARY_PATH setting is in effect to influence the runtime library search, which would interfere with the link-editing being performed.

-I name

When building an executable, uses name as the path name of the interpreter to be written into the program header. The default in static mode is no interpreter. In dynamic mode, the default is the name of the runtime linker, ld.so.1(1). Either case can be overridden by -I name. exec(2) loads this interpreter when the a.out is loaded, and passes control to the interpreter rather than to the a.out directly.

-l x

Searches a library libx.so or libx.a, the conventional names for shared object and archive libraries, respectively. In dynamic mode, unless the -B static option is in effect, ld searches each directory specified in the library search path for a libx.so or libx.a file. The directory search stops at the first directory containing either. ld chooses the file ending in .so if -lx expands to two files with names of the form libx.so and libx.a. If no libx.so is found, then ld accepts libx.a. In static mode, or when the -B static option is in effect, ld selects only the file ending in .a. ld searches a library when the library is encountered, so the placement of -l is significant.

-L path

Adds path to the library search directories. ld searches for libraries first in any directories specified by the -L options and then in the standard directories. This option is useful only if the option precedes the -l options to which the -L option applies. The environment variable LD_LIBRARY_PATH can be used to supplement the library search path. See LD_LIBRARY_PATH under ENVIRONMENT VARIABLES.

-m

Produces a memory map or listing of the input/output sections, together with any non-fatal multiply-defined symbols, on the standard output.

-M mapfile

Reads mapfile as a text file of directives to ld. This option can be specified multiple times. If mapfile is a directory, then all regular files, as defined by stat(2), within the directory are processed. See the Linker and Libraries Guide for a description of mapfiles. Example mapfiles are provided in /usr/lib/ld. See FILES.

-N string

This option causes a DT_NEEDED entry to be added to the .dynamic section of the object being built. The value of the DT_NEEDED string is the string that is specified on the command line. This option is position dependent, and the DT_NEEDED .dynamic entry is relative to the other dynamic dependencies discovered on the link-edit line. This option is useful for specifying dependencies within device driver relocatable objects when combined with the -dy and -r options.

-o outfile

Produces an output object file that is named outfile. The name of the default object file is a.out.

-p auditlib

Identifies an audit library, auditlib. This audit library is used to audit the object being created at runtime. A shared object identified as requiring auditing with the -p option, has this requirement inherited by any object that specifies the shared object as a dependency. See the -P option.

-P auditlib

Identifies an audit library, auditlib. This audit library is used to audit the dependencies of the object being created at runtime. Dependency auditing can also be inherited from dependencies that are identified as requiring auditing. See the -p option.

-Q y | n

Under -Q y, an ident string is added to the .comment section of the output file. This string identifies the version of the link-editor used to create the file. This results in multiple ld idents when there have been multiple linking steps, such as when using ld -r. This identification is identical with the default action of the cc command. -Q n suppresses version identification.

-r

Combines relocatable object files to produce one relocatable object file. ld does not complain about unresolved references. This option cannot be used with the -a option.

-R path

A colon-separated list of directories used to specify library search directories to the runtime linker. If present and not NULL, the path is recorded in the output object file and passed to the runtime linker. Multiple instances of this option are concatenated together with each path separated by a colon.

-s

Strips symbolic information from the output file. Any debugging information, that is, .line, .debug*, and .stab* sections, and their associated relocation entries are removed. Except for relocatable files, a symbol table SHT_SYMTAB and its associated string table section are not created in the output object file. Note, the elimination of a SHT_SYMTAB symbol table can compromise the .stab* debugging information that is generate using the compiler drivers -g option. See the -z redlocsym option.

-S supportlib

The shared object supportlib is loaded with the link-editor and given information regarding the linking process. Support shared objects can also be supplied using the SGS_SUPPORT environment variable. See the Linker and Libraries Guide for more details.

-t

Turns off the warning for multiply-defined symbols that have different sizes or different alignments.

-u symname

Enters symname as an undefined symbol in the symbol table. This option is useful for loading entirely from an archive library. In this instance, an unresolved reference is needed to force the loading of the first routine. The placement of this option on the command line is significant. This option must be placed before the library that defines the symbol.

-V

Outputs a message giving information about the version of ld being used.

-Y P,dirlist

Changes the default directories used for finding libraries. dirlist is a colon-separated path list.

-z absexec

Useful only when building a dynamic executable. Specifies that references to external absolute symbols should be resolved immediately instead of being left for resolution at runtime. In very specialized circumstances, this option removes text relocations that can result in excessive swap space demands by an executable.

-z allextract | defaultextract | weakextract

Alters the extraction criteria of objects from any archives that follow. By default, archive members are extracted to satisfy undefined references and to promote tentative definitions with data definitions. Weak symbol references do not trigger extraction. Under -z allextract, all archive members are extracted from the archive. Under -z weakextract, weak references trigger archive extraction. -z defaultextract provides a means of returning to the default following use of the former extract options.

-z combreloc

Combines multiple relocation sections. Historically, relocation sections are maintained in a one-to-one relationship with the sections to which the relocations must be applied. When building an executable or shared object, ld sorts the entries of data relocation sections by their symbol reference. This sorting reduces the runtime symbol lookup. Combining multiple data relocation sections allows optimal sorting and hence the least relocation overhead when objects are loaded into memory.

-z defs | nodefs

The -z defs option forces a fatal error if any undefined symbols remain at the end of the link. This mode is the default when an executable is built. For historic reasons, this mode is not the default when building a shared object. Use of the -z defs option is recommended, as this mode assures the object being built is self-contained. A self-contained object has all symbolic references resolved internally, or to the object's immediate dependencies.

The -z nodefs option allows undefined symbols. For historic reasons, this mode is the default when a shared object is built. When used with executables, the behavior of references to such undefined symbols is unspecified. Use of the -z nodefs option is not recommended

-z direct | nodirect

Enables or disables direct binding to any dependencies that follow on the command line. These options allow finer control over direct binding than the global counterpart -B direct. The -z direct option also differs from the -B direct option in the following areas. Direct binding information is not established between a symbol reference and an associated definition within the object being created. Lazy loading is not enabled.

-z endfiltee

Marks a filtee so that when processed by a filter, the filtee terminates any further filtee searches by the filter.

-z finiarray=function

Appends an entry to the .finiarray section of the object being built. If no .finiarray section is present, a section is created. The new entry is initialized to point to function. See the Linker and Libraries Guide for more details.

-z globalaudit

This option supplements an audit library definition that has been recorded with the -P option. This option is only meaningful when building a dynamic executable. Audit libraries that are defined within an object with the -P option typically allow for the auditing of the immediate dependencies of the object. The -z globalaudit promotes the auditor to a global auditor, thus allowing the auditing of all dependencies. An auditor established with the -P option and the -z globalaudit option, is equivalent to the auditor being established with the LD_AUDIT environment variable. See ld.so.1(1).

-z groupperm | nogroupperm

Assigns, or deassigns each dependency that follows to a unique group. The assignment of a dependency to a group has the same effect as if the dependency had been built using the -B group option.

-z ignore | record

Ignores, or records, dynamic dependencies that are not referenced as part of the link-edit. Ignores, or records, unreferenced ELF sections from the relocatable objects that are read as part of the link-edit. By default, -z record is in effect.

If an ELF section is ignored, the section is eliminated from the output file being generated. A section is ignored when three conditions are true. The eliminated section must contribute to an allocatable segment. The eliminated section must provide no global symbols. No other section from any object that contributes to the link-edit, must reference an eliminated section.

-z initarray=function

Appends an entry to the .initarray section of the object being built. If no .initarray section is present, a section is created. The new entry is initialized to point to function. See the Linker and Libraries Guide for more details.

-z initfirst

Marks the object so that its runtime initialization occurs before the runtime initialization of any other objects brought into the process at the same time. In addition, the object runtime finalization occurs after the runtime finalization of any other objects removed from the process at the same time. This option is only meaningful when building a shared object.

-z interpose

Marks the object as an interposer. When direct bindings are in effect, the runtime linker searchs for symbols in any interposers before the object associated to the direct binding. See -B direct.

-z lazyload | nolazyload

Enables or disables the marking of dynamic dependencies to be lazily loaded. Dynamic dependencies which are marked lazyload are not loaded at initial process start-up. These dependencies are delayed until the first binding to the object is made. Note: Lazy loading requires the correct declaration of dependencies, and associated runpaths for each dynamic object used within a process. See the Linker and Libraries Guide for more details.

-z ld32=arg1,arg2,...
-z ld64=arg1,arg2,...

The class of the link-editor is affected by the class of the output file being created and by the capabilities of the underlying operating system. This option provides a means of defining any link-editor argument, so that the argument is only interpreted, respectively, by the 32–bit class or 64–bit class of the link-editor.

For example, support libraries are class specific, so the correct class of support library can be insured using:

ld ... -z ld32=-Saudit32.so.1 -z ld64=-Saudit64.so.1 ...

Note: The class of link-editor that is invoked is determined from the ELF class of the first input relocatable file that is seen on the command line. This determination is carried out prior to any -z ld[32|64] processing.

-z loadfltr

Marks a filter to indicate that filtees must be processed immediately at runtime. Normally, filter processing is delayed until a symbol reference is bound to the filter. The runtime processing of an object that contains this flag mimics that which occurs if the LD_LOADFLTR environment variable is in effect. See the ld.so.1(1).

-z muldefs

Allows multiple symbol definitions. By default, multiple symbol definitions that occur between relocatable objects result in a fatal error condition. This option, suppresses the error condition, allowing the first symbol definition to be taken.

-z nocompstrtab

Disables the compression of ELF string tables.

-z nodefaultlib

Marks the object so that the runtime default library search path, used after any LD_LIBRARY_PATH or runpaths, is ignored. This option implies that all dependencies of the object can be satisfied from its runpath.

-z nodelete

Marks the object as non-deletable at runtime. The runtime processing of an object that contains this flag mimics that which occurs if the object is added to a process using dlopen(3C) with the RTLD_NODELETE mode.

-z nodlopen

Marks the object as not available to dlopen(3C), either as the object specified by the dlopen(), or as any form of dependency required by the object specified by the dlopen(). This option is only meaningful when building a shared object.

-z nodump

Marks the object as not available to dldump(3C).

-z nopartial

Partially initialized symbols, that are defined within the input relocatable object files, are expanded in the output file being generated.

-z noversion

Does not record any versioning sections. Any version sections or associated .dynamic section entries are not generated in the output image.

-z now

Marks the object as requiring non-lazy runtime binding. This mode is similar to adding the object to the process by using dlopen(3C) with the RTLD_NOW mode, or having the LD_BIND_NOW environment variable in effect. See the ld.so.1(1).

-z origin

Marks the object as requiring immediate $ORIGIN processing at runtime. This option is only maintained for historic compatibility, as the runtime analysis of objects to provide for $ORIGIN processing is now default.

-z preinitarray=function

Appends an entry to the .preinitarray section of the object being built. If no .preinitarray section is present, a section is created. The new entry is initialized to point to function. See the Linker and Libraries Guide for more details.

-z redlocsym

Eliminates all local symbols except for the SECT symbols from the symbol table SHT_SYMTAB. All relocations that refer to local symbols are updated to refer to the corresponding SECT symbol. This option allows specialized objects to greatly reduce their symbol table sizes. Note, eliminated local symbols can compromise the .stab* debugging information that is generate using the compiler drivers -g option. See the -s option.

-z rescan

Rescans the archive files that are provided to the link-edit. By default, archives are processed once as the archives appear on the command line. Archives are traditionally specified at the end of the command line so that their symbol definitions resolve any preceding references. However, specifying archives multiple times to satisfy their own interdependencies, can be necessary.

The -z rescan option causes the entire archive list to be reprocessed in an attempt to locate additional archive members that resolve symbol references. This archive rescanning continues until a pass over the archive list occurs in which no new members are extracted.

-z text

In dynamic mode only, forces a fatal error if any relocations against non-writable, allocatable sections remain. For historic reasons, this mode is not the default when building an executable or shared object. However, its use is recommended to insure that the text segment of the dynamic object being built is shareable between multiple running processes. A shared text segment incurs the least relocation overhead when loaded into memory.

-z textoff

In dynamic mode only, allows relocations against all allocatable sections, including non-writable ones. This mode is the default when building a shared object.

-z textwarn

In dynamic mode only, lists a warning if any relocations against non-writable, allocatable sections remain. This mode is the default when building an executable.

-z verbose

This option provides additional warning diagnostics during a link-edit. Presently, this option conveys suspicious use of displacement relocation. In future, this option might be enhanced to provide additional diagnostics that are deemed too noisy to be generated by default.

Environment Variables

LD_LIBRARY_PATH

A list of directories in which to search for the libraries specified using the -l option. Multiple directories are separated by a colon. In the most general case, this environment variable contains two directory lists separated by a semicolon:

dirlist1;dirlist2

If ld is called with any number of occurrences of -L, as in:

ld ... -Lpath1 ... -Lpathn ...

then the search path ordering is:

dirlist1 path1 ... pathn dirlist2 LIBPATH

When the list of directories does not contain a semicolon, the list is interpreted as dirlist2.

The LD_LIBRARY_PATH environment variable also affects the runtime linkers search for dynamic dependencies.

This environment variable can be specified with a _32 or _64 suffix. This makes the environment variable specific, respectively, to 32-bit or 64-bit processes and overrides any non-suffixed version of the environment variable that is in effect.

LD_NOEXEC_64

Suppresses the automatic execution of the 64-bit link-editor. By default, the link-editor executes the 64-bit version when the ELF class of the first input relocatable file identifies a 64-bit object. The 64–bit image that a 32–bit link-editor can create, has some limitations. However, some link-edits might find the use of the 32–bit link-editor faster.

LD_OPTIONS

A default set of options to ld. LD_OPTIONS is interpreted by ld just as though its value had been placed on the command line, immediately following the name used to invoke ld, as in:

ld $LD_OPTIONS ... other-arguments ...
LD_RUN_PATH

An alternative mechanism for specifying a runpath to the link-editor. See the -R option. If both LD_RUN_PATH and the -R option are specified, -R supersedes.

SGS_SUPPORT

Provides a colon-separated list of shared objects that are loaded with the link-editor and given information regarding the linking process. This environment variable can be specified with a _32 or _64 suffix. This makes the environment variable specific, respectively, to the 32-bit or 64-bit class of ld and overrides any non-suffixed version of the environment variable that is in effect. See the -S option.

Notice that environment variable-names that begin with the characters 'LD_' are reserved for possible future enhancements to ld and ld.so.1(1).

Files

libx.so

shared object libraries.

libx.a

archive libraries.

a.out

default output file.

LIBPATH

For 32–bit libraries, the default search path is /usr/ccs/lib, followed by /lib, and finally /usr/lib. For 64-bit libraries, the default search path is /lib/64, followed by /usr/lib/64.

/usr/lib/ld

A directory containing several mapfiles that can be used during link-editing. These mapfiles provide various capabilities, such as defining memory layouts, aligning bss, and defining non-executable stacks.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
SUNWtoo

See Also

as(1), crle(1), gprof(1), ld.so.1(1), pvs(1), exec(2), stat(2), dlopen(3C), dldump(3C), elf(3ELF), ar.h(3HEAD), a.out(4), attributes(5)

Linker and Libraries Guide

Notes

Default options applied by ld are maintained for historic reasons. In today's programming environment, where dynamic objects dominate, alternative defaults would often make more sense. However, historic defaults must be maintained to insure compatibility with existing program development environments. Historic defaults are called out wherever possible in this manual. For a description of the current recommended options, see the Link-Editor Quick Reference in the Linker and Libraries Guide.

If the file being created by ld already exists, the file is truncated after all input files have been processed. The existing file is overridden with the new file contents. ld does not create a temporary file as part of the link-edit, since multiple instances of large output files frequently exhaust system resources. The drawback of overriding an existing file occurs if the file is in use by a running process. In this case, the process might be prematurely terminated as the output files image is created. This situation can be avoided by removing the output file before performing the link-edit. This removal is not detrimental to the running process. The removal frees up the file system namespace, not the actual disk space, for the new output file creation. The disk space of a removed file is freed when the last process referencing the file terminates.