xref: /illumos-gate/usr/src/man/man1/ld.1 (revision 63f6f57b9c12b68feed7eb52a4d31b7afb0c0906)
1*63f6f57bSAndy Fiddaman.\"
2*63f6f57bSAndy Fiddaman.\" The contents of this file are subject to the terms of the
3*63f6f57bSAndy Fiddaman.\" Common Development and Distribution License (the "License").
4*63f6f57bSAndy Fiddaman.\" You may not use this file except in compliance with the License.
5*63f6f57bSAndy Fiddaman.\"
6*63f6f57bSAndy Fiddaman.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7*63f6f57bSAndy Fiddaman.\" or http://www.opensolaris.org/os/licensing.
8*63f6f57bSAndy Fiddaman.\" See the License for the specific language governing permissions
9*63f6f57bSAndy Fiddaman.\" and limitations under the License.
10*63f6f57bSAndy Fiddaman.\"
11*63f6f57bSAndy Fiddaman.\" When distributing Covered Code, include this CDDL HEADER in each
12*63f6f57bSAndy Fiddaman.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
13*63f6f57bSAndy Fiddaman.\" If applicable, add the following below this CDDL HEADER, with the
14*63f6f57bSAndy Fiddaman.\" fields enclosed by brackets "[]" replaced with your own identifying
15*63f6f57bSAndy Fiddaman.\" information: Portions Copyright [yyyy] [name of copyright owner]
16*63f6f57bSAndy Fiddaman.\"
17c10c16deSRichard Lowe.\" Copyright 1989 AT&T
18c10c16deSRichard Lowe.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
1905a20ab1SRobert Mustacchi.\" Copyright 2019 Joyent, Inc.
20012e6ce7SDan Cross.\" Copyright 2023 Oxide Computer Company
21*63f6f57bSAndy Fiddaman.\" Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
22*63f6f57bSAndy Fiddaman.\"
23*63f6f57bSAndy Fiddaman.Dd January 15, 2024
24*63f6f57bSAndy Fiddaman.Dt LD 1
25*63f6f57bSAndy Fiddaman.Os
26*63f6f57bSAndy Fiddaman.Sh NAME
27*63f6f57bSAndy Fiddaman.Nm ld
28*63f6f57bSAndy Fiddaman.Nd link-editor for object files
29*63f6f57bSAndy Fiddaman.Sh SYNOPSIS
30*63f6f57bSAndy Fiddaman.Nm
31*63f6f57bSAndy Fiddaman.Op Fl 32 | 64
32*63f6f57bSAndy Fiddaman.Op Fl a | r
33*63f6f57bSAndy Fiddaman.Op Fl b
34*63f6f57bSAndy Fiddaman.Op Fl B Cm direct | Fl B Cm nodirect
35*63f6f57bSAndy Fiddaman.Op Fl B Cm dynamic | Fl B Cm static
36*63f6f57bSAndy Fiddaman.Op Fl B Cm eliminate
37*63f6f57bSAndy Fiddaman.Op Fl B Cm group
38*63f6f57bSAndy Fiddaman.Op Fl B Cm local
39*63f6f57bSAndy Fiddaman.Op Fl B Cm reduce
40*63f6f57bSAndy Fiddaman.Op Fl B Cm symbolic
41*63f6f57bSAndy Fiddaman.Op Fl c Ar name
42*63f6f57bSAndy Fiddaman.Op Fl C
43*63f6f57bSAndy Fiddaman.Op Fl d Cm y | Fl d Cm n
44*63f6f57bSAndy Fiddaman.Op Fl D Ar token Ns No ,...
45*63f6f57bSAndy Fiddaman.Op Fl e Ar epsym
46*63f6f57bSAndy Fiddaman.Op Fl f Ar name | Fl F Ar name
47*63f6f57bSAndy Fiddaman.Op Fl G
48*63f6f57bSAndy Fiddaman.Op Fl h Ar name
49*63f6f57bSAndy Fiddaman.Op Fl i
50*63f6f57bSAndy Fiddaman.Op Fl I Ar name
51*63f6f57bSAndy Fiddaman.Op Fl l Ar x
52*63f6f57bSAndy Fiddaman.Op Fl L Ar path
53*63f6f57bSAndy Fiddaman.Op Fl m
54*63f6f57bSAndy Fiddaman.Op Fl M Ar mapfile
55*63f6f57bSAndy Fiddaman.Op Fl N Ar string
56*63f6f57bSAndy Fiddaman.Op Fl o Ar outfile
57*63f6f57bSAndy Fiddaman.Op Fl p Ar auditlib
58*63f6f57bSAndy Fiddaman.Op Fl P Ar auditlib
59*63f6f57bSAndy Fiddaman.Op Fl Q Cm y | Fl Q Cm n
60*63f6f57bSAndy Fiddaman.Op Fl R Ar path
61*63f6f57bSAndy Fiddaman.Op Fl s
62*63f6f57bSAndy Fiddaman.Op Fl S Ar supportlib
63*63f6f57bSAndy Fiddaman.Op Fl t
64*63f6f57bSAndy Fiddaman.Op Fl u Ar symname
65*63f6f57bSAndy Fiddaman.Op Fl V
66*63f6f57bSAndy Fiddaman.Op Fl Y Cm P Ns \&, Ns Ar dirlist
67*63f6f57bSAndy Fiddaman.Op Fl z Cm absexec
68*63f6f57bSAndy Fiddaman.Op Fl z Cm allextract | Fl z Cm defaultextract | Fl z Cm weakextract
69*63f6f57bSAndy Fiddaman.Op Fl z Cm altexec64
70*63f6f57bSAndy Fiddaman.Op Fl z Cm aslr Ns Op Cm \&= Ns Ar state
71*63f6f57bSAndy Fiddaman.Op Fl z Cm assert-deflib
72*63f6f57bSAndy Fiddaman.Op Fl z Cm assert-deflib= Ns Ar libname
73*63f6f57bSAndy Fiddaman.Op Fl z Cm combreloc | Fl z Cm nocombreloc
74*63f6f57bSAndy Fiddaman.Op Fl z Cm defs | Fl z Cm nodefs
75*63f6f57bSAndy Fiddaman.Op Fl z Cm direct | Fl z Cm nodirect
76*63f6f57bSAndy Fiddaman.Op Fl z Cm endfiltee
77*63f6f57bSAndy Fiddaman.Op Fl z Cm fatal-warnings | Fl z Cm nofatal-warnings
78*63f6f57bSAndy Fiddaman.Op Fl z Cm finiarray= Ns Ar function
79*63f6f57bSAndy Fiddaman.Op Fl z Cm globalaudit
80*63f6f57bSAndy Fiddaman.Op Fl z Cm groupperm | nogroupperm
81*63f6f57bSAndy Fiddaman.Op Fl z Cm guidance Ns Op Cm \&= Ns Ar id Ns No \&,...
82*63f6f57bSAndy Fiddaman.Op Fl z Cm help
83*63f6f57bSAndy Fiddaman.Op Fl z Cm ignore | Fl z Cm record
84*63f6f57bSAndy Fiddaman.Op Fl z Cm initarray= Ns Ar function
85*63f6f57bSAndy Fiddaman.Op Fl z Cm initfirst
86*63f6f57bSAndy Fiddaman.Op Fl z Cm interpose
87*63f6f57bSAndy Fiddaman.Op Fl z Cm lazyload | Fl z Cm nolazyload
88*63f6f57bSAndy Fiddaman.Op Fl z Cm ld32= Ns Ar arg Ns No \&,...
89*63f6f57bSAndy Fiddaman.Op Fl z Cm ld64= Ns Ar arg Ns No \&,...
90*63f6f57bSAndy Fiddaman.Op Fl z Cm loadfltr
91*63f6f57bSAndy Fiddaman.Op Fl z Cm muldefs
92*63f6f57bSAndy Fiddaman.Op Fl z Cm nocompstrtab
93*63f6f57bSAndy Fiddaman.Op Fl z Cm nodefaultlib
94*63f6f57bSAndy Fiddaman.Op Fl z Cm nodelete
95*63f6f57bSAndy Fiddaman.Op Fl z Cm nodlopen
96*63f6f57bSAndy Fiddaman.Op Fl z Cm nodump
97*63f6f57bSAndy Fiddaman.Op Fl z Cm noldynsym
98*63f6f57bSAndy Fiddaman.Op Fl z Cm nopartial
99*63f6f57bSAndy Fiddaman.Op Fl z Cm noversion
100*63f6f57bSAndy Fiddaman.Op Fl z Cm now
101*63f6f57bSAndy Fiddaman.Op Fl z Cm origin
102*63f6f57bSAndy Fiddaman.Op Fl z Cm preinitarray= Ns Ar function
103*63f6f57bSAndy Fiddaman.Op Fl z Cm redlocsym
104*63f6f57bSAndy Fiddaman.Op Fl z Cm relaxreloc
105*63f6f57bSAndy Fiddaman.Op Fl z Cm rescan
106*63f6f57bSAndy Fiddaman.Op Fl z Cm rescan-now
107*63f6f57bSAndy Fiddaman.Op Fl z Cm rescan-start \&... Fl z Cm rescan-end
108*63f6f57bSAndy Fiddaman.Op Fl z Cm symbolcap
109*63f6f57bSAndy Fiddaman.Op Fl z Cm target= Ns Cm sparc Ns | Ns Cm x86
110*63f6f57bSAndy Fiddaman.Op Fl z Cm text | Fl z Cm textwarn | Fl z Cm textoff
111*63f6f57bSAndy Fiddaman.Sm off
112*63f6f57bSAndy Fiddaman.Op Fl z\~ Cm type= Cm exec | kmod | reloc | shared
113*63f6f57bSAndy Fiddaman.Sm on
114*63f6f57bSAndy Fiddaman.Op Fl z Cm verbose
115*63f6f57bSAndy Fiddaman.Op Fl z Cm wrap= Ns Ar symbol
116*63f6f57bSAndy Fiddaman.Ar filename Ns No \&...
117*63f6f57bSAndy Fiddaman.Sh DESCRIPTION
118*63f6f57bSAndy FiddamanThe link-editor,
119*63f6f57bSAndy Fiddaman.Nm ,
120*63f6f57bSAndy Fiddamancombines relocatable object files by resolving symbol references to symbol
121*63f6f57bSAndy Fiddamandefinitions, together with performing relocations.
122*63f6f57bSAndy Fiddaman.Nm
123*63f6f57bSAndy Fiddamanoperates in two modes, static or dynamic, as governed by the
124*63f6f57bSAndy Fiddaman.Fl d
125*63f6f57bSAndy Fiddamanoption.
126*63f6f57bSAndy FiddamanIn all cases, the output of
127*63f6f57bSAndy Fiddaman.Nm
128*63f6f57bSAndy Fiddamanis left in the file
129*63f6f57bSAndy Fiddaman.Pa a.out
130*63f6f57bSAndy Fiddamanby default.
131*63f6f57bSAndy FiddamanSee
132*63f6f57bSAndy Fiddaman.Sx NOTES .
133*63f6f57bSAndy Fiddaman.Pp
134*63f6f57bSAndy FiddamanIn dynamic mode,
135*63f6f57bSAndy Fiddaman.Fl d Cm y ,
136*63f6f57bSAndy Fiddamanthe default, relocatable object files that are provided as arguments are
137*63f6f57bSAndy Fiddamancombined to produce an executable object file.
138*63f6f57bSAndy FiddamanThis file is linked at execution with any shared object files that are provided
139*63f6f57bSAndy Fiddamanas arguments.
140*63f6f57bSAndy FiddamanIf the
141*63f6f57bSAndy Fiddaman.Fl G
142*63f6f57bSAndy Fiddamanoption is specified, relocatable object files are combined to produce a shared
143*63f6f57bSAndy Fiddamanobject.
144*63f6f57bSAndy FiddamanWithout the
145*63f6f57bSAndy Fiddaman.Fl G
146*63f6f57bSAndy Fiddamanoption, a dynamic executable is created.
147*63f6f57bSAndy Fiddaman.Pp
148*63f6f57bSAndy FiddamanIn static mode,
149*63f6f57bSAndy Fiddaman.Fl d Cm n ,
150*63f6f57bSAndy Fiddamanrelocatable object files that are provided as arguments are combined to produce
151*63f6f57bSAndy Fiddamana static executable file.
152*63f6f57bSAndy FiddamanIf the
153*63f6f57bSAndy Fiddaman.Fl r
154c10c16deSRichard Loweoption is specified, relocatable object files are combined to produce one
155*63f6f57bSAndy Fiddamanrelocatable object file.
156*63f6f57bSAndy FiddamanSee
157*63f6f57bSAndy Fiddaman.Sx Static Executables .
158*63f6f57bSAndy Fiddaman.Pp
159c10c16deSRichard LoweDynamic linking is the most common model for combining relocatable objects, and
160*63f6f57bSAndy Fiddamanthe eventual creation of processes within illumos.
161*63f6f57bSAndy FiddamanThis environment tightly couples the work of the link-editor and the runtime
162*63f6f57bSAndy Fiddamanlinker,
163*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 .
164c10c16deSRichard LoweBoth of these utilities, together with their related technologies and
165*63f6f57bSAndy Fiddamanutilities, are extensively documented in the
166*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
167*63f6f57bSAndy Fiddaman.Pp
168*63f6f57bSAndy FiddamanIf any argument is a library,
169*63f6f57bSAndy Fiddaman.Nm
170*63f6f57bSAndy Fiddamanby default searches the library exactly once at the point the library is
171*63f6f57bSAndy Fiddamanencountered on the argument list.
172*63f6f57bSAndy FiddamanThe library can be either a shared object or relocatable archive.
173*63f6f57bSAndy FiddamanSee
174*63f6f57bSAndy Fiddaman.Xr ar.h 3HEAD .
175*63f6f57bSAndy Fiddaman.Pp
176c10c16deSRichard LoweA shared object consists of an indivisible, whole unit that has been generated
177*63f6f57bSAndy Fiddamanby a previous link-edit of one or more input files.
178*63f6f57bSAndy FiddamanWhen the link-editor processes a shared object, the entire contents of the
179*63f6f57bSAndy Fiddamanshared object become a logical part of the resulting output file image.
180*63f6f57bSAndy FiddamanThe shared object is not physically copied during the link-edit as its actual
181*63f6f57bSAndy Fiddamaninclusion is deferred until process execution.
182*63f6f57bSAndy FiddamanThis logical inclusion means that all symbol entries defined in the shared
183*63f6f57bSAndy Fiddamanobject are made available to the link-editing process.
184*63f6f57bSAndy FiddamanSee Chapter 4,
185*63f6f57bSAndy Fiddaman.Em Shared Objects ,
186*63f6f57bSAndy Fiddamanin
187*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
188*63f6f57bSAndy Fiddaman.Pp
189*63f6f57bSAndy FiddamanFor an archive library,
190*63f6f57bSAndy Fiddaman.Nm
191*63f6f57bSAndy Fiddamanloads only those routines that define an unresolved external reference.
192*63f6f57bSAndy Fiddaman.Nm
193*63f6f57bSAndy Fiddamansearches the symbol table of the archive library sequentially to resolve
194*63f6f57bSAndy Fiddamanexternal references that can be satisfied by library members.
195*63f6f57bSAndy FiddamanThis search is repeated until no external references can be resolved by the
196*63f6f57bSAndy Fiddamanarchive.
197*63f6f57bSAndy FiddamanThus, the order of members in the library is functionally unimportant, unless
198*63f6f57bSAndy Fiddamanmultiple library members exist that define the same external symbol.
199*63f6f57bSAndy FiddamanArchive libraries that have interdependencies can require multiple command line
200*63f6f57bSAndy Fiddamandefinitions, or the use of one of the
201*63f6f57bSAndy Fiddaman.Fl z Cm rescan
202*63f6f57bSAndy Fiddamanoptions.
203*63f6f57bSAndy FiddamanSee
204*63f6f57bSAndy Fiddaman.Em Archive Processing
205*63f6f57bSAndy Fiddamanin
206*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
207*63f6f57bSAndy Fiddaman.Pp
208*63f6f57bSAndy Fiddaman.Nm
209*63f6f57bSAndy Fiddamanis a cross link-editor, able to link 32-bit objects or 64-bit objects, for
210*63f6f57bSAndy FiddamanSparc or x86 targets.
211*63f6f57bSAndy Fiddaman.Nm
212*63f6f57bSAndy Fiddamanuses the
213*63f6f57bSAndy Fiddaman.Sy ELF
214*63f6f57bSAndy Fiddamanclass and machine type of the first relocatable object on the command line to
215*63f6f57bSAndy Fiddamangovern the mode in which to operate.
216*63f6f57bSAndy FiddamanThe mixing of 32-bit objects and 64-bit objects is not permitted.
217*63f6f57bSAndy FiddamanSimilarly, only objects of a single machine type are allowed.
218*63f6f57bSAndy FiddamanSee the
219*63f6f57bSAndy Fiddaman.Fl 32 ,
220*63f6f57bSAndy Fiddaman.Fl 64
221*63f6f57bSAndy Fiddamanand
222*63f6f57bSAndy Fiddaman.Fl z Cm target
223*63f6f57bSAndy Fiddamanoptions, and the
224*63f6f57bSAndy Fiddaman.Ev LD_NOEXEC_64
225c10c16deSRichard Loweenvironment variable.
226*63f6f57bSAndy Fiddaman.Ss Static Executables
227*63f6f57bSAndy FiddamanThe creation of static executables is discouraged.
228*63f6f57bSAndy FiddamanSince a static executable is built against system archive libraries, the
229*63f6f57bSAndy Fiddamanexecutable contains system implementation details.
230*63f6f57bSAndy FiddamanThis self-containment has a number of drawbacks.
231*63f6f57bSAndy Fiddaman.Bl -bullet -offset 4n
232*63f6f57bSAndy Fiddaman.It
233bec2e3ffSPeter TribbleThe executable is immune to the benefits of system updates delivered as shared
234*63f6f57bSAndy Fiddamanobjects.
235*63f6f57bSAndy FiddamanThe executable therefore, must be rebuilt to take advantage of many system
236*63f6f57bSAndy Fiddamanimprovements.
237*63f6f57bSAndy Fiddaman.It
238c10c16deSRichard LoweThe ability of the executable to run on future releases can be compromised.
239*63f6f57bSAndy Fiddaman.It
240c10c16deSRichard LoweThe duplication of system implementation details negatively affects system
241c10c16deSRichard Loweperformance.
242*63f6f57bSAndy Fiddaman.El
243*63f6f57bSAndy Fiddaman.Pp
244*63f6f57bSAndy FiddamanOn illumos, system archive libraries
245*63f6f57bSAndy Fiddaman.Po
246*63f6f57bSAndy Fiddamansuch as
247*63f6f57bSAndy Fiddaman.Pa libc.a
248*63f6f57bSAndy Fiddaman.Pc
249*63f6f57bSAndy Fiddamanhave never been provided.
250*63f6f57bSAndy FiddamanWithout these libraries, the creation of static executables is not achievable
251*63f6f57bSAndy Fiddamanwithout specialized system knowledge.
252*63f6f57bSAndy FiddamanHowever, the capability of
253*63f6f57bSAndy Fiddaman.Nm
254*63f6f57bSAndy Fiddamanto process static linking options, and the processing of archive libraries,
255*63f6f57bSAndy Fiddamanremains.
256*63f6f57bSAndy Fiddaman.Sh OPTIONS
257c10c16deSRichard LoweThe following options are supported.
258*63f6f57bSAndy Fiddaman.Pp
259*63f6f57bSAndy Fiddaman.Bl -tag -width 4n -compact
260*63f6f57bSAndy Fiddaman.It Fl 32 | 64
261c10c16deSRichard LoweCreates a 32-bit, or 64-bit object.
262*63f6f57bSAndy Fiddaman.Pp
263c10c16deSRichard LoweBy default, the class of the object being generated is determined from the
264*63f6f57bSAndy Fiddamanfirst
265*63f6f57bSAndy Fiddaman.Sy ELF
266*63f6f57bSAndy Fiddamanobject processed from the command line.
267*63f6f57bSAndy FiddamanIf no objects are specified, the class is determined by the first object
268*63f6f57bSAndy Fiddamanencountered within the first archive processed from the command line.
269*63f6f57bSAndy FiddamanIf there are no objects or archives, the link-editor creates a 32-bit object.
270*63f6f57bSAndy Fiddaman.Pp
271*63f6f57bSAndy FiddamanThe
272*63f6f57bSAndy Fiddaman.Fl 64
273*63f6f57bSAndy Fiddamanoption is required to create a 64-bit object solely from a mapfile.
274*63f6f57bSAndy Fiddaman.Pp
275*63f6f57bSAndy FiddamanThe
276*63f6f57bSAndy Fiddaman.Fl 32
277*63f6f57bSAndy Fiddamanor
278*63f6f57bSAndy Fiddaman.Fl 64
279*63f6f57bSAndy Fiddamanoptions can also be used in the rare case of linking entirely from an archive
280*63f6f57bSAndy Fiddamanthat contains a mixture of 32 and 64-bit objects.
281*63f6f57bSAndy FiddamanIf the first object in the archive is not the class of the object that is
282*63f6f57bSAndy Fiddamanrequired to be created, then the
283*63f6f57bSAndy Fiddaman.Fl 32
284*63f6f57bSAndy Fiddamanor
285*63f6f57bSAndy Fiddaman.Fl 64
286*63f6f57bSAndy Fiddamanoption can be used to direct the link-editor.
287*63f6f57bSAndy FiddamanSee
288*63f6f57bSAndy Fiddaman.Em The 32-bit link-editor and 64-bit link-editor
289*63f6f57bSAndy Fiddamanin
290*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
291*63f6f57bSAndy Fiddaman.Pp
292*63f6f57bSAndy FiddamanNote that for compatibility with existing Makefiles and scripts, these options
293012e6ce7SDan Crossmay be given multiple times and may be mixed in the same invocation: the last
294*63f6f57bSAndy Fiddamaninstance wins, so that, for example,
295*63f6f57bSAndy Fiddaman.Ql ld -64 -32 -64 \&...
296*63f6f57bSAndy Fiddamangives 64-bit output.
297*63f6f57bSAndy Fiddaman.Pp
298*63f6f57bSAndy Fiddaman.It Fl a
299*63f6f57bSAndy FiddamanIn static mode only, produces an executable object file.
300*63f6f57bSAndy FiddamanUndefined references are not permitted.
301*63f6f57bSAndy FiddamanThis option is the default behavior for static mode.
302*63f6f57bSAndy FiddamanThe
303*63f6f57bSAndy Fiddaman.Fl a
304*63f6f57bSAndy Fiddamanoption can not be used with the
305*63f6f57bSAndy Fiddaman.Fl r
306c10c16deSRichard Loweoption.
307*63f6f57bSAndy FiddamanSee
308*63f6f57bSAndy Fiddaman.Sx Static Executables
309*63f6f57bSAndy Fiddaman.Pp
310*63f6f57bSAndy Fiddaman.It Fl b
311*63f6f57bSAndy FiddamanIn dynamic mode only, provides no special processing for dynamic executable
312*63f6f57bSAndy Fiddamanrelocations that reference symbols in shared objects.
313*63f6f57bSAndy FiddamanWithout the
314*63f6f57bSAndy Fiddaman.Fl b
315*63f6f57bSAndy Fiddamanoption, the link-editor applies techniques within a dynamic executable so that
316*63f6f57bSAndy Fiddamanthe text segment can remain read-only.
317*63f6f57bSAndy FiddamanOne technique is the creation of special position-independent relocations for
318*63f6f57bSAndy Fiddamanreferences to functions that are defined in shared objects.
319*63f6f57bSAndy FiddamanAnother technique arranges for data objects that are defined in shared objects
320*63f6f57bSAndy Fiddamanto be copied into the memory image of an executable at runtime.
321*63f6f57bSAndy Fiddaman.Pp
322*63f6f57bSAndy FiddamanThe
323*63f6f57bSAndy Fiddaman.Fl b
324*63f6f57bSAndy Fiddamanoption is intended for specialized dynamic objects and is not recommended for
325*63f6f57bSAndy Fiddamangeneral use.
326*63f6f57bSAndy FiddamanIts use suppresses all specialized processing required to ensure an object's
327*63f6f57bSAndy Fiddamanshareability, and can even prevent the relocation of 64-bit executables.
328*63f6f57bSAndy Fiddaman.Pp
329*63f6f57bSAndy Fiddaman.It Fl B Cm direct | Fl B Cm nodirect
330*63f6f57bSAndy FiddamanThese options govern direct binding.
331*63f6f57bSAndy Fiddaman.Fl B Cm direct
332*63f6f57bSAndy Fiddamanestablishes direct binding information by recording the relationship between
333*63f6f57bSAndy Fiddamaneach symbol reference together with the dependency that provides the
334*63f6f57bSAndy Fiddamandefinition.
335*63f6f57bSAndy FiddamanIn addition, direct binding information is established between each symbol
336*63f6f57bSAndy Fiddamanreference and an associated definition within the object being created.
337*63f6f57bSAndy FiddamanThe runtime linker uses this information to search directly for a symbol in the
338*63f6f57bSAndy Fiddamanassociated object rather than to carry out a default symbol search.
339*63f6f57bSAndy Fiddaman.Pp
340*63f6f57bSAndy FiddamanDirect binding information can only be established to dependencies specified
341*63f6f57bSAndy Fiddamanwith the link-edit.
342*63f6f57bSAndy FiddamanThus, you should use the
343*63f6f57bSAndy Fiddaman.Fl z Cm defs
344*63f6f57bSAndy Fiddamanoption.
345*63f6f57bSAndy FiddamanObjects that wish to interpose on symbols in a direct binding environment
346*63f6f57bSAndy Fiddamanshould identify themselves as interposers with the
347*63f6f57bSAndy Fiddaman.Fl z Cm interpose
348*63f6f57bSAndy Fiddamanoption.
349*63f6f57bSAndy FiddamanThe use of
350*63f6f57bSAndy Fiddaman.Fl B Cm direct
351*63f6f57bSAndy Fiddamanenables
352*63f6f57bSAndy Fiddaman.Fl z Cm lazyload
353*63f6f57bSAndy Fiddamanfor all dependencies.
354*63f6f57bSAndy Fiddaman.Pp
355*63f6f57bSAndy FiddamanThe
356*63f6f57bSAndy Fiddaman.Fl B Cm nodirect
357*63f6f57bSAndy Fiddamanoption prevents any direct binding to the interfaces offered by the object
358*63f6f57bSAndy Fiddamanbeing created.
359*63f6f57bSAndy FiddamanThe object being created can continue to directly bind to external interfaces
360*63f6f57bSAndy Fiddamanby specifying the
361*63f6f57bSAndy Fiddaman.Fl z Cm direct
362*63f6f57bSAndy Fiddamanoption.
363*63f6f57bSAndy FiddamanSee Appendix D,
364*63f6f57bSAndy Fiddaman.Em Direct Bindings ,
365*63f6f57bSAndy Fiddamanin
366*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
367*63f6f57bSAndy Fiddaman.Pp
368*63f6f57bSAndy Fiddaman.It Fl B Cm dynamic | Fl B Cm static
369*63f6f57bSAndy FiddamanOptions governing library inclusion.
370*63f6f57bSAndy Fiddaman.Fl B Cm dynamic
371*63f6f57bSAndy Fiddamanis valid in dynamic mode only.
372*63f6f57bSAndy FiddamanThese options can be specified any number of times on the command line as
373*63f6f57bSAndy Fiddamantoggles: if the
374*63f6f57bSAndy Fiddaman.Fl B Cm static
375*63f6f57bSAndy Fiddamanoption is given, no shared objects are accepted until
376*63f6f57bSAndy Fiddaman.Fl B Cm dynamic
377*63f6f57bSAndy Fiddamanis seen.
378*63f6f57bSAndy FiddamanSee the
379*63f6f57bSAndy Fiddaman.Fl l
380*63f6f57bSAndy Fiddamanoption.
381*63f6f57bSAndy Fiddaman.Pp
382*63f6f57bSAndy Fiddaman.It Fl B Cm eliminate
383c10c16deSRichard LoweCauses any global symbols, not assigned to a version definition, to be
384*63f6f57bSAndy Fiddamaneliminated from the symbol table.
385*63f6f57bSAndy FiddamanVersion definitions can be supplied by means of a
386*63f6f57bSAndy Fiddaman.Sy mapfile
387*63f6f57bSAndy Fiddamanto indicate the global symbols that should remain visible in the generated
388*63f6f57bSAndy Fiddamanobject.
389*63f6f57bSAndy FiddamanThis option achieves the same symbol elimination as the
390*63f6f57bSAndy Fiddaman.Em auto-elimination
391*63f6f57bSAndy Fiddamandirective that is available as part of a mapfile version definition.
392*63f6f57bSAndy FiddamanThis option can be useful when combining versioned and non-versioned
393*63f6f57bSAndy Fiddamanrelocatable objects.
394*63f6f57bSAndy FiddamanSee also the
395*63f6f57bSAndy Fiddaman.Fl B Cm local
396*63f6f57bSAndy Fiddamanand
397*63f6f57bSAndy Fiddaman.Fl B Cm reduce
398*63f6f57bSAndy Fiddamanoptions.
399*63f6f57bSAndy FiddamanSee
400*63f6f57bSAndy Fiddaman.Em Defining Additional Symbols with a mapfile
401*63f6f57bSAndy Fiddamanin
402*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
403*63f6f57bSAndy Fiddaman.Pp
404*63f6f57bSAndy Fiddaman.It Fl B Cm group
405*63f6f57bSAndy FiddamanEstablishes a shared object and its dependencies as a group.
406*63f6f57bSAndy FiddamanObjects within the group are bound to other members of the group at runtime.
407*63f6f57bSAndy FiddamanThis mode is similar to adding the object to the process by using
408*63f6f57bSAndy Fiddaman.Xr dlopen 3C
409*63f6f57bSAndy Fiddamanwith the
410*63f6f57bSAndy Fiddaman.Dv RTLD_GROUP
411*63f6f57bSAndy Fiddamanmode.
412*63f6f57bSAndy FiddamanAn object that has an explicit dependency on a object identified as a group,
413*63f6f57bSAndy Fiddamanbecomes a member of the group.
414*63f6f57bSAndy Fiddaman.Pp
415*63f6f57bSAndy FiddamanAs the group must be self contained, use of the
416*63f6f57bSAndy Fiddaman.Fl B Cm group
417*63f6f57bSAndy Fiddamanoption also asserts the
418*63f6f57bSAndy Fiddaman.Fl z Cm defs
419*63f6f57bSAndy Fiddamanoption.
420*63f6f57bSAndy Fiddaman.Pp
421*63f6f57bSAndy Fiddaman.It Fl B Cm local
422c10c16deSRichard LoweCauses any global symbols, not assigned to a version definition, to be reduced
423*63f6f57bSAndy Fiddamanto local.
424*63f6f57bSAndy FiddamanVersion definitions can be supplied by means of a
425*63f6f57bSAndy Fiddaman.Sy mapfile
426*63f6f57bSAndy Fiddamanto indicate the global symbols that should remain visible in the generated
427*63f6f57bSAndy Fiddamanobject.
428*63f6f57bSAndy FiddamanThis option achieves the same symbol reduction as the
429*63f6f57bSAndy Fiddaman.Ar auto-reduction
430*63f6f57bSAndy Fiddamandirective that is available as part of a mapfile version definition.
431*63f6f57bSAndy FiddamanThis option can be useful when combining versioned and non-versioned
432*63f6f57bSAndy Fiddamanrelocatable objects.
433*63f6f57bSAndy FiddamanSee also the
434*63f6f57bSAndy Fiddaman.Fl B Cm eliminate
435*63f6f57bSAndy Fiddamanand
436*63f6f57bSAndy Fiddaman.Fl B Cm reduce
437*63f6f57bSAndy Fiddamanoptions.
438*63f6f57bSAndy FiddamanSee
439*63f6f57bSAndy Fiddaman.Em Defining Additional Symbols with a mapfile
440*63f6f57bSAndy Fiddamanin
441*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
442*63f6f57bSAndy Fiddaman.Pp
443*63f6f57bSAndy Fiddaman.It Fl B Cm reduce
444c10c16deSRichard LoweWhen generating a relocatable object, causes the reduction of symbolic
445*63f6f57bSAndy Fiddamaninformation defined by any version definitions.
446*63f6f57bSAndy FiddamanVersion definitions can be supplied by means of a
447*63f6f57bSAndy Fiddaman.Sy mapfile
448*63f6f57bSAndy Fiddamanto indicate the global symbols that should remain visible in the generated
449*63f6f57bSAndy Fiddamanobject.
450*63f6f57bSAndy FiddamanBy default, when a relocatable object is generated, version definitions are
451*63f6f57bSAndy Fiddamanonly recorded in the output image.
452*63f6f57bSAndy FiddamanThe actual reduction of symbolic information is carried out when the object is
453*63f6f57bSAndy Fiddamanused in the construction of a dynamic executable or shared object.
454*63f6f57bSAndy FiddamanThe
455*63f6f57bSAndy Fiddaman.Fl B Cm reduce
456*63f6f57bSAndy Fiddamanoption is applied automatically when a dynamic executable or shared object is
457*63f6f57bSAndy Fiddamancreated.
458*63f6f57bSAndy Fiddaman.Pp
459*63f6f57bSAndy Fiddaman.It Fl B Cm symbolic
460*63f6f57bSAndy FiddamanIn dynamic mode only.
461*63f6f57bSAndy FiddamanWhen building a shared object, binds references to global symbols to their
462*63f6f57bSAndy Fiddamandefinitions, if available, within the object.
463*63f6f57bSAndy FiddamanNormally, references to global symbols within shared objects are not bound
464*63f6f57bSAndy Fiddamanuntil runtime, even if definitions are available.
465*63f6f57bSAndy FiddamanThis model allows definitions of the same symbol in an executable or other
466*63f6f57bSAndy Fiddamanshared object to override the object's own definition.
467*63f6f57bSAndy Fiddaman.Nm
468*63f6f57bSAndy Fiddamanissues warnings for undefined symbols unless
469*63f6f57bSAndy Fiddaman.Fl z Cm defs
470*63f6f57bSAndy Fiddamanoverrides.
471*63f6f57bSAndy Fiddaman.Pp
472*63f6f57bSAndy FiddamanThe
473*63f6f57bSAndy Fiddaman.Fl B Cm symbolic
474*63f6f57bSAndy Fiddamanoption is intended for specialized dynamic objects and is not recommended for
475*63f6f57bSAndy Fiddamangeneral use.
476*63f6f57bSAndy FiddamanTo reduce the runtime relocation processing that is required an object, the
477*63f6f57bSAndy Fiddamancreation of a version definition is recommended.
478*63f6f57bSAndy Fiddaman.Fl c Ar name
479*63f6f57bSAndy Fiddamanrecords the configuration file
480*63f6f57bSAndy Fiddaman.Ar name
481*63f6f57bSAndy Fiddamanfor use at runtime.
482*63f6f57bSAndy FiddamanConfiguration files can be employed to alter default search paths, provide a
483*63f6f57bSAndy Fiddamandirectory cache, together with providing alternative object dependencies.
484*63f6f57bSAndy FiddamanSee
485*63f6f57bSAndy Fiddaman.Xr crle 1 .
486*63f6f57bSAndy Fiddaman.Pp
487*63f6f57bSAndy Fiddaman.It Fl C
488c10c16deSRichard LoweDemangles C++ symbol names displayed in diagnostic messages.
489*63f6f57bSAndy Fiddaman.Pp
490*63f6f57bSAndy Fiddaman.It Fl d Cm y | Fl d Cm n
491*63f6f57bSAndy FiddamanWhen
492*63f6f57bSAndy Fiddaman.Fl d Cm y ,
493*63f6f57bSAndy Fiddamanthe default, is specified,
494*63f6f57bSAndy Fiddaman.Nm
495*63f6f57bSAndy Fiddamanuses dynamic linking.
496*63f6f57bSAndy FiddamanWhen
497*63f6f57bSAndy Fiddaman.Fl d Cm n
498*63f6f57bSAndy Fiddamanis specified,
499*63f6f57bSAndy Fiddaman.Nm
500*63f6f57bSAndy Fiddamanuses static linking.
501*63f6f57bSAndy FiddamanSee
502*63f6f57bSAndy Fiddaman.Sx Static Executables
503*63f6f57bSAndy Fiddamanand
504*63f6f57bSAndy Fiddaman.Fl B Cm dynamic | Fl B Cm static .
505*63f6f57bSAndy Fiddaman.Pp
506*63f6f57bSAndy Fiddaman.It Fl D Ar token Ns \&,...
507*63f6f57bSAndy FiddamanPrints debugging information as specified by each
508*63f6f57bSAndy Fiddaman.Ar token
509*63f6f57bSAndy Fiddamanto the standard error.
510*63f6f57bSAndy FiddamanThe special token
511*63f6f57bSAndy Fiddaman.Cm help
512*63f6f57bSAndy Fiddamanindicates the full list of tokens available.
513*63f6f57bSAndy FiddamanSee
514*63f6f57bSAndy Fiddaman.Em Debugging Aids
515*63f6f57bSAndy Fiddamanin
516*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
517*63f6f57bSAndy Fiddaman.Pp
518*63f6f57bSAndy Fiddaman.It Fl e Ar epsym
519*63f6f57bSAndy Fiddaman.It Fl \&-entry Ar epsym
520*63f6f57bSAndy FiddamanSets the entry point address for the output file to be the symbol
521*63f6f57bSAndy Fiddaman.Ar epsym .
522*63f6f57bSAndy Fiddaman.Pp
523*63f6f57bSAndy Fiddaman.It Fl f Ar name
524*63f6f57bSAndy Fiddaman.It Fl \&-auxiliary Ar name
525*63f6f57bSAndy FiddamanUseful only when building a shared object.
526*63f6f57bSAndy FiddamanSpecifies that the symbol table of the shared object is used as an auxiliary
527*63f6f57bSAndy Fiddamanfilter on the symbol table of the shared object specified by
528*63f6f57bSAndy Fiddaman.Ar name .
529*63f6f57bSAndy FiddamanMultiple instances of this option are allowed.
530*63f6f57bSAndy FiddamanThis option can not be combined with the
531*63f6f57bSAndy Fiddaman.Fl F
532*63f6f57bSAndy Fiddamanoption.
533*63f6f57bSAndy FiddamanSee
534*63f6f57bSAndy Fiddaman.Em Generating Auxiliary Filters
535*63f6f57bSAndy Fiddamanin
536*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
537*63f6f57bSAndy Fiddaman.Pp
538*63f6f57bSAndy Fiddaman.It Fl F Ar name
539*63f6f57bSAndy Fiddaman.It Fl \&-filter Ar name
540*63f6f57bSAndy FiddamanUseful only when building a shared object.
541*63f6f57bSAndy FiddamanSpecifies that the symbol table of the shared object is used as a filter on the
542*63f6f57bSAndy Fiddamansymbol table of the shared object specified by
543*63f6f57bSAndy Fiddaman.Ar name .
544*63f6f57bSAndy FiddamanMultiple instances of this option are allowed.
545*63f6f57bSAndy FiddamanThis option cannot be combined with the
546*63f6f57bSAndy Fiddaman.Fl f
547*63f6f57bSAndy Fiddamanoption.
548*63f6f57bSAndy FiddamanSee
549*63f6f57bSAndy Fiddaman.Em Generating Standard Filters
550*63f6f57bSAndy Fiddamanin
551*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
552*63f6f57bSAndy Fiddaman.Pp
553*63f6f57bSAndy Fiddaman.It Fl G
554*63f6f57bSAndy Fiddaman.It Fl shared
555*63f6f57bSAndy FiddamanIn dynamic mode only, produces a shared object.
556*63f6f57bSAndy FiddamanUndefined symbols are allowed.
557*63f6f57bSAndy FiddamanSee Chapter 4,
558*63f6f57bSAndy Fiddaman.Em Shared Objects ,
559*63f6f57bSAndy Fiddamanin
560*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
561*63f6f57bSAndy Fiddaman.Pp
562*63f6f57bSAndy Fiddaman.It Fl h Ar name
563*63f6f57bSAndy Fiddaman.It Fl soname Ar name
564*63f6f57bSAndy FiddamanIn dynamic mode only, when building a shared object, records
565*63f6f57bSAndy Fiddaman.Ar name
566*63f6f57bSAndy Fiddamanin the object's dynamic section.
567*63f6f57bSAndy Fiddaman.Ar name
568*63f6f57bSAndy Fiddamanis recorded in any dynamic objects that are linked with this object rather than
569*63f6f57bSAndy Fiddamanthe object's file system name.
570*63f6f57bSAndy FiddamanAccordingly,
571*63f6f57bSAndy Fiddaman.Ar name
572*63f6f57bSAndy Fiddamanis used by the runtime linker as the name of the shared object to search for at
573*63f6f57bSAndy Fiddamanruntime.
574*63f6f57bSAndy FiddamanSee
575*63f6f57bSAndy Fiddaman.Em Recording a Shared Object Name
576*63f6f57bSAndy Fiddamanin
577*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
578*63f6f57bSAndy Fiddaman.Pp
579*63f6f57bSAndy Fiddaman.It Fl i
580*63f6f57bSAndy FiddamanIgnores
581*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH .
582*63f6f57bSAndy FiddamanThis option is useful when an
583*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH
584*63f6f57bSAndy Fiddamansetting is in effect to influence the runtime library search, which would
585*63f6f57bSAndy Fiddamaninterfere with the link-editing being performed.
586*63f6f57bSAndy Fiddaman.Pp
587*63f6f57bSAndy Fiddaman.It Fl I Ar name
588*63f6f57bSAndy Fiddaman.It Fl \&-dynamic-linker Ar name
589*63f6f57bSAndy FiddamanWhen building an executable, uses
590*63f6f57bSAndy Fiddaman.Ar name
591*63f6f57bSAndy Fiddamanas the path name of the interpreter to be written into the program header.
592*63f6f57bSAndy FiddamanThe default in static mode is no interpreter.
593*63f6f57bSAndy FiddamanIn dynamic mode, the default is the name of the runtime linker,
594*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 .
595*63f6f57bSAndy FiddamanEither case can be overridden by
596*63f6f57bSAndy Fiddaman.Fl I Ar name .
597*63f6f57bSAndy Fiddaman.Xr exec 2
598*63f6f57bSAndy Fiddamanloads this interpreter when the
599*63f6f57bSAndy Fiddaman.Pa a.out
600*63f6f57bSAndy Fiddamanis loaded, and passes control to the interpreter rather than to the
601*63f6f57bSAndy Fiddaman.Pa a.out
602*63f6f57bSAndy Fiddamandirectly.
603*63f6f57bSAndy Fiddaman.Pp
604*63f6f57bSAndy Fiddaman.It Fl l Ar x
605*63f6f57bSAndy Fiddaman.It Fl \&-library Ar x
606*63f6f57bSAndy FiddamanSearches a library
607*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .so
608*63f6f57bSAndy Fiddamanor
609*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .a ,
610c10c16deSRichard Lowethe conventional names for shared object and archive libraries, respectively.
611*63f6f57bSAndy FiddamanIn dynamic mode, unless the
612*63f6f57bSAndy Fiddaman.Fl B Cm static
613*63f6f57bSAndy Fiddamanoption is in effect,
614*63f6f57bSAndy Fiddaman.Nm
615c10c16deSRichard Lowesearches each directory specified in the library search path for a
616*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .so
617*63f6f57bSAndy Fiddamanor
618*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy \&.a .
619*63f6f57bSAndy FiddamanThe directory search stops at the first directory containing either.
620*63f6f57bSAndy Fiddaman.Nm
621*63f6f57bSAndy Fiddamanchooses the file ending in
622*63f6f57bSAndy Fiddaman.Sy .so
623*63f6f57bSAndy Fiddamanif
624*63f6f57bSAndy Fiddaman.Fl l Ar x
625*63f6f57bSAndy Fiddamanexpands to two files with names of the form
626*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .so
627*63f6f57bSAndy Fiddamanand
628*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .a .
629*63f6f57bSAndy FiddamanIf no
630*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .so
631*63f6f57bSAndy Fiddamanis found, then
632*63f6f57bSAndy Fiddaman.Nm
633*63f6f57bSAndy Fiddamanaccepts
634*63f6f57bSAndy Fiddaman.Sy lib Ns Ar x Ns Sy .a .
635*63f6f57bSAndy FiddamanIn static mode, or when the
636*63f6f57bSAndy Fiddaman.Fl B Cm static
637*63f6f57bSAndy Fiddamanoption is in effect,
638*63f6f57bSAndy Fiddaman.Nm
639*63f6f57bSAndy Fiddamanselects only the file ending in
640*63f6f57bSAndy Fiddaman.Sy .a .
641*63f6f57bSAndy Fiddaman.Nm
642*63f6f57bSAndy Fiddamansearches a library when the library is encountered, so the placement of
643*63f6f57bSAndy Fiddaman.Fl l
644*63f6f57bSAndy Fiddamanis significant.
645*63f6f57bSAndy FiddamanSee
646*63f6f57bSAndy Fiddaman.Em Linking With Additional Libraries
647*63f6f57bSAndy Fiddamanin
648*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
649*63f6f57bSAndy Fiddaman.Pp
650*63f6f57bSAndy Fiddaman.It Fl L Ar path
651*63f6f57bSAndy Fiddaman.It Fl \&-library-path Ar path
652*63f6f57bSAndy FiddamanAdds
653*63f6f57bSAndy Fiddaman.Ar path
654*63f6f57bSAndy Fiddamanto the library search directories.
655*63f6f57bSAndy Fiddaman.Nm
656*63f6f57bSAndy Fiddamansearches for libraries first in any directories specified by the
657*63f6f57bSAndy Fiddaman.Fl L
658*63f6f57bSAndy Fiddamanoptions and then in the standard directories.
659*63f6f57bSAndy FiddamanThis option is useful only if the option precedes the
660*63f6f57bSAndy Fiddaman.Fl l
661*63f6f57bSAndy Fiddamanoptions to which the
662*63f6f57bSAndy Fiddaman.Fl L
663*63f6f57bSAndy Fiddamanoption applies.
664*63f6f57bSAndy FiddamanSee
665*63f6f57bSAndy Fiddaman.Em Directories Searched by the Link-Editor
666*63f6f57bSAndy Fiddamanin
667*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
668*63f6f57bSAndy Fiddaman.Pp
669*63f6f57bSAndy FiddamanThe environment variable
670*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH
671*63f6f57bSAndy Fiddamancan be used to supplement the library search path, however the
672*63f6f57bSAndy Fiddaman.Fl L
673*63f6f57bSAndy Fiddamanoption is recommended, as the environment variable is also interpreted by the
674*63f6f57bSAndy Fiddamanruntime environment.
675*63f6f57bSAndy FiddamanSee
676*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH
677*63f6f57bSAndy Fiddamanunder
678*63f6f57bSAndy Fiddaman.Sx ENVIRONMENT .
679*63f6f57bSAndy Fiddaman.Pp
680*63f6f57bSAndy Fiddaman.It Fl m
681c10c16deSRichard LoweProduces a memory map or listing of the input/output sections, together with
682c10c16deSRichard Loweany non-fatal multiply-defined symbols, on the standard output.
683*63f6f57bSAndy Fiddaman.Pp
684*63f6f57bSAndy Fiddaman.It Fl M Ar mapfile
685*63f6f57bSAndy FiddamanReads
686*63f6f57bSAndy Fiddaman.Ar mapfile
687*63f6f57bSAndy Fiddamanas a text file of directives to
688*63f6f57bSAndy Fiddaman.Nm .
689*63f6f57bSAndy FiddamanThis option can be specified multiple times.
690*63f6f57bSAndy FiddamanIf
691*63f6f57bSAndy Fiddaman.Ar mapfile
692*63f6f57bSAndy Fiddamanis a directory, then all regular files, as defined by
693*63f6f57bSAndy Fiddaman.Xr stat 2 ,
694*63f6f57bSAndy Fiddamanwithin the directory are processed.
695*63f6f57bSAndy FiddamanSee Chapter 9,
696*63f6f57bSAndy Fiddaman.Em Mapfile Option ,
697*63f6f57bSAndy Fiddamanin
698*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
699*63f6f57bSAndy FiddamanExample mapfiles are provided in
700*63f6f57bSAndy Fiddaman.Pa /usr/lib/ld .
701*63f6f57bSAndy FiddamanSee
702*63f6f57bSAndy Fiddaman.Sx FILES .
703*63f6f57bSAndy Fiddaman.Pp
704*63f6f57bSAndy Fiddaman.It Fl N Ar string
705*63f6f57bSAndy FiddamanThis option causes a
706*63f6f57bSAndy Fiddaman.Dv DT_NEEDED
707*63f6f57bSAndy Fiddamanentry to be added to the
708*63f6f57bSAndy Fiddaman.Sy .dynamic
709*63f6f57bSAndy Fiddamansection of the object being built.
710*63f6f57bSAndy FiddamanThe value of the
711*63f6f57bSAndy Fiddaman.Dv DT_NEEDED
712*63f6f57bSAndy Fiddamanstring is the
713*63f6f57bSAndy Fiddaman.Ar string
714*63f6f57bSAndy Fiddamanthat is specified on the command line.
715*63f6f57bSAndy FiddamanThis option is position dependent, and the
716*63f6f57bSAndy Fiddaman.Dv DT_NEEDED
717*63f6f57bSAndy Fiddaman.Sy .dynamic
718*63f6f57bSAndy Fiddamanentry is relative to the other dynamic dependencies discovered on the link-edit
719*63f6f57bSAndy Fiddamanline.
720*63f6f57bSAndy FiddamanThis option is useful for specifying dependencies within device driver
721*63f6f57bSAndy Fiddamanrelocatable objects when combined with the
722*63f6f57bSAndy Fiddaman.Fl d Cm y
723*63f6f57bSAndy Fiddamanand
724*63f6f57bSAndy Fiddaman.Fl r
725*63f6f57bSAndy Fiddamanoptions.
726*63f6f57bSAndy Fiddaman.Pp
727*63f6f57bSAndy Fiddaman.It Fl o Ar outfile
728*63f6f57bSAndy Fiddaman.It Fl \&-output Ar outfile
729*63f6f57bSAndy FiddamanProduces an output object file that is named
730*63f6f57bSAndy Fiddaman.Ar outfile .
731*63f6f57bSAndy FiddamanThe name of the default object file is
732*63f6f57bSAndy Fiddaman.Pa a.out .
733*63f6f57bSAndy Fiddaman.Pp
734*63f6f57bSAndy Fiddaman.It Fl p Ar auditlib
735*63f6f57bSAndy FiddamanIdentifies an audit library,
736*63f6f57bSAndy Fiddaman.Ar auditlib .
737*63f6f57bSAndy FiddamanThis audit library is used to audit the object being created at runtime.
738*63f6f57bSAndy FiddamanA shared object identified as requiring auditing with the
739*63f6f57bSAndy Fiddaman.Fl p
740*63f6f57bSAndy Fiddamanoption, has this requirement inherited by any object that specifies the shared
741*63f6f57bSAndy Fiddamanobject as a dependency.
742*63f6f57bSAndy FiddamanSee the
743*63f6f57bSAndy Fiddaman.Fl P
744*63f6f57bSAndy Fiddamanoption.
745*63f6f57bSAndy FiddamanSee
746*63f6f57bSAndy Fiddaman.Em Runtime Linker Auditing Interface
747*63f6f57bSAndy Fiddamanin
748*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
749*63f6f57bSAndy Fiddaman.Pp
750*63f6f57bSAndy Fiddaman.It Fl P Ar auditlib
751*63f6f57bSAndy FiddamanIdentifies an audit library,
752*63f6f57bSAndy Fiddaman.Ar auditlib .
753*63f6f57bSAndy FiddamanThis audit library is used to audit the dependencies of the object being
754*63f6f57bSAndy Fiddamancreated at runtime.
755*63f6f57bSAndy FiddamanDependency auditing can also be inherited from dependencies that are identified
756*63f6f57bSAndy Fiddamanas requiring auditing.
757*63f6f57bSAndy FiddamanSee the
758*63f6f57bSAndy Fiddaman.Fl p
759*63f6f57bSAndy Fiddamanand
760*63f6f57bSAndy Fiddaman.Fl z Cm globalaudit
761*63f6f57bSAndy Fiddamanoptions.
762*63f6f57bSAndy FiddamanSee
763*63f6f57bSAndy Fiddaman.Em Runtime Linker Auditing Interface
764*63f6f57bSAndy Fiddamanin
765*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
766*63f6f57bSAndy Fiddaman.Pp
767*63f6f57bSAndy Fiddaman.It Fl Q Cm y | Fl Q Cm n
768*63f6f57bSAndy FiddamanUnder
769*63f6f57bSAndy Fiddaman.Fl Q Cm y ,
770*63f6f57bSAndy Fiddamanan
771*63f6f57bSAndy Fiddaman.Sy ident
772*63f6f57bSAndy Fiddamanstring is added to the
773*63f6f57bSAndy Fiddaman.Sy .comment
774*63f6f57bSAndy Fiddamansection of the output file.
775*63f6f57bSAndy FiddamanThis string identifies the version of the
776*63f6f57bSAndy Fiddaman.Nm
777*63f6f57bSAndy Fiddamanused to create the file.
778*63f6f57bSAndy FiddamanThis results in multiple
779*63f6f57bSAndy Fiddaman.Nm
780*63f6f57bSAndy Fiddamanidents when there have been multiple linking steps, such as when using
781*63f6f57bSAndy Fiddaman.Nm Fl r .
782*63f6f57bSAndy FiddamanThis identification is identical with the default action of the
783*63f6f57bSAndy Fiddaman.Xr cc 1
784*63f6f57bSAndy Fiddamancommand.
785*63f6f57bSAndy Fiddaman.Fl Q Cm n
786*63f6f57bSAndy Fiddamansuppresses version identification.
787*63f6f57bSAndy Fiddaman.Sy .comment
788*63f6f57bSAndy Fiddamansections can be manipulated by the
789*63f6f57bSAndy Fiddaman.Xr mcs 1
790*63f6f57bSAndy Fiddamanutility.
791*63f6f57bSAndy Fiddaman.Pp
792*63f6f57bSAndy Fiddaman.It Fl r
793*63f6f57bSAndy Fiddaman.It Fl \&-relocatable
794c10c16deSRichard LoweCombines relocatable object files to produce one relocatable object file.
795*63f6f57bSAndy Fiddaman.Nm
796*63f6f57bSAndy Fiddamandoes not complain about unresolved references.
797*63f6f57bSAndy FiddamanThis option cannot be used with the
798*63f6f57bSAndy Fiddaman.Fl a
799*63f6f57bSAndy Fiddamanoption.
800*63f6f57bSAndy Fiddaman.Pp
801*63f6f57bSAndy Fiddaman.It Fl R Ar path
802*63f6f57bSAndy Fiddaman.It Fl rpath Ar path
803c10c16deSRichard LoweA colon-separated list of directories used to specify library search
804*63f6f57bSAndy Fiddamandirectories to the runtime linker.
805*63f6f57bSAndy FiddamanIf present and not NULL, the path is recorded in the output object file and
806*63f6f57bSAndy Fiddamanpassed to the runtime linker.
807*63f6f57bSAndy FiddamanMultiple instances of this option are concatenated together with each
808*63f6f57bSAndy Fiddaman.Ar path
809*63f6f57bSAndy Fiddamanseparated by a colon.
810*63f6f57bSAndy FiddamanSee
811*63f6f57bSAndy Fiddaman.Em Directories Searched by the Runtime Linker
812*63f6f57bSAndy Fiddamanin
813*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
814*63f6f57bSAndy Fiddaman.Pp
815c10c16deSRichard LoweThe use of a runpath within an associated object is preferable to setting
816*63f6f57bSAndy Fiddamanglobal search paths such as through the
817*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH
818*63f6f57bSAndy Fiddamanenvironment variable.
819*63f6f57bSAndy FiddamanOnly the runpaths that are necessary to find the objects dependencies should be
820*63f6f57bSAndy Fiddamanrecorded.
821*63f6f57bSAndy Fiddaman.Xr ldd 1
822*63f6f57bSAndy Fiddamancan also be used to discover unused runpaths in dynamic objects, when used with
823*63f6f57bSAndy Fiddamanthe
824*63f6f57bSAndy Fiddaman.Fl U
825*63f6f57bSAndy Fiddamanoption.
826*63f6f57bSAndy Fiddaman.Pp
827c10c16deSRichard LoweVarious tokens can also be supplied with a runpath that provide a flexible
828*63f6f57bSAndy Fiddamanmeans of identifying system capabilities or an objects location.
829*63f6f57bSAndy FiddamanSee Appendix C,
830*63f6f57bSAndy Fiddaman.Em Establishing Dependencies with Dynamic String Tokens ,
831*63f6f57bSAndy Fiddamanin
832*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
833*63f6f57bSAndy FiddamanThe
834*63f6f57bSAndy Fiddaman.Sy $ORIGIN
835*63f6f57bSAndy Fiddamantoken is especially useful in allowing dynamic objects to be relocated to
836*63f6f57bSAndy Fiddamandifferent locations in the file system.
837*63f6f57bSAndy Fiddaman.Pp
838*63f6f57bSAndy Fiddaman.It Fl s
839*63f6f57bSAndy Fiddaman.It Fl \&-strip-all
840*63f6f57bSAndy FiddamanStrips symbolic information from the output file.
841*63f6f57bSAndy FiddamanAny debugging information,
842*63f6f57bSAndy Fiddamanthat is,
843*63f6f57bSAndy Fiddaman.Sy .line ,
844*63f6f57bSAndy Fiddaman.Sy .debug* ,
845*63f6f57bSAndy Fiddamanand
846*63f6f57bSAndy Fiddaman.Sy .stab*
847*63f6f57bSAndy Fiddamansections, and their associated relocation entries are removed.
848*63f6f57bSAndy FiddamanExcept for relocatable files, a symbol table
849*63f6f57bSAndy Fiddaman.Dv SHT_SYMTAB
850*63f6f57bSAndy Fiddamanand its associated string table section are not created in the output object
851*63f6f57bSAndy Fiddamanfile.
852*63f6f57bSAndy FiddamanThe elimination of a
853*63f6f57bSAndy Fiddaman.Dv SHT_SYMTAB
854*63f6f57bSAndy Fiddamansymbol table can reduce the .stab* debugging information that is generated
855*63f6f57bSAndy Fiddamanusing the compiler driver's
856*63f6f57bSAndy Fiddaman.Fl g
857*63f6f57bSAndy Fiddamanoption.
858*63f6f57bSAndy FiddamanSee the
859*63f6f57bSAndy Fiddaman.Fl z Cm redlocsym
860*63f6f57bSAndy Fiddamanand
861*63f6f57bSAndy Fiddaman.Fl z Cm noldynsym
862*63f6f57bSAndy Fiddamanoptions.
863*63f6f57bSAndy Fiddaman.Pp
864*63f6f57bSAndy Fiddaman.It Fl S Ar supportlib
865*63f6f57bSAndy FiddamanThe shared object
866*63f6f57bSAndy Fiddaman.Ar supportlib
867*63f6f57bSAndy Fiddamanis loaded with
868*63f6f57bSAndy Fiddaman.Nm
869*63f6f57bSAndy Fiddamanand given information regarding the linking process.
870*63f6f57bSAndy FiddamanShared objects that are defined by using the
871*63f6f57bSAndy Fiddaman.Fl S
872*63f6f57bSAndy Fiddamanoption can also be supplied using the
873*63f6f57bSAndy Fiddaman.Ev SGS_SUPPORT
874*63f6f57bSAndy Fiddamanenvironment variable.
875*63f6f57bSAndy FiddamanSee
876*63f6f57bSAndy Fiddaman.Em Link-Editor Support Interface
877*63f6f57bSAndy Fiddamanin
878*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
879*63f6f57bSAndy Fiddaman.Pp
880*63f6f57bSAndy Fiddaman.It Fl t
881c10c16deSRichard LoweTurns off the warning for multiply-defined symbols that have different sizes or
882c10c16deSRichard Lowedifferent alignments.
883*63f6f57bSAndy Fiddaman.Pp
884*63f6f57bSAndy Fiddaman.It Fl u Ar symname
885*63f6f57bSAndy Fiddaman.It Fl \&-undefined Ar symname
886*63f6f57bSAndy FiddamanEnters
887*63f6f57bSAndy Fiddaman.Ar symname
888*63f6f57bSAndy Fiddamanas an undefined symbol in the symbol table.
889*63f6f57bSAndy FiddamanThis option is useful for loading entirely from an archive library.
890*63f6f57bSAndy FiddamanIn this instance, an unresolved reference is needed to force the loading of the
891*63f6f57bSAndy Fiddamanfirst routine.
892*63f6f57bSAndy FiddamanThe placement of this option on the command line is significant.
893*63f6f57bSAndy FiddamanThis option must be placed before the library that defines the symbol.
894*63f6f57bSAndy FiddamanSee
895*63f6f57bSAndy Fiddaman.Em Defining Additional Symbols with the u option
896*63f6f57bSAndy Fiddamanin
897*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
898*63f6f57bSAndy Fiddaman.Pp
899*63f6f57bSAndy Fiddaman.It Fl V
900*63f6f57bSAndy Fiddaman.It Fl \&-version
901*63f6f57bSAndy FiddamanOutputs a message giving information about the version of
902*63f6f57bSAndy Fiddaman.Nm
903*63f6f57bSAndy Fiddamanbeing used.
904*63f6f57bSAndy Fiddaman.Pp
905*63f6f57bSAndy Fiddaman.It Fl Y Cm P\&, Ns Ar dirlist
906*63f6f57bSAndy FiddamanChanges the default directories used for finding libraries.
907*63f6f57bSAndy Fiddaman.Ar dirlist
908*63f6f57bSAndy Fiddamanis a colon-separated path list.
909*63f6f57bSAndy Fiddaman.Pp
910*63f6f57bSAndy Fiddaman.It Fl z Cm absexec
911*63f6f57bSAndy FiddamanUseful only when building a dynamic executable.
912*63f6f57bSAndy FiddamanSpecifies that references to external absolute symbols should be resolved
913*63f6f57bSAndy Fiddamanimmediately instead of being left for resolution at runtime.
914*63f6f57bSAndy FiddamanIn very specialized circumstances, this option removes text relocations that
915*63f6f57bSAndy Fiddamancan result in excessive swap space demands by an executable.
916*63f6f57bSAndy Fiddaman.Pp
917*63f6f57bSAndy Fiddaman.It Fl z Cm allextract | Fl z Cm defaultextract | Fl z Cm weakextract
918*63f6f57bSAndy Fiddaman.It Fl \&-whole-archive | \&-no-whole-archive
919*63f6f57bSAndy FiddamanAlters the extraction criteria of objects from any archives that follow.
920*63f6f57bSAndy FiddamanBy default, archive members are extracted to satisfy undefined references and
921*63f6f57bSAndy Fiddamanto promote tentative definitions with data definitions.
922*63f6f57bSAndy FiddamanWeak symbol references do not trigger extraction.
923*63f6f57bSAndy FiddamanUnder the
924*63f6f57bSAndy Fiddaman.Fl z Cm allextract
925*63f6f57bSAndy Fiddamanor
926*63f6f57bSAndy Fiddaman.Fl \&-whole-archive
927*63f6f57bSAndy Fiddamanoptions, all archive members are extracted from the archive.
928*63f6f57bSAndy FiddamanUnder
929*63f6f57bSAndy Fiddaman.Fl z Cm weakextract ,
930*63f6f57bSAndy Fiddamanweak references trigger archive extraction.
931*63f6f57bSAndy FiddamanThe
932*63f6f57bSAndy Fiddaman.Fl z Cm defaultextract
933*63f6f57bSAndy Fiddamanor
934*63f6f57bSAndy Fiddaman.Fl \&-no-whole-archive
935c10c16deSRichard Loweoptions provide a means of returning to the default following use of the former
936*63f6f57bSAndy Fiddamanextract options.
937*63f6f57bSAndy FiddamanSee
938*63f6f57bSAndy Fiddaman.Em Archive Processing
939*63f6f57bSAndy Fiddamanin
940*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
941*63f6f57bSAndy Fiddaman.Pp
942*63f6f57bSAndy Fiddaman.It Fl z Cm altexec64
943*63f6f57bSAndy FiddamanExecute the 64-bit
944*63f6f57bSAndy Fiddaman.Nm .
945*63f6f57bSAndy FiddamanThe creation of very large 32-bit objects can exhaust the virtual memory that
946*63f6f57bSAndy Fiddamanis available to the 32-bit
947*63f6f57bSAndy Fiddaman.Nm .
948*63f6f57bSAndy FiddamanThe
949*63f6f57bSAndy Fiddaman.Fl z Cm altexec64
950*63f6f57bSAndy Fiddamanoption can be used to force the use of the associated 64-bit
951*63f6f57bSAndy Fiddaman.Nm .
952*63f6f57bSAndy FiddamanThe 64-bit
953*63f6f57bSAndy Fiddaman.Nm
954*63f6f57bSAndy Fiddamanprovides a larger virtual address space for building 32-bit objects.
955*63f6f57bSAndy FiddamanSee
956*63f6f57bSAndy Fiddaman.Em The 32-bit link-editor and 64-bit link-editor
957*63f6f57bSAndy Fiddamanin
958*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
959*63f6f57bSAndy Fiddaman.Pp
960*63f6f57bSAndy Fiddaman.It Fl z Cm aslr Ns Op Cm \&= Ns Ar state
961d2a70789SRichard LoweSpecify whether the executable's address space should be randomized on
962*63f6f57bSAndy Fiddamanexecution.
963*63f6f57bSAndy FiddamanIf
964*63f6f57bSAndy Fiddaman.Ar state
965*63f6f57bSAndy Fiddamanis
966*63f6f57bSAndy Fiddaman.Cm enabled ,
967*63f6f57bSAndy Fiddamanrandomization will always occur when this executable is run
968*63f6f57bSAndy Fiddaman.Pq regardless of inherited settings .
969*63f6f57bSAndy FiddamanIf
970*63f6f57bSAndy Fiddaman.Ar state
971*63f6f57bSAndy Fiddamanis
972*63f6f57bSAndy Fiddaman.Cm disabled ,
973*63f6f57bSAndy Fiddamanrandomization will never occur when this executable is run.
974*63f6f57bSAndy FiddamanIf
975*63f6f57bSAndy Fiddaman.Ar state
976*63f6f57bSAndy Fiddamanis omitted, ASLR is enabled.
977d2a70789SRichard LoweAn executable that should simply use the settings inherited from its
978d2a70789SRichard Loweenvironment should not use this flag at all.
979*63f6f57bSAndy Fiddaman.Pp
980*63f6f57bSAndy Fiddaman.It Fl z Cm combreloc | Fl z Cm nocombreloc
981*63f6f57bSAndy FiddamanBy default,
982*63f6f57bSAndy Fiddaman.Nm
983*63f6f57bSAndy Fiddamancombines multiple relocation sections when building executables or shared
984*63f6f57bSAndy Fiddamanobjects.
985*63f6f57bSAndy FiddamanThis section combination differs from relocatable objects, in which relocation
986*63f6f57bSAndy Fiddamansections are maintained in a one-to-one relationship with the sections to which
987*63f6f57bSAndy Fiddamanthe relocations must be applied.
988*63f6f57bSAndy FiddamanThe
989*63f6f57bSAndy Fiddaman.Fl z Cm nocombreloc
990*63f6f57bSAndy Fiddamanoption disables this merging of relocation sections, and preserves the
991*63f6f57bSAndy Fiddamanone-to-one relationship found in the original relocatable objects.
992*63f6f57bSAndy Fiddaman.Pp
993*63f6f57bSAndy Fiddaman.Nm
994*63f6f57bSAndy Fiddamansorts the entries of data relocation sections by their symbol reference.
995*63f6f57bSAndy FiddamanThis sorting reduces runtime symbol lookup.
996*63f6f57bSAndy FiddamanWhen multiple relocation sections are combined, this sorting produces the least
997*63f6f57bSAndy Fiddamanpossible relocation overhead when objects are loaded into memory, and speeds
998*63f6f57bSAndy Fiddamanthe runtime loading of dynamic objects.
999*63f6f57bSAndy Fiddaman.Pp
1000c10c16deSRichard LoweHistorically, the individual relocation sections were carried over to any
1001*63f6f57bSAndy Fiddamanexecutable or shared object, and the
1002*63f6f57bSAndy Fiddaman.Fl z Cm combreloc
1003*63f6f57bSAndy Fiddamanoption was required to enable the relocation section merging previously
1004*63f6f57bSAndy Fiddamandescribed.
1005*63f6f57bSAndy FiddamanRelocation section merging is now the default.
1006*63f6f57bSAndy FiddamanThe
1007*63f6f57bSAndy Fiddaman.Fl z Cm combreloc
1008c10c16deSRichard Loweoption is still accepted for the benefit of old build environments, but the
1009c10c16deSRichard Loweoption is unnecessary, and has no effect.
1010*63f6f57bSAndy Fiddaman.Pp
1011*63f6f57bSAndy Fiddaman.It Fl z Cm assert-deflib
1012*63f6f57bSAndy Fiddaman.It Fl z Cm assert-deflib= Ns Ar libname
1013b533f56bSRobert MustacchiEnables warnings that check the location of where libraries passed in with
1014*63f6f57bSAndy Fiddaman.Fl l
1015*63f6f57bSAndy Fiddamanare found.
1016*63f6f57bSAndy FiddamanIf the link-editor finds a library on its default search path it will emit a
1017*63f6f57bSAndy Fiddamanwarning.
1018*63f6f57bSAndy FiddamanThis warning can be made fatal in conjunction with the option
1019*63f6f57bSAndy Fiddaman.Fl z Cm fatal-warnings .
1020*63f6f57bSAndy FiddamanPassing
1021*63f6f57bSAndy Fiddaman.Ar libname
1022*63f6f57bSAndy Fiddamanwhite lists a library from this check.
1023*63f6f57bSAndy FiddamanThe library must be the full name of the library, e.g.
1024*63f6f57bSAndy Fiddaman.Pa libc.so .
1025*63f6f57bSAndy FiddamanTo white list multiple libraries, the
1026*63f6f57bSAndy Fiddaman.Fl z Cm assert-deflib= Ns Ar libname
1027*63f6f57bSAndy Fiddamanoption can be repeated multiple times.
1028*63f6f57bSAndy FiddamanThis option is useful when trying to build self-contained objects where a
1029*63f6f57bSAndy Fiddamanreferenced library might exist in the default system library path and in
1030*63f6f57bSAndy Fiddamanalternate paths specified by
1031*63f6f57bSAndy Fiddaman.Fl L ,
1032*63f6f57bSAndy Fiddamanbut you only want the alternate paths to be used.
1033*63f6f57bSAndy Fiddaman.Pp
1034*63f6f57bSAndy Fiddaman.It Fl z Cm defs | Fl z Cm nodefs
1035*63f6f57bSAndy Fiddaman.It Fl \&-no-undefined
1036*63f6f57bSAndy FiddamanThe
1037*63f6f57bSAndy Fiddaman.Fl z Cm defs
1038*63f6f57bSAndy Fiddamanoption and the
1039*63f6f57bSAndy Fiddaman.Fl \&-no-undefined
1040*63f6f57bSAndy Fiddamanoption force a fatal error if any undefined symbols remain at the end of the
1041*63f6f57bSAndy Fiddamanlink.
1042*63f6f57bSAndy FiddamanThis mode is the default when an executable is built.
1043*63f6f57bSAndy FiddamanFor historic reasons, this mode is
1044*63f6f57bSAndy Fiddaman.Em not
1045*63f6f57bSAndy Fiddamanthe default when building a shared object.
1046*63f6f57bSAndy FiddamanUse of the
1047*63f6f57bSAndy Fiddaman.Fl z Cm defs
1048*63f6f57bSAndy Fiddamanoption is recommended, as this mode assures the object being built is
1049*63f6f57bSAndy Fiddamanself-contained.
1050*63f6f57bSAndy FiddamanA self-contained object has all symbolic references resolved internally, or to
1051*63f6f57bSAndy Fiddamanthe object's immediate dependencies.
1052*63f6f57bSAndy Fiddaman.Pp
1053*63f6f57bSAndy FiddamanThe
1054*63f6f57bSAndy Fiddaman.Fl z Cm nodefs
1055*63f6f57bSAndy Fiddamanoption allows undefined symbols.
1056*63f6f57bSAndy FiddamanFor historic reasons, this mode is the default when a shared object is built.
1057*63f6f57bSAndy FiddamanWhen used with executables, the behavior of references to such undefined
1058*63f6f57bSAndy Fiddamansymbols is unspecified.
1059*63f6f57bSAndy FiddamanUse of the
1060*63f6f57bSAndy Fiddaman.Fl z Cm nodefs
1061*63f6f57bSAndy Fiddamanoption is not recommended.
1062*63f6f57bSAndy Fiddaman.Pp
1063*63f6f57bSAndy Fiddaman.It Fl z Cm direct | Fl z Cm nodirect
1064c10c16deSRichard LoweEnables or disables direct binding to any dependencies that follow on the
1065*63f6f57bSAndy Fiddamancommand line.
1066*63f6f57bSAndy FiddamanThese options allow finer control over direct binding than the global
1067*63f6f57bSAndy Fiddamancounterpart
1068*63f6f57bSAndy Fiddaman.Fl B Cm direct .
1069*63f6f57bSAndy FiddamanThe
1070*63f6f57bSAndy Fiddaman.Fl z Cm direct
1071*63f6f57bSAndy Fiddamanoption also differs from the
1072*63f6f57bSAndy Fiddaman.Fl B Cm direct
1073*63f6f57bSAndy Fiddamanoption in the following areas.
1074*63f6f57bSAndy FiddamanDirect binding information is not established between a symbol reference and an
1075*63f6f57bSAndy Fiddamanassociated definition within the object being created.
1076*63f6f57bSAndy FiddamanLazy loading is not enabled.
1077*63f6f57bSAndy Fiddaman.Pp
1078*63f6f57bSAndy Fiddaman.It Fl z Cm endfiltee
1079c10c16deSRichard LoweMarks a filtee so that when processed by a filter, the filtee terminates any
1080*63f6f57bSAndy Fiddamanfurther filtee searches by the filter.
1081*63f6f57bSAndy FiddamanSee
1082*63f6f57bSAndy Fiddaman.Em Reducing Filtee Searches
1083*63f6f57bSAndy Fiddamanin
1084*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1085*63f6f57bSAndy Fiddaman.Pp
1086*63f6f57bSAndy Fiddaman.It Fl z Cm fatal-warnings | Fl z Cm nofatal-warnings
1087*63f6f57bSAndy Fiddaman.It Fl \&-fatal-warnings | \&-no-fatal-warnings
1088*63f6f57bSAndy FiddamanControls the behavior of warnings emitted from the link-editor.
1089*63f6f57bSAndy FiddamanSetting
1090*63f6f57bSAndy Fiddaman.Fl z Cm fatal-warnings
1091*63f6f57bSAndy Fiddamanpromotes warnings emitted by the link-editor to fatal errors that will cause
1092*63f6f57bSAndy Fiddamanthe link-editor to fail before linking.
1093*63f6f57bSAndy Fiddaman.Fl z Cm nofatal-warnings
1094*63f6f57bSAndy Fiddamaninstead demotes these warnings such that they will not cause the link-editor to
1095*63f6f57bSAndy Fiddamanexit prematurely.
1096*63f6f57bSAndy Fiddaman.Pp
1097*63f6f57bSAndy Fiddaman.It Fl z Cm finiarray= Ns Ar function
1098*63f6f57bSAndy FiddamanAppends an entry to the
1099*63f6f57bSAndy Fiddaman.Sy .fini_array
1100*63f6f57bSAndy Fiddamansection of the object being built.
1101*63f6f57bSAndy FiddamanIf no
1102*63f6f57bSAndy Fiddaman.Sy .fini_array
1103*63f6f57bSAndy Fiddamansection is present, a section is created.
1104*63f6f57bSAndy FiddamanThe new entry is initialized to point to
1105*63f6f57bSAndy Fiddaman.Ar function .
1106*63f6f57bSAndy FiddamanSee
1107*63f6f57bSAndy Fiddaman.Em Initialization and Termination Sections
1108*63f6f57bSAndy Fiddamanin
1109*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1110*63f6f57bSAndy Fiddaman.Pp
1111*63f6f57bSAndy Fiddaman.It Fl z Cm globalaudit
1112c10c16deSRichard LoweThis option supplements an audit library definition that has been recorded with
1113*63f6f57bSAndy Fiddamanthe
1114*63f6f57bSAndy Fiddaman.Fl P
1115*63f6f57bSAndy Fiddamanoption.
1116*63f6f57bSAndy FiddamanThis option is only meaningful when building a dynamic executable.
1117*63f6f57bSAndy FiddamanAudit libraries that are defined within an object with the
1118*63f6f57bSAndy Fiddaman.Fl P
1119c10c16deSRichard Loweoption typically allow for the auditing of the immediate dependencies of the
1120*63f6f57bSAndy Fiddamanobject.
1121*63f6f57bSAndy FiddamanThe
1122*63f6f57bSAndy Fiddaman.Fl z Cm globalaudit
1123*63f6f57bSAndy Fiddamanpromotes the auditor to a global auditor, thus allowing the auditing of all
1124*63f6f57bSAndy Fiddamandependencies.
1125*63f6f57bSAndy FiddamanSee
1126*63f6f57bSAndy Fiddaman.Em Invoking the Auditing Interface
1127*63f6f57bSAndy Fiddamanin
1128*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1129*63f6f57bSAndy Fiddaman.Pp
1130*63f6f57bSAndy FiddamanAn auditor established with the
1131*63f6f57bSAndy Fiddaman.Fl P
1132*63f6f57bSAndy Fiddamanoption and the
1133*63f6f57bSAndy Fiddaman.Fl z Cm globalaudit
1134*63f6f57bSAndy Fiddamanoption, is equivalent to the auditor being established with the
1135*63f6f57bSAndy Fiddaman.Ev LD_AUDIT
1136*63f6f57bSAndy Fiddamanenvironment variable.
1137*63f6f57bSAndy FiddamanSee
1138*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 .
1139*63f6f57bSAndy Fiddaman.Pp
1140*63f6f57bSAndy Fiddaman.It Fl z Cm groupperm | Fl z Cm nogroupperm
1141*63f6f57bSAndy FiddamanAssigns, or deassigns each dependency that follows to a unique group.
1142*63f6f57bSAndy FiddamanThe assignment of a dependency to a group has the same effect as if the
1143*63f6f57bSAndy Fiddamandependency had been built using the
1144*63f6f57bSAndy Fiddaman.Fl B Cm group
1145*63f6f57bSAndy Fiddamanoption.
1146*63f6f57bSAndy Fiddaman.Pp
1147*63f6f57bSAndy Fiddaman.It Fl z Cm guidance Ns Op Cm \&= Ns Ar id Ns No ,...
114872025881SRichard LoweGive messages suggesting link-editor features that could improve the resulting
114972025881SRichard Lowedynamic object.
11508222814eSRichard LoweSpecific classes of suggestion can be silenced by specifying an optional comma
11518222814eSRichard Loweseparated list of guidance identifiers.
115272025881SRichard LoweThe current classes of suggestion provided are:
1153*63f6f57bSAndy Fiddaman.Bl -tag -width 4n
1154*63f6f57bSAndy Fiddaman.It Enable use of direct binding
1155*63f6f57bSAndy FiddamanSuggests that
1156*63f6f57bSAndy Fiddaman.Fl z Cm direct
1157*63f6f57bSAndy Fiddamanor
1158*63f6f57bSAndy Fiddaman.Fl B Cm direct
1159*63f6f57bSAndy Fiddamanbe present prior to any specified dependency.
1160*63f6f57bSAndy FiddamanThis allows predictable symbol binding at runtime.
1161*63f6f57bSAndy FiddamanCan be disabled with
1162*63f6f57bSAndy Fiddaman.Fl z Cm guidance=nodirect
1163*63f6f57bSAndy Fiddaman.It Enable lazy dependency loading
1164*63f6f57bSAndy FiddamanSuggests that
1165*63f6f57bSAndy Fiddaman.Fl z Cm lazyload
1166*63f6f57bSAndy Fiddamanbe present prior to any specified dependency.
116772025881SRichard LoweThis allows the dynamic object to be loaded more quickly.
1168*63f6f57bSAndy FiddamanCan be disabled with
1169*63f6f57bSAndy Fiddaman.Fl z Cm guidance=nolazyload
1170*63f6f57bSAndy Fiddaman.It Shared objects should define all their dependencies.
1171*63f6f57bSAndy FiddamanSuggests that
1172*63f6f57bSAndy Fiddaman.Fl z Cm defs
1173*63f6f57bSAndy Fiddamanbe specified on the link-editor command line.
117472025881SRichard LoweShared objects that explicitly state all their dependencies behave more
117572025881SRichard Lowepredictably when used.
1176*63f6f57bSAndy FiddamanCan be be disabled with
1177*63f6f57bSAndy Fiddaman.Fl z Cm guidance=nodefs
1178*63f6f57bSAndy Fiddaman.It Version 2 mapfile syntax
117972025881SRichard LoweSuggests that any specified mapfiles use the more readable version 2 syntax.
1180*63f6f57bSAndy FiddamanCan be disabled with
1181*63f6f57bSAndy Fiddaman.Fl z Cm guidance=nomapfile
1182*63f6f57bSAndy Fiddaman.It Read-only text segment
118372025881SRichard LoweShould any runtime relocations within the text segment exist, suggests that
1184*63f6f57bSAndy Fiddamanthe object be compiled with position independent code
1185*63f6f57bSAndy Fiddaman.Pq PIC .
1186*63f6f57bSAndy FiddamanKeeping large allocatable sections read-only allows them to be shared between
1187*63f6f57bSAndy Fiddamanprocesses using a given shared object.
1188*63f6f57bSAndy FiddamanCan be disabled with
1189*63f6f57bSAndy Fiddaman.Fl z Cm guidance=notext
1190*63f6f57bSAndy Fiddaman.It No unused dependencies
119172025881SRichard LoweSuggests that any dependency not referenced by the resulting dynamic object be
119272025881SRichard Loweremoved from the link-editor command line.
1193*63f6f57bSAndy FiddamanCan be disabled with
1194*63f6f57bSAndy Fiddaman.Fl z Cm guidance=nounused
1195*63f6f57bSAndy Fiddaman.It Global data in shared libraries built with mapfiles have size assertions
11968222814eSRichard LoweSuggests that any global data in a library built with a mapfile asserts the
11978222814eSRichard Lowesize of that global data for ABI stability purposes.
1198*63f6f57bSAndy FiddamanCan be disabled with
1199*63f6f57bSAndy Fiddaman.Fl z Cm guidance=noasserts
1200*63f6f57bSAndy Fiddaman.El
1201*63f6f57bSAndy Fiddaman.Pp
1202*63f6f57bSAndy Fiddaman.It Fl z Cm help
1203*63f6f57bSAndy Fiddaman.It Fl \&-help
1204c10c16deSRichard LowePrint a summary of the command line options on the standard output and exit.
1205*63f6f57bSAndy Fiddaman.Pp
1206*63f6f57bSAndy Fiddaman.It Fl z Cm ignore | Fl z Cm record
1207c10c16deSRichard LoweIgnores, or records, dynamic dependencies that are not referenced as part of
1208*63f6f57bSAndy Fiddamanthe link-edit.
1209*63f6f57bSAndy FiddamanIgnores, or records, unreferenced
1210*63f6f57bSAndy Fiddaman.Sy ELF
1211*63f6f57bSAndy Fiddamansections from the relocatable objects
1212*63f6f57bSAndy Fiddamanthat are read as part of the link-edit.
1213*63f6f57bSAndy FiddamanBy default,
1214*63f6f57bSAndy Fiddaman.Fl z Cm record
1215*63f6f57bSAndy Fiddamanis in effect.
1216*63f6f57bSAndy Fiddaman.Pp
1217*63f6f57bSAndy FiddamanIf an
1218*63f6f57bSAndy Fiddaman.Sy ELF
1219*63f6f57bSAndy Fiddamansection is ignored, the section is eliminated from the output file being
1220*63f6f57bSAndy Fiddamangenerated.
1221*63f6f57bSAndy FiddamanA section is ignored when three conditions are true.
1222*63f6f57bSAndy FiddamanThe eliminated section must contribute to an allocatable segment.
1223*63f6f57bSAndy FiddamanThe eliminated section must provide no global symbols.
1224*63f6f57bSAndy FiddamanNo other section from any object that contributes to the link-edit, must
1225*63f6f57bSAndy Fiddamanreference an eliminated section.
1226*63f6f57bSAndy Fiddaman.Pp
1227*63f6f57bSAndy Fiddaman.It Fl z Cm initarray= Ns Ar function
1228*63f6f57bSAndy FiddamanAppends an entry to the
1229*63f6f57bSAndy Fiddaman.Sy .init_array
1230*63f6f57bSAndy Fiddamansection of the object being built.
1231*63f6f57bSAndy FiddamanIf no
1232*63f6f57bSAndy Fiddaman.Sy .init_array
1233*63f6f57bSAndy Fiddamansection is present, a section is created.
1234*63f6f57bSAndy FiddamanThe new entry is initialized to point to
1235*63f6f57bSAndy Fiddaman.Ar function .
1236*63f6f57bSAndy FiddamanSee
1237*63f6f57bSAndy Fiddaman.Em Initialization and Termination Sections
1238*63f6f57bSAndy Fiddamanin
1239*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1240*63f6f57bSAndy Fiddaman.Pp
1241*63f6f57bSAndy Fiddaman.It Fl z Cm initfirst
1242c10c16deSRichard LoweMarks the object so that its runtime initialization occurs before the runtime
1243c10c16deSRichard Loweinitialization of any other objects brought into the process at the same time.
1244c10c16deSRichard LoweIn addition, the object runtime finalization occurs after the runtime
1245c10c16deSRichard Lowefinalization of any other objects removed from the process at the same time.
1246c10c16deSRichard LoweThis option is only meaningful when building a shared object.
1247*63f6f57bSAndy Fiddaman.Pp
1248*63f6f57bSAndy Fiddaman.It Fl z Cm interpose
1249*63f6f57bSAndy FiddamanMarks the object as an interposer.
1250*63f6f57bSAndy FiddamanAt runtime, an object is identified as an explicit interposer if the object has
1251*63f6f57bSAndy Fiddamanbeen tagged using the
1252*63f6f57bSAndy Fiddaman.Fl z Cm interpose
1253*63f6f57bSAndy Fiddamanoption.
1254*63f6f57bSAndy FiddamanAn explicit interposer is also established when an object is loaded using the
1255*63f6f57bSAndy Fiddaman.Ev LD_PRELOAD
1256*63f6f57bSAndy Fiddamanenvironment variable.
1257*63f6f57bSAndy FiddamanImplicit interposition can occur because of the load order of objects, however,
1258*63f6f57bSAndy Fiddamanthis implicit interposition is unknown to the runtime linker.
1259*63f6f57bSAndy FiddamanExplicit interposition can ensure that interposition takes place regardless of
1260*63f6f57bSAndy Fiddamanthe order in which objects are loaded.
1261*63f6f57bSAndy FiddamanExplicit interposition also ensures that the runtime linker searches for
1262*63f6f57bSAndy Fiddamansymbols in any explicit interposers when direct bindings are in effect.
1263*63f6f57bSAndy Fiddaman.Pp
1264*63f6f57bSAndy Fiddaman.It Fl z Cm lazyload | Fl z Cm nolazyload
1265c10c16deSRichard LoweEnables or disables the marking of dynamic dependencies to be lazily loaded.
1266*63f6f57bSAndy FiddamanDynamic dependencies which are marked
1267*63f6f57bSAndy FiddamanCm lazyload
1268*63f6f57bSAndy Fiddamanare not loaded at initial process start-up.
1269*63f6f57bSAndy FiddamanThese dependencies are delayed until the first binding to the object is made.
1270*63f6f57bSAndy FiddamanNote: Lazy loading requires the correct declaration of dependencies, together
1271*63f6f57bSAndy Fiddamanwith associated runpaths for each dynamic object used within a process.
1272*63f6f57bSAndy FiddamanSee
1273*63f6f57bSAndy Fiddaman.Em Lazy Loading of Dynamic Dependencies
1274*63f6f57bSAndy Fiddamanin
1275*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1276*63f6f57bSAndy Fiddaman.Pp
1277*63f6f57bSAndy Fiddaman.It Fl z Cm ld32= Ns Ar arg Ns No ,...
1278*63f6f57bSAndy Fiddaman.It Fl z Cm ld64= Ns Ar arg Ns No ,...
1279c10c16deSRichard LoweThe class of the link-editor is affected by the class of the output file being
1280*63f6f57bSAndy Fiddamancreated and by the capabilities of the underlying operating system.
1281*63f6f57bSAndy FiddamanThe
1282*63f6f57bSAndy Fiddaman.Fl z Cm ld32 | Fl z Cm ld64
1283*63f6f57bSAndy Fiddamanoptions provide a means of defining any link-editor argument.
1284*63f6f57bSAndy FiddamanThe defined argument is only interpreted, respectively, by the 32-bit class or
1285*63f6f57bSAndy Fiddaman64-bit class of the link-editor.
1286*63f6f57bSAndy Fiddaman.Pp
1287c10c16deSRichard LoweFor example, support libraries are class specific, so the correct class of
1288c10c16deSRichard Lowesupport library can be ensured using:
1289*63f6f57bSAndy Fiddaman.Pp
1290*63f6f57bSAndy Fiddaman.Dl ld ... -z ld32=-Saudit32.so.1 -z ld64=-Saudit64.so.1 ...
1291*63f6f57bSAndy Fiddaman.Pp
1292*63f6f57bSAndy FiddamanThe class of link-editor that is invoked is determined from the
1293*63f6f57bSAndy Fiddaman.Sy ELF
1294*63f6f57bSAndy Fiddamanclass of the first relocatable file that is seen on the command line.
1295*63f6f57bSAndy FiddamanThis determination is carried out
1296*63f6f57bSAndy Fiddaman.Em prior
1297*63f6f57bSAndy Fiddamanto any
1298*63f6f57bSAndy Fiddaman.Fl z Cm ld32 | Fl z Cm ld64
1299*63f6f57bSAndy Fiddamanprocessing.
1300*63f6f57bSAndy Fiddaman.Pp
1301*63f6f57bSAndy Fiddaman.It Fl z Cm loadfltr
1302c10c16deSRichard LoweMarks a filter to indicate that filtees must be processed immediately at
1303*63f6f57bSAndy Fiddamanruntime.
1304*63f6f57bSAndy FiddamanNormally, filter processing is delayed until a symbol reference is bound to the
1305*63f6f57bSAndy Fiddamanfilter.
1306*63f6f57bSAndy FiddamanThe runtime processing of an object that contains this flag mimics that which
1307*63f6f57bSAndy Fiddamanoccurs if the
1308*63f6f57bSAndy Fiddaman.Ev LD_LOADFLTR
1309*63f6f57bSAndy Fiddamanenvironment variable is in effect.
1310*63f6f57bSAndy FiddamanSee the
1311*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 .
1312*63f6f57bSAndy Fiddaman.Pp
1313*63f6f57bSAndy Fiddaman.It Fl z Cm muldefs
1314*63f6f57bSAndy Fiddaman.It Fl \&-allow-multiple-definition
1315*63f6f57bSAndy FiddamanAllows multiple symbol definitions.
1316*63f6f57bSAndy FiddamanBy default, multiple symbol definitions that occur between relocatable objects
1317*63f6f57bSAndy Fiddamanresult in a fatal error condition.
1318*63f6f57bSAndy FiddamanThis option, suppresses the error condition, allowing the first symbol
1319*63f6f57bSAndy Fiddamandefinition to be taken.
1320*63f6f57bSAndy Fiddaman.Pp
1321*63f6f57bSAndy Fiddaman.It Fl z Cm nocompstrtab
1322*63f6f57bSAndy FiddamanDisables the compression of
1323*63f6f57bSAndy Fiddaman.Sy ELF
1324*63f6f57bSAndy Fiddamanstring tables.
1325*63f6f57bSAndy FiddamanBy default, string compression is applied to
1326*63f6f57bSAndy Fiddaman.Dv SHT_STRTAB
1327*63f6f57bSAndy Fiddamansections, and to
1328*63f6f57bSAndy Fiddaman.Dv SHT_PROGBITS
1329*63f6f57bSAndy Fiddamansections that have their
1330*63f6f57bSAndy Fiddaman.Dv SHF_MERGE
1331*63f6f57bSAndy Fiddamanand
1332*63f6f57bSAndy Fiddaman.Dv SHF_STRINGS
1333*63f6f57bSAndy Fiddamansection flags set.
1334*63f6f57bSAndy Fiddaman.Pp
1335*63f6f57bSAndy Fiddaman.It Fl z Cm nodefaultlib
1336c10c16deSRichard LoweMarks the object so that the runtime default library search path, used after
1337*63f6f57bSAndy Fiddamanany
1338*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH
1339*63f6f57bSAndy Fiddamanor runpaths, is ignored.
1340*63f6f57bSAndy FiddamanThis option implies that all dependencies of the object can be satisfied from
1341*63f6f57bSAndy Fiddamanits runpath.
1342*63f6f57bSAndy Fiddaman.Pp
1343*63f6f57bSAndy Fiddaman.It Fl z Cm nodelete
1344*63f6f57bSAndy FiddamanMarks the object as non-deletable at runtime.
1345*63f6f57bSAndy FiddamanThis mode is similar to adding the object to the process by using
1346*63f6f57bSAndy Fiddaman.Xr dlopen 3C
1347*63f6f57bSAndy Fiddamanwith the
1348*63f6f57bSAndy Fiddaman.Dv RTLD_NODELETE
1349*63f6f57bSAndy Fiddamanmode.
1350*63f6f57bSAndy Fiddaman.Pp
1351*63f6f57bSAndy Fiddaman.It Fl z Cm nodlopen
1352*63f6f57bSAndy FiddamanMarks the object as not available to
1353*63f6f57bSAndy Fiddaman.Xr dlopen 3C ,
1354*63f6f57bSAndy Fiddamaneither as the object specified by the
1355*63f6f57bSAndy Fiddaman.Xr dlopen 3C ,
1356*63f6f57bSAndy Fiddamanor as any form of dependency required by the object specified by the
1357*63f6f57bSAndy Fiddaman.Xr dlopen 3C .
1358*63f6f57bSAndy FiddamanThis option is only meaningful when building a shared object.
1359*63f6f57bSAndy Fiddaman.Pp
1360*63f6f57bSAndy Fiddaman.It Fl z Cm nodump
1361*63f6f57bSAndy FiddamanMarks the object as not available to
1362*63f6f57bSAndy Fiddaman.Xr dldump 3C .
1363*63f6f57bSAndy Fiddaman.Pp
1364*63f6f57bSAndy Fiddaman.It Fl z Cm noldynsym
1365*63f6f57bSAndy FiddamanPrevents the inclusion of a
1366*63f6f57bSAndy Fiddaman.Sy .SUNW_ldynsym
1367*63f6f57bSAndy Fiddamansection in dynamic executables or sharable libraries.
1368*63f6f57bSAndy FiddamanThe
1369*63f6f57bSAndy Fiddaman.Sy .SUNW_ldynsym
1370*63f6f57bSAndy Fiddamansection augments the
1371*63f6f57bSAndy Fiddaman.Sy .dynsym
1372*63f6f57bSAndy Fiddamansection by providing symbols for local functions.
1373*63f6f57bSAndy FiddamanLocal function symbols allow debuggers to display local function names in stack
1374*63f6f57bSAndy Fiddamantraces from stripped programs.
1375*63f6f57bSAndy FiddamanSimilarly,
1376*63f6f57bSAndy Fiddaman.Xr dladdr 3C
1377*63f6f57bSAndy Fiddamanis able to supply more accurate results.
1378*63f6f57bSAndy Fiddaman.Pp
1379*63f6f57bSAndy FiddamanThe
1380*63f6f57bSAndy Fiddaman.Fl z Cm noldynsym
1381*63f6f57bSAndy Fiddamanoption also prevents the inclusion of the two symbol sort sections that are
1382*63f6f57bSAndy Fiddamanrelated to the
1383*63f6f57bSAndy Fiddaman.Sy .SUNW_ldynsym
1384*63f6f57bSAndy Fiddamansection.
1385*63f6f57bSAndy FiddamanThe
1386*63f6f57bSAndy Fiddaman.Sy .SUNW_dynsymsort
1387*63f6f57bSAndy Fiddamansection provides sorted access to regular function and variable symbols.
1388*63f6f57bSAndy FiddamanThe
1389*63f6f57bSAndy Fiddaman.Sy .SUNW_dyntlssort
1390*63f6f57bSAndy Fiddamansection provides sorted access to thread local storage
1391*63f6f57bSAndy Fiddaman.Pq TLS
1392*63f6f57bSAndy Fiddamanvariable symbols.
1393*63f6f57bSAndy Fiddaman.Pp
1394*63f6f57bSAndy FiddamanThe
1395*63f6f57bSAndy Fiddaman.Sy .SUNW_ldynsym ,
1396*63f6f57bSAndy Fiddaman.Sy .SUNW_dynsymsort ,
1397*63f6f57bSAndy Fiddamanand
1398*63f6f57bSAndy Fiddaman.Sy .SUNW_dyntlssort
1399*63f6f57bSAndy Fiddamansections, which becomes part of the allocable text segment of the resulting
1400*63f6f57bSAndy Fiddamanfile, cannot be removed by
1401*63f6f57bSAndy Fiddaman.Xr strip 1 .
1402*63f6f57bSAndy FiddamanTherefore, the
1403*63f6f57bSAndy Fiddaman.Fl z Cm noldynsym
1404*63f6f57bSAndy Fiddamanoption is the only way to prevent their inclusion.
1405*63f6f57bSAndy FiddamanSee the
1406*63f6f57bSAndy Fiddaman.Fl s
1407*63f6f57bSAndy Fiddamanand
1408*63f6f57bSAndy Fiddaman.Fl z Cm redlocsym
1409*63f6f57bSAndy Fiddamanoptions.
1410*63f6f57bSAndy Fiddaman.Pp
1411*63f6f57bSAndy Fiddaman.It Fl z Cm nopartial
1412c10c16deSRichard LowePartially initialized symbols, that are defined within relocatable object
1413c10c16deSRichard Lowefiles, are expanded in the output file being generated.
1414*63f6f57bSAndy Fiddaman.Pp
1415*63f6f57bSAndy Fiddaman.It Fl z Cm noversion
1416*63f6f57bSAndy FiddamanDoes not record any versioning sections.
1417*63f6f57bSAndy FiddamanAny version sections or associated
1418*63f6f57bSAndy Fiddaman.Sy .dynamic
1419*63f6f57bSAndy Fiddamansection entries are not generated in the output image.
1420*63f6f57bSAndy Fiddaman.Pp
1421*63f6f57bSAndy Fiddaman.It Fl z Cm now
1422*63f6f57bSAndy FiddamanMarks the object as requiring non-lazy runtime binding.
1423*63f6f57bSAndy FiddamanThis mode is similar to adding the object to the process by using
1424*63f6f57bSAndy Fiddaman.Xr dlopen 3C
1425*63f6f57bSAndy Fiddamanwith the
1426*63f6f57bSAndy Fiddaman.Dv RTLD_NOW
1427*63f6f57bSAndy Fiddamanmode.
1428*63f6f57bSAndy FiddamanThis mode is also similar to having the
1429*63f6f57bSAndy Fiddaman.Ev LD_BIND_NOW
1430*63f6f57bSAndy Fiddamanenvironment variable in effect.
1431*63f6f57bSAndy FiddamanSee
1432*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 .
1433*63f6f57bSAndy Fiddaman.Pp
1434*63f6f57bSAndy Fiddaman.It Fl z Cm origin
1435*63f6f57bSAndy FiddamanMarks the object as requiring immediate
1436*63f6f57bSAndy Fiddaman.Sy $ORIGIN
1437*63f6f57bSAndy Fiddamanprocessing at runtime.
1438c10c16deSRichard LoweThis option is only maintained for historic compatibility, as the runtime
1439*63f6f57bSAndy Fiddamananalysis of objects to provide for
1440*63f6f57bSAndy Fiddaman.Sy $ORIGIN
1441*63f6f57bSAndy Fiddamanprocessing is now default.
1442*63f6f57bSAndy Fiddaman.Pp
1443*63f6f57bSAndy Fiddaman.It Fl z Cm preinitarray= Ns Ar function
1444*63f6f57bSAndy FiddamanAppends an entry to the
1445*63f6f57bSAndy Fiddaman.Sy .preinitarray
1446*63f6f57bSAndy Fiddamansection of the object being built.
1447*63f6f57bSAndy FiddamanIf no
1448*63f6f57bSAndy Fiddaman.Sy .preinitarray
1449*63f6f57bSAndy Fiddamansection is present, a section is created.
1450*63f6f57bSAndy FiddamanThe new entry is initialized to point to
1451*63f6f57bSAndy Fiddaman.Ar function .
1452*63f6f57bSAndy FiddamanSee
1453*63f6f57bSAndy Fiddaman.Em Initialization and Termination Sections
1454*63f6f57bSAndy Fiddamanin
1455*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1456*63f6f57bSAndy Fiddaman.Pp
1457*63f6f57bSAndy Fiddaman.It Fl z Cm redlocsym
1458*63f6f57bSAndy FiddamanEliminates all local symbols except for the
1459*63f6f57bSAndy Fiddaman.Sy SECT
1460*63f6f57bSAndy Fiddamansymbols from the symbol
1461*63f6f57bSAndy Fiddamantable
1462*63f6f57bSAndy Fiddaman.Dv SHT_SYMTAB .
1463*63f6f57bSAndy FiddamanAll relocations that refer to local symbols are updated to refer to the
1464*63f6f57bSAndy Fiddamancorresponding
1465*63f6f57bSAndy Fiddaman.Sy SECT
1466*63f6f57bSAndy Fiddamansymbol.
1467*63f6f57bSAndy FiddamanThis option allows specialized objects to greatly reduce their symbol table
1468*63f6f57bSAndy Fiddamansizes.
1469*63f6f57bSAndy FiddamanEliminated local symbols can reduce the
1470*63f6f57bSAndy Fiddaman.Sy .stab
1471*63f6f57bSAndy Fiddamandebugging information that is generated using the compiler driver's
1472*63f6f57bSAndy Fiddaman.Fl g
1473*63f6f57bSAndy Fiddamanoption.
1474*63f6f57bSAndy FiddamanSee the
1475*63f6f57bSAndy Fiddaman.Fl s
1476*63f6f57bSAndy Fiddamanand
1477*63f6f57bSAndy Fiddaman.Fl z Cm noldynsym
1478c10c16deSRichard Loweoptions.
1479*63f6f57bSAndy Fiddaman.Pp
1480*63f6f57bSAndy Fiddaman.It Fl z Cm relaxreloc
1481*63f6f57bSAndy Fiddaman.Nm
1482*63f6f57bSAndy Fiddamannormally issues a fatal error upon encountering a relocation using a
1483*63f6f57bSAndy Fiddamansymbol that references an eliminated COMDAT section.
1484*63f6f57bSAndy FiddamanIf
1485*63f6f57bSAndy Fiddaman.Fl z Cm relaxreloc
1486*63f6f57bSAndy Fiddamanis enabled,
1487*63f6f57bSAndy Fiddaman.Nm
1488*63f6f57bSAndy Fiddamaninstead redirects such relocations to the equivalent symbol in the COMDAT
1489*63f6f57bSAndy Fiddamansection that was kept.
1490*63f6f57bSAndy Fiddaman.Fl z Cm relaxreloc
1491*63f6f57bSAndy Fiddamanis a specialized option, mainly of interest to compiler authors, and is not
1492*63f6f57bSAndy Fiddamanintended for general use.
1493*63f6f57bSAndy Fiddaman.Pp
1494*63f6f57bSAndy Fiddaman.It Fl z Cm rescan-now
1495*63f6f57bSAndy Fiddaman.It Fl z Cm rescan
1496*63f6f57bSAndy FiddamanThese options rescan the archive files that are provided to the link-edit.
1497*63f6f57bSAndy FiddamanBy default, archives are processed once as the archives appear on the command
1498*63f6f57bSAndy Fiddamanline.
1499*63f6f57bSAndy FiddamanArchives are traditionally specified at the end of the command line so that
1500*63f6f57bSAndy Fiddamantheir symbol definitions resolve any preceding references.
1501*63f6f57bSAndy FiddamanHowever, specifying archives multiple times to satisfy their own
1502*63f6f57bSAndy Fiddamaninterdependencies can be necessary.
1503*63f6f57bSAndy Fiddaman.Pp
1504*63f6f57bSAndy Fiddaman.Fl z Cm rescan-now
1505*63f6f57bSAndy Fiddamanis a positional option, and is processed by the link-editor immediately when
1506*63f6f57bSAndy Fiddamanencountered on the command line.
1507*63f6f57bSAndy FiddamanAll archives seen on the command line up to that point are immediately
1508*63f6f57bSAndy Fiddamanreprocessed in an attempt to locate additional archive members that resolve
1509*63f6f57bSAndy Fiddamansymbol references.
1510*63f6f57bSAndy FiddamanThis archive rescanning is repeated until a pass over the archives occurs in
1511*63f6f57bSAndy Fiddamanwhich no new members are extracted.
1512*63f6f57bSAndy Fiddaman.Pp
1513*63f6f57bSAndy Fiddaman.Fl z Cm rescan
1514*63f6f57bSAndy Fiddamanis a position independent option.
1515*63f6f57bSAndy FiddamanThe link-editor defers the rescan operation until after it has processed the
1516*63f6f57bSAndy Fiddamanentire command line, and then initiates a final rescan operation over all
1517*63f6f57bSAndy Fiddamanarchives seen on the command line.
1518*63f6f57bSAndy FiddamanThe
1519*63f6f57bSAndy Fiddaman.Fl z Cm rescan
1520*63f6f57bSAndy Fiddamanoperation can interact incorrectly with objects that contain initialization
1521*63f6f57bSAndy Fiddaman.Pq .init
1522*63f6f57bSAndy Fiddamanor finalization
1523*63f6f57bSAndy Fiddaman.Pq .fini
1524*63f6f57bSAndy Fiddamansections, preventing the code in those sections from running.
1525*63f6f57bSAndy FiddamanFor this reason,
1526*63f6f57bSAndy Fiddaman.Fl z Cm rescan
1527*63f6f57bSAndy Fiddamanis deprecated, and use of
1528*63f6f57bSAndy Fiddaman.Fl z Cm rescan-now
1529*63f6f57bSAndy Fiddamanis
1530c10c16deSRichard Loweadvised.
1531*63f6f57bSAndy Fiddaman.Pp
1532*63f6f57bSAndy Fiddaman.It Fl z Cm rescan-start No \&... Fl z Cm rescan-end
1533*63f6f57bSAndy Fiddaman.It Fl \&-start-group No \&... Fl \&-end-group
1534*63f6f57bSAndy Fiddaman.It Fl \&( No \&... Fl \&)
1535*63f6f57bSAndy FiddamanDefines an archive rescan group.
1536*63f6f57bSAndy FiddamanThis is a positional construct, and is processed by the link-editor immediately
1537*63f6f57bSAndy Fiddamanupon encountering the closing delimiter option.
1538*63f6f57bSAndy FiddamanArchives found within the group delimiter options are reprocessed as a group in
1539*63f6f57bSAndy Fiddamanan attempt to locate additional archive members that resolve symbol references.
1540*63f6f57bSAndy FiddamanThis archive rescanning is repeated until a pass over the archives occurs in
1541*63f6f57bSAndy Fiddamanwhich no new members are extracted.
1542c10c16deSRichard LoweArchive rescan groups cannot be nested.
1543*63f6f57bSAndy Fiddaman.Pp
1544*63f6f57bSAndy Fiddaman.It Fl z Cm symbolcap
1545*63f6f57bSAndy FiddamanSpecifies that a relocatable object that defines object capabilities should
1546*63f6f57bSAndy Fiddamanhave those converted to symbol capabilities.
1547*63f6f57bSAndy FiddamanA relocatable object that does not have any object capabilities will ignore
1548*63f6f57bSAndy Fiddamanthis option.
1549*63f6f57bSAndy Fiddaman.Pp
1550*63f6f57bSAndy FiddamanSymbol capabilities provide a means for multiple implementations of a function
1551*63f6f57bSAndy Fiddamanto co-exist and have one picked at runtime based upon the hardware capabilities
1552*63f6f57bSAndy Fiddamanof the system.
1553*63f6f57bSAndy FiddamanWhen
1554*63f6f57bSAndy Fiddaman.Fl z Cm symbolcap
1555*63f6f57bSAndy Fiddamanis invoked, all global functions are converted into local functions that have
1556*63f6f57bSAndy Fiddamanthe corresponding capability name appended to them and an undefined symbol with
1557*63f6f57bSAndy Fiddamanthe original name left in the resulting relocatable object.
1558*63f6f57bSAndy FiddamanAt runtime, the global symbol will be bound to the corresponding implementation
1559*63f6f57bSAndy Fiddamanthat is appropriate based on the capabilities of the system.
1560*63f6f57bSAndy Fiddaman.Pp
1561*63f6f57bSAndy Fiddaman.It Fl z Cm target= Ns Cm sparc Ns | Ns Cm x86
1562*63f6f57bSAndy FiddamanSpecifies the machine type for the output object.
1563*63f6f57bSAndy FiddamanSupported targets are
1564*63f6f57bSAndy Fiddaman.Cm sparc
1565*63f6f57bSAndy Fiddamanand
1566*63f6f57bSAndy Fiddaman.Cm x86 .
1567*63f6f57bSAndy FiddamanThe 32-bit machine type for the specified target is used unless the
1568*63f6f57bSAndy Fiddaman.Fl 64
1569*63f6f57bSAndy Fiddamanoption is also present, in which case the corresponding 64-bit machine type is
1570*63f6f57bSAndy Fiddamanused.
1571*63f6f57bSAndy FiddamanBy default, the machine type of the object being generated is determined from
1572*63f6f57bSAndy Fiddamanthe first
1573*63f6f57bSAndy Fiddaman.Sy ELF
1574*63f6f57bSAndy Fiddamanobject processed from the command line.
1575*63f6f57bSAndy FiddamanIf no objects are specified, the machine type is determined by the first object
1576*63f6f57bSAndy Fiddamanencountered within the first archive processed from the command line.
1577*63f6f57bSAndy FiddamanIf there are no objects or archives, the link-editor assumes the native
1578*63f6f57bSAndy Fiddamanmachine.
1579*63f6f57bSAndy FiddamanThis option is useful when creating an object directly with
1580*63f6f57bSAndy Fiddaman.Nm
1581*63f6f57bSAndy Fiddamanwhose input is solely from a
1582*63f6f57bSAndy Fiddaman.Sy mapfile .
1583*63f6f57bSAndy FiddamanSee the
1584*63f6f57bSAndy Fiddaman.Fl M
1585*63f6f57bSAndy Fiddamanoption.
1586c10c16deSRichard LoweIt can also be useful in the rare case of linking entirely from an archive that
1587c10c16deSRichard Lowecontains objects of different machine types for which the first object is not
1588*63f6f57bSAndy Fiddamanof the desired machine type.
1589*63f6f57bSAndy FiddamanSee
1590*63f6f57bSAndy Fiddaman.Em The 32-bit link-editor and 64-bit link-editor
1591*63f6f57bSAndy Fiddamanin
1592*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1593*63f6f57bSAndy Fiddaman.Pp
1594*63f6f57bSAndy FiddamanNote that for compatibility with existing Makefiles and scripts, these options
1595012e6ce7SDan Crossmay be given multiple times and may be mixed in the same invocation: the last
1596*63f6f57bSAndy Fiddamaninstance wins, so that, for example,
1597*63f6f57bSAndy Fiddaman.Ql ld -z target=sparc -z target=x86 \&...
1598*63f6f57bSAndy Fiddamangives a machine type of
1599*63f6f57bSAndy Fiddaman.Sq x86 .
1600*63f6f57bSAndy Fiddaman.Pp
1601*63f6f57bSAndy Fiddaman.It Fl z Cm text
1602c10c16deSRichard LoweIn dynamic mode only, forces a fatal error if any relocations against
1603*63f6f57bSAndy Fiddamannon-writable, allocatable sections remain.
1604*63f6f57bSAndy FiddamanFor historic reasons, this mode is not the default when building an executable
1605*63f6f57bSAndy Fiddamanor shared object.
1606*63f6f57bSAndy FiddamanHowever, its use is recommended to ensure that the text segment of the dynamic
1607*63f6f57bSAndy Fiddamanobject being built is shareable between multiple running processes.
1608*63f6f57bSAndy FiddamanA shared text segment incurs the least relocation overhead when loaded into
1609*63f6f57bSAndy Fiddamanmemory.
1610*63f6f57bSAndy FiddamanSee
1611*63f6f57bSAndy Fiddaman.Em Position-Independent Code
1612*63f6f57bSAndy Fiddamanin
1613*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1614*63f6f57bSAndy Fiddaman.Pp
1615*63f6f57bSAndy Fiddaman.It Fl z Cm textoff
1616c10c16deSRichard LoweIn dynamic mode only, allows relocations against all allocatable sections,
1617*63f6f57bSAndy Fiddamanincluding non-writable ones.
1618*63f6f57bSAndy FiddamanThis mode is the default when building a shared object.
1619*63f6f57bSAndy Fiddaman.Pp
1620*63f6f57bSAndy Fiddaman.It Fl z Cm textwarn
1621c10c16deSRichard LoweIn dynamic mode only, lists a warning if any relocations against non-writable,
1622*63f6f57bSAndy Fiddamanallocatable sections remain.
1623*63f6f57bSAndy FiddamanThis mode is the default when building an executable.
1624*63f6f57bSAndy Fiddaman.Pp
1625*63f6f57bSAndy Fiddaman.It Xo
1626*63f6f57bSAndy Fiddaman.Sm off
1627*63f6f57bSAndy Fiddaman.Fl z\~ Cm type= Cm exec | kmod | reloc | shared
1628*63f6f57bSAndy Fiddaman.Sm on
1629*63f6f57bSAndy Fiddaman.Xc
1630b6a0e2cdSRichard LoweSpecifies the type of object to create.
1631*63f6f57bSAndy Fiddaman.Bl -tag -width shared
1632*63f6f57bSAndy Fiddaman.It exec
1633b6a0e2cdSRichard LoweDynamic executable
1634*63f6f57bSAndy Fiddaman.It reloc
1635b6a0e2cdSRichard LoweRelocatable object
1636*63f6f57bSAndy Fiddaman.It shared
1637b6a0e2cdSRichard LoweDynamic shared object
1638*63f6f57bSAndy Fiddaman.It kmod
1639b6a0e2cdSRichard Loweillumos kernel module
1640*63f6f57bSAndy Fiddaman.El
1641*63f6f57bSAndy Fiddaman.Pp
1642*63f6f57bSAndy Fiddaman.It Fl z Cm verbose
1643c10c16deSRichard LoweThis option provides additional warning diagnostics during a link-edit.
1644*63f6f57bSAndy FiddamanPresently, this option conveys suspicious use of displacement relocations.
1645*63f6f57bSAndy FiddamanThis option also conveys the restricted use of static TLS relocations when
1646*63f6f57bSAndy Fiddamanbuilding shared objects.
1647*63f6f57bSAndy FiddamanIn future, this option might be enhanced to provide additional diagnostics that
1648*63f6f57bSAndy Fiddamanare deemed too noisy to be generated by default.
1649*63f6f57bSAndy Fiddaman.Pp
1650*63f6f57bSAndy Fiddaman.It Fl z Cm wrap= Ns Ar symbol
1651*63f6f57bSAndy Fiddaman.It Fl wrap Ns Cm \&= Ns Ar symbol
1652*63f6f57bSAndy Fiddaman.It Fl \&-wrap Ns Cm \&= Ns Ar symbol
1653*63f6f57bSAndy FiddamanRename undefined references to
1654*63f6f57bSAndy Fiddaman.Ar symbol
1655*63f6f57bSAndy Fiddamanin order to allow wrapper code to be linked into the output object without
1656*63f6f57bSAndy Fiddamanhaving to modify source code.
1657*63f6f57bSAndy FiddamanWhen
1658*63f6f57bSAndy Fiddaman.Fl z Cm wrap
1659*63f6f57bSAndy Fiddamanis specified, all undefined references to
1660*63f6f57bSAndy Fiddaman.Ar symbol
1661*63f6f57bSAndy Fiddamanare modified to reference
1662*63f6f57bSAndy Fiddaman.Sy __wrap_ Ns Ar symbol ,
1663*63f6f57bSAndy Fiddamanand all references to
1664*63f6f57bSAndy Fiddaman.Sy __real_ Ns Ar symbol
1665*63f6f57bSAndy Fiddamanare modified to reference
1666*63f6f57bSAndy Fiddaman.Ar symbol .
1667*63f6f57bSAndy FiddamanThe user is expected to provide an object containing the
1668*63f6f57bSAndy Fiddaman.Sy __wrap_ Ns Ar symbol
1669*63f6f57bSAndy Fiddamanfunction.
1670*63f6f57bSAndy FiddamanThis wrapper function can call
1671*63f6f57bSAndy Fiddaman.Sy __real_ Ns Ar symbol
1672*63f6f57bSAndy Fiddamanin order to reference the actual function being wrapped.
1673*63f6f57bSAndy Fiddaman.Pp
1674*63f6f57bSAndy FiddamanThe following is an example of a wrapper for the
1675*63f6f57bSAndy Fiddaman.Xr malloc 3C
1676*63f6f57bSAndy Fiddamanfunction:
1677*63f6f57bSAndy Fiddaman.Bd -literal -offset 4n
1678c10c16deSRichard Lowevoid *
1679c10c16deSRichard Lowe__wrap_malloc(size_t c)
1680c10c16deSRichard Lowe{
168198cdf45aSBart Coddens    (void) printf("malloc called with %zu\en", c);
1682c10c16deSRichard Lowe    return (__real_malloc(c));
1683c10c16deSRichard Lowe}
1684*63f6f57bSAndy Fiddaman.Ed
1685*63f6f57bSAndy Fiddaman.Pp
1686*63f6f57bSAndy FiddamanIf you link other code with this file using
1687*63f6f57bSAndy Fiddaman.Fl z Cm wrap= Ns Ar malloc
1688*63f6f57bSAndy Fiddamanto compile all the objects, then all calls to
1689*63f6f57bSAndy Fiddaman.Sy malloc
1690*63f6f57bSAndy Fiddamanwill call the function
1691*63f6f57bSAndy Fiddaman.Sy __wrap_malloc
1692*63f6f57bSAndy Fiddamaninstead.
1693*63f6f57bSAndy FiddamanThe call to
1694*63f6f57bSAndy Fiddaman.Sy __real_malloc
1695*63f6f57bSAndy Fiddamanwill call the real
1696*63f6f57bSAndy Fiddaman.Sy malloc
1697*63f6f57bSAndy Fiddamanfunction.
1698*63f6f57bSAndy Fiddaman.Pp
1699c10c16deSRichard LoweThe real and wrapped functions should be maintained in separate source files.
1700c10c16deSRichard LoweOtherwise, the compiler or assembler may resolve the call instead of leaving
1701c10c16deSRichard Lowethat operation for the link-editor to carry out, and prevent the wrap from
1702c10c16deSRichard Loweoccurring.
1703*63f6f57bSAndy Fiddaman.El
1704*63f6f57bSAndy Fiddaman.Sh ENVIRONMENT
1705*63f6f57bSAndy Fiddaman.Bl -tag -width 4n
1706*63f6f57bSAndy Fiddaman.It Ev LD_ALTEXEC
1707*63f6f57bSAndy FiddamanAn alternative link-editor path name.
1708*63f6f57bSAndy Fiddaman.Nm
1709*63f6f57bSAndy Fiddamanexecutes, and passes control to this alternative link-editor.
1710*63f6f57bSAndy FiddamanThis environment variable provides a generic means of overriding the default
1711*63f6f57bSAndy Fiddamanlink-editor that is called from the various compiler drivers.
1712*63f6f57bSAndy FiddamanSee the
1713*63f6f57bSAndy Fiddaman.Fl z Cm altexec64
1714*63f6f57bSAndy Fiddamanoption.
1715*63f6f57bSAndy Fiddaman.It Ev LD_LIBRARY_PATH
1716c10c16deSRichard LoweA list of directories in which to search for the libraries specified using the
1717*63f6f57bSAndy Fiddaman.Fl l
1718*63f6f57bSAndy Fiddamanoption.
1719*63f6f57bSAndy FiddamanMultiple directories are separated by a colon.
1720*63f6f57bSAndy FiddamanIn the most general case, this environment variable contains two directory
1721*63f6f57bSAndy Fiddamanlists separated by a semicolon:
1722*63f6f57bSAndy Fiddaman.Pp
1723*63f6f57bSAndy Fiddaman.D1 Ar dirlist1 Ns Cm \&; Ns Ar dirlist2
1724*63f6f57bSAndy Fiddaman.Pp
1725*63f6f57bSAndy FiddamanIf
1726*63f6f57bSAndy Fiddaman.Nm
1727*63f6f57bSAndy Fiddamanis called with any number of occurrences of
1728*63f6f57bSAndy Fiddaman.Fl L ,
1729*63f6f57bSAndy Fiddamanas in:
1730*63f6f57bSAndy Fiddaman.Pp
1731*63f6f57bSAndy Fiddaman.D1 Nm No ... Fl L Ns Ar path1 No ... Fl L Ns Ar pathn No ...
1732*63f6f57bSAndy Fiddaman.Pp
1733c10c16deSRichard Lowethen the search path ordering is:
1734*63f6f57bSAndy Fiddaman.Pp
1735*63f6f57bSAndy Fiddaman.D1 Ar dirlist1 Ar path1 No ... Ar pathn Ar dirlist2 Ev LIBPATH
1736*63f6f57bSAndy Fiddaman.Pp
1737c10c16deSRichard LoweWhen the list of directories does not contain a semicolon, the list is
1738*63f6f57bSAndy Fiddamaninterpreted as
1739*63f6f57bSAndy Fiddaman.Ar dirlist2 .
1740*63f6f57bSAndy Fiddaman.Pp
1741*63f6f57bSAndy FiddamanThe
1742*63f6f57bSAndy Fiddaman.Ev LD_LIBRARY_PATH
1743*63f6f57bSAndy Fiddamanenvironment variable also affects the runtime linkers search for dynamic
1744*63f6f57bSAndy Fiddamandependencies.
1745*63f6f57bSAndy Fiddaman.Pp
1746*63f6f57bSAndy FiddamanThis environment variable can be specified with a _32 or _64 suffix.
1747*63f6f57bSAndy FiddamanThis makes the environment variable specific, respectively, to 32-bit or 64-bit
1748*63f6f57bSAndy Fiddamanprocesses and overrides any non-suffixed version of the environment variable
1749*63f6f57bSAndy Fiddamanthat is in effect.
1750*63f6f57bSAndy Fiddaman.It Ev LD_NOEXEC_64
1751*63f6f57bSAndy FiddamanSuppresses the automatic execution of the 64-bit link-editor.
1752*63f6f57bSAndy FiddamanBy default, the link-editor executes the 64-bit version when the
1753*63f6f57bSAndy Fiddaman.Sy ELF
1754*63f6f57bSAndy Fiddamanclass of the first relocatable file identifies a 64-bit object.
1755*63f6f57bSAndy FiddamanThe 64-bit image that a 32-bit link-editor can create, has some limitations.
1756*63f6f57bSAndy FiddamanHowever, some link-edits might find the use of the 32-bit link-editor faster.
1757*63f6f57bSAndy Fiddaman.It Ev LD_OPTIONS
1758*63f6f57bSAndy FiddamanA default set of options to
1759*63f6f57bSAndy Fiddaman.Nm .
1760*63f6f57bSAndy Fiddaman.Ev LD_OPTIONS
1761*63f6f57bSAndy Fiddamanis interpreted by
1762*63f6f57bSAndy Fiddaman.Nm
1763*63f6f57bSAndy Fiddamanjust as though its value had been placed on the command line, immediately
1764*63f6f57bSAndy Fiddamanfollowing the name used to invoke
1765*63f6f57bSAndy Fiddaman.Nm ,
1766*63f6f57bSAndy Fiddamanas in:
1767*63f6f57bSAndy Fiddaman.Pp
1768*63f6f57bSAndy Fiddaman.D1 Nm Ev $LD_OPTIONS No ... Ar other-arguments No ...
1769*63f6f57bSAndy Fiddaman.It Ev LD_RUN_PATH
1770*63f6f57bSAndy FiddamanAn alternative mechanism for specifying a runpath to the link-editor.
1771*63f6f57bSAndy FiddamanSee the
1772*63f6f57bSAndy Fiddaman.Fl R
1773*63f6f57bSAndy Fiddamanoption.
1774*63f6f57bSAndy FiddamanIf both
1775*63f6f57bSAndy Fiddaman.Ev LD_RUN_PATH
1776*63f6f57bSAndy Fiddamanand the
1777*63f6f57bSAndy Fiddaman.Fl R
1778*63f6f57bSAndy Fiddamanoption are specified,
1779*63f6f57bSAndy Fiddaman.Fl R
1780*63f6f57bSAndy Fiddamansupersedes.
1781*63f6f57bSAndy Fiddaman.It Ev SGS_SUPPORT
1782*63f6f57bSAndy FiddamanProvides a colon-separated list of shared objects that are loaded with the
1783*63f6f57bSAndy Fiddamanlink-editor and given information regarding the linking process.
1784*63f6f57bSAndy FiddamanThis environment variable can be specified with a _32 or _64 suffix.
1785*63f6f57bSAndy FiddamanThis makes the environment variable specific, respectively, to the 32-bit or
1786*63f6f57bSAndy Fiddaman64-bit class of
1787*63f6f57bSAndy Fiddaman.Nm
1788c10c16deSRichard Loweand overrides any non-suffixed version of the environment variable that is in
1789c10c16deSRichard Loweeffect.
1790*63f6f57bSAndy FiddamanSee the
1791*63f6f57bSAndy Fiddaman.Fl S
1792*63f6f57bSAndy Fiddamanoption.
1793*63f6f57bSAndy Fiddaman.El
1794*63f6f57bSAndy Fiddaman.Pp
1795*63f6f57bSAndy FiddamanNotice that environment variable-names that begin with the characters
1796*63f6f57bSAndy Fiddaman.Sq LD_
1797*63f6f57bSAndy Fiddamanare reserved for possible future enhancements to
1798*63f6f57bSAndy Fiddaman.Nm
1799*63f6f57bSAndy Fiddamanand
1800*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 .
1801*63f6f57bSAndy Fiddaman.Sh FILES
1802*63f6f57bSAndy Fiddaman.Bl -tag -width 4n
1803*63f6f57bSAndy Fiddaman.It lib Ns Ar x Ns No .so
1804c10c16deSRichard Loweshared object libraries.
1805*63f6f57bSAndy Fiddaman.It lib Ns Ar x Ns No .a
1806c10c16deSRichard Lowearchive libraries.
1807*63f6f57bSAndy Fiddaman.It Pa a.out
1808c10c16deSRichard Lowedefault output file.
1809*63f6f57bSAndy Fiddaman.It Ev LIBPATH
1810*63f6f57bSAndy FiddamanFor 32-bit libraries, the default search path is
1811*63f6f57bSAndy Fiddaman.Pa /usr/ccs/lib ,
1812*63f6f57bSAndy Fiddamanfollowed by
1813*63f6f57bSAndy Fiddaman.Pa /lib ,
1814*63f6f57bSAndy Fiddamanand finally
1815*63f6f57bSAndy Fiddaman.Pa /usr/lib .
1816*63f6f57bSAndy FiddamanFor 64-bit libraries, the default search path is
1817*63f6f57bSAndy Fiddaman.Pa /lib/64 ,
1818*63f6f57bSAndy Fiddamanfollowed by
1819*63f6f57bSAndy Fiddaman.Pa /usr/lib/64 .
1820*63f6f57bSAndy Fiddaman.It Pa /usr/lib/ld
1821*63f6f57bSAndy FiddamanA directory containing several mapfiles that can be used during link-editing.
1822*63f6f57bSAndy FiddamanThese mapfiles provide various capabilities, such as defining memory layouts,
1823*63f6f57bSAndy Fiddamanaligning bss, and defining non-executable stacks.
1824*63f6f57bSAndy Fiddaman.El
1825*63f6f57bSAndy Fiddaman.Sh ATTRIBUTES
1826*63f6f57bSAndy FiddamanThe command line interface of
1827*63f6f57bSAndy Fiddaman.Nm
1828*63f6f57bSAndy Fiddamanis
1829*63f6f57bSAndy Fiddaman.Sy Committed .
1830*63f6f57bSAndy FiddamanThe output of
1831*63f6f57bSAndy Fiddaman.Nm
1832*63f6f57bSAndy Fiddamanis
1833*63f6f57bSAndy Fiddaman.Sy Committed .
1834*63f6f57bSAndy Fiddaman.Sh SEE ALSO
1835*63f6f57bSAndy Fiddaman.Xr as 1 ,
1836*63f6f57bSAndy Fiddaman.Xr crle 1 ,
1837*63f6f57bSAndy Fiddaman.Xr gprof 1 ,
1838*63f6f57bSAndy Fiddaman.Xr ld.so.1 1 ,
1839*63f6f57bSAndy Fiddaman.Xr ldd 1 ,
1840*63f6f57bSAndy Fiddaman.Xr mcs 1 ,
1841*63f6f57bSAndy Fiddaman.Xr pvs 1 ,
1842*63f6f57bSAndy Fiddaman.Xr strip 1 ,
1843*63f6f57bSAndy Fiddaman.Xr exec 2 ,
1844*63f6f57bSAndy Fiddaman.Xr stat 2 ,
1845*63f6f57bSAndy Fiddaman.Xr dladdr 3C ,
1846*63f6f57bSAndy Fiddaman.Xr dldump 3C ,
1847*63f6f57bSAndy Fiddaman.Xr dlopen 3C ,
1848*63f6f57bSAndy Fiddaman.Xr malloc 3C ,
1849*63f6f57bSAndy Fiddaman.Xr elf 3ELF ,
1850*63f6f57bSAndy Fiddaman.Xr ar.h 3HEAD ,
1851*63f6f57bSAndy Fiddaman.Xr a.out 5 ,
1852*63f6f57bSAndy Fiddaman.Xr attributes 7
1853*63f6f57bSAndy Fiddaman.Rs
1854*63f6f57bSAndy Fiddaman.%B Linker and Libraries Guide
1855*63f6f57bSAndy Fiddaman.Re
1856*63f6f57bSAndy Fiddaman.Sh NOTES
1857*63f6f57bSAndy FiddamanDefault options applied by
1858*63f6f57bSAndy Fiddaman.Nm
1859*63f6f57bSAndy Fiddamanare maintained for historic reasons.
1860*63f6f57bSAndy FiddamanIn today's programming environment, where dynamic objects dominate, alternative
1861*63f6f57bSAndy Fiddamandefaults would often make more sense.
1862*63f6f57bSAndy FiddamanHowever, historic defaults must be maintained to ensure compatibility with
1863*63f6f57bSAndy Fiddamanexisting program development environments.
1864*63f6f57bSAndy FiddamanHistoric defaults are called out wherever possible in this manual.
1865*63f6f57bSAndy FiddamanFor a description of the current recommended options, see Appendix A,
1866*63f6f57bSAndy Fiddaman.Em Link-Editor Quick Reference ,
1867*63f6f57bSAndy Fiddamanin
1868*63f6f57bSAndy Fiddaman.%T Linker and Libraries Guide .
1869*63f6f57bSAndy Fiddaman.Pp
1870*63f6f57bSAndy FiddamanIf the file being created by
1871*63f6f57bSAndy Fiddaman.Nm
1872*63f6f57bSAndy Fiddamanalready exists, the file is unlinked after all input files have been processed.
1873*63f6f57bSAndy FiddamanA new file with the specified name is then created.
1874*63f6f57bSAndy FiddamanThis allows
1875*63f6f57bSAndy Fiddaman.Nm
1876*63f6f57bSAndy Fiddamanto create a new version of the file, while simultaneously allowing existing
1877*63f6f57bSAndy Fiddamanprocesses that are accessing the old file contents to continue running.
1878*63f6f57bSAndy FiddamanIf the old file has no other links, the disk space of the removed file is freed
1879*63f6f57bSAndy Fiddamanwhen the last process referencing the file terminates.
1880*63f6f57bSAndy Fiddaman.Pp
1881*63f6f57bSAndy FiddamanThe behavior of
1882*63f6f57bSAndy Fiddaman.Nm
1883*63f6f57bSAndy Fiddamanwhen the file being created already exists was changed
1884*63f6f57bSAndy Fiddamanwith SXCE build 43.
1885*63f6f57bSAndy FiddamanIn older versions, the existing file was rewritten in place, an approach with
1886*63f6f57bSAndy Fiddamanthe potential to corrupt any running processes that is using the file.
1887*63f6f57bSAndy FiddamanThis change has an implication for output files that have multiple hard links
1888*63f6f57bSAndy Fiddamanin the file system.
1889*63f6f57bSAndy FiddamanPreviously, all links would remain intact, with all links accessing the new
1890*63f6f57bSAndy Fiddamanfile contents.
1891*63f6f57bSAndy FiddamanThe new
1892*63f6f57bSAndy Fiddaman.Nm
1893*63f6f57bSAndy Fiddamanbehavior
1894*63f6f57bSAndy Fiddaman.Em breaks
1895*63f6f57bSAndy Fiddamansuch links, with the result that only the specified output file name references
1896*63f6f57bSAndy Fiddamanthe new file.
1897*63f6f57bSAndy FiddamanAll the other links continue to reference the old file.
1898*63f6f57bSAndy FiddamanTo ensure consistent behavior, applications that rely on multiple hard links to
1899*63f6f57bSAndy Fiddamanlinker output files should explicitly remove and relink the other file names.
1900