Print this page
Code review comments from jeffpc
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/ld.1
+++ new/usr/src/man/man1/ld.1
1 1 '\" te
2 2 .\" Copyright 1989 AT&T
3 3 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
4 4 .\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved
5 5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
6 6 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
7 7 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 -.TH LD 1 "Sep 10, 2013"
8 +.TH LD 1 "Jun 6, 2016"
9 9 .SH NAME
10 10 ld \- link-editor for object files
11 11 .SH SYNOPSIS
12 12 .LP
13 13 .nf
14 14 \fBld\fR [\fB-32\fR | \fB-64\fR] [\fB-a\fR | \fB-r\fR] [\fB-b\fR] [\fB-B\fRdirect | nodirect]
15 15 [\fB-B\fR dynamic | static] [\fB-B\fR eliminate] [\fB-B\fR group] [\fB-B\fR local]
16 16 [\fB-B\fR reduce] [\fB-B\fR symbolic] [\fB-c\fR \fIname\fR] [\fB-C\fR] [\fB-d\fR y | n]
17 17 [\fB-D\fR \fItoken\fR,...] [\fB-e\fR \fIepsym\fR] [\fB-f\fR \fIname\fR | \fB-F\fR \fIname\fR] [\fB-G\fR] [\fB-h\fR \fIname\fR]
18 18 [\fB-i\fR] [\fB-I\fR \fIname\fR] [\fB-l\fR \fIx\fR] [\fB-L\fR \fIpath\fR] [\fB-m\fR] [\fB-M\fR \fImapfile\fR]
19 19 [\fB-N\fR \fIstring\fR] [\fB-o\fR \fIoutfile\fR] [\fB-p\fR \fIauditlib\fR] [\fB-P\fR \fIauditlib\fR]
20 20 [\fB-Q\fR y | n] [\fB-R\fR \fIpath\fR] [\fB-s\fR] [\fB-S\fR \fIsupportlib\fR] [\fB-t\fR]
21 21 [\fB-u\fR \fIsymname\fR] [\fB-V\fR] [\fB-Y P\fR\fI,dirlist\fR] [\fB-z\fR absexec]
22 22 [\fB-z\fR allextract | defaultextract | weakextract ] [\fB-z\fR altexec64]
23 23 [\fB-z\fR aslr[=\fIstate\fR]] [\fB-z\fR assert-deflib] [ \fB-z\fR assert-deflib=\fIlibname\fR]
24 24 [\fB-z\fR combreloc | nocombreloc ] [\fB-z\fR defs | nodefs]
25 25 [\fB-z\fR direct | nodirect] [\fB-z\fR endfiltee]
26 26 [\fB-z\fR fatal-warnings | nofatal-warnings ] [\fB-z\fR finiarray=\fIfunction\fR]
27 27 [\fB-z\fR globalaudit] [\fB-z\fR groupperm | nogroupperm]
28 28 [\fB-z\fR guidance[=\fIid1\fR,\fIid2\fR...] [\fB-z\fR help ]
29 29 [\fB-z\fR ignore | record] [\fB-z\fR initarray=\fIfunction\fR] [\fB-z\fR initfirst]
30 30 [\fB-z\fR interpose] [\fB-z\fR lazyload | nolazyload]
31 31 [\fB-z\fR ld32=\fIarg1\fR,\fIarg2\fR,...] [\fB-z\fR ld64=\fIarg1\fR,\fIarg2\fR,...]
32 32 [\fB-z\fR loadfltr] [\fB-z\fR muldefs] [\fB-z\fR nocompstrtab] [\fB-z\fR nodefaultlib]
33 33 [\fB-z\fR nodelete] [\fB-z\fR nodlopen] [\fB-z\fR nodump] [\fB-z\fR noldynsym]
34 34 [\fB-z\fR nopartial] [\fB-z\fR noversion] [\fB-z\fR now] [\fB-z\fR origin]
35 35 [\fB-z\fR preinitarray=\fIfunction\fR] [\fB-z\fR redlocsym] [\fB-z\fR relaxreloc]
36 36 [\fB-z\fR rescan-now] [\fB-z\fR recan] [\fB-z\fR rescan-start \fI\&...\fR \fB-z\fR rescan-end]]
37 37 [\fB-z\fR target=sparc|x86] [\fB-z\fR text | textwarn | textoff]
38 38 [\fB-z\fR verbose] [\fB-z\fR wrap=\fIsymbol\fR] \fIfilename\fR...
39 39 .fi
40 40
41 41 .SH DESCRIPTION
42 42 .LP
43 43 The link-editor, \fBld\fR, combines relocatable object files by resolving
44 44 symbol references to symbol definitions, together with performing relocations.
45 45 \fBld\fR operates in two modes, static or dynamic, as governed by the \fB-d\fR
46 46 option. In all cases, the output of \fBld\fR is left in the file \fBa.out\fR by
47 47 default. See NOTES.
48 48 .sp
49 49 .LP
50 50 In dynamic mode, \fB-dy\fR, the default, relocatable object files that are
51 51 provided as arguments are combined to produce an executable object file. This
52 52 file is linked at execution with any shared object files that are provided as
53 53 arguments. If the \fB-G\fR option is specified, relocatable object files are
54 54 combined to produce a shared object. Without the \fB-G\fR option, a dynamic
55 55 executable is created.
56 56 .sp
57 57 .LP
58 58 In static mode, \fB-dn\fR, relocatable object files that are provided as
59 59 arguments are combined to produce a static executable file. If the \fB-r\fR
60 60 option is specified, relocatable object files are combined to produce one
61 61 relocatable object file. See \fBStatic Executables\fR.
62 62 .sp
63 63 .LP
64 64 Dynamic linking is the most common model for combining relocatable objects, and
65 65 the eventual creation of processes within Solaris. This environment tightly
66 66 couples the work of the link-editor and the runtime linker, \fBld.so.1\fR(1).
67 67 Both of these utilities, together with their related technologies and
68 68 utilities, are extensively documented in the \fILinker and Libraries Guide\fR.
69 69 .sp
70 70 .LP
71 71 If any argument is a library, \fBld\fR by default searches the library exactly
72 72 once at the point the library is encountered on the argument list. The library
73 73 can be either a shared object or relocatable archive. See \fBar.h\fR(3HEAD)).
74 74 .sp
75 75 .LP
76 76 A shared object consists of an indivisible, whole unit that has been generated
77 77 by a previous link-edit of one or more input files. When the link-editor
78 78 processes a shared object, the entire contents of the shared object become a
79 79 logical part of the resulting output file image. The shared object is not
80 80 physically copied during the link-edit as its actual inclusion is deferred
81 81 until process execution. This logical inclusion means that all symbol entries
82 82 defined in the shared object are made available to the link-editing process.
83 83 See Chapter 4, \fIShared Objects,\fR in \fILinker and Libraries Guide\fR
84 84 .sp
85 85 .LP
86 86 For an archive library, \fBld\fR loads only those routines that define an
87 87 unresolved external reference. \fBld\fR searches the symbol table of the
88 88 archive library sequentially to resolve external references that can be
89 89 satisfied by library members. This search is repeated until no external
90 90 references can be resolved by the archive. Thus, the order of members in the
91 91 library is functionally unimportant, unless multiple library members exist that
92 92 define the same external symbol. Archive libraries that have interdependencies
93 93 can require multiple command line definitions, or the use of one of the
94 94 \fB-z\fR \fBrescan\fR options. See \fIArchive Processing\fR in \fILinker and
95 95 Libraries Guide\fR.
96 96 .sp
97 97 .LP
98 98 \fBld\fR is a cross link-editor, able to link 32-bit objects or 64-bit objects,
99 99 for Sparc or x86 targets. \fBld\fR uses the \fBELF\fR class and machine type of
100 100 the first relocatable object on the command line to govern the mode in which to
101 101 operate. The mixing of 32-bit objects and 64-bit objects is not permitted.
102 102 Similarly, only objects of a single machine type are allowed. See the
103 103 \fB-32\fR, \fB-64\fR and \fB-z target\fR options, and the \fBLD_NOEXEC_64\fR
104 104 environment variable.
105 105 .SS "Static Executables"
106 106 .LP
107 107 The creation of static executables has been discouraged for many releases. In
108 108 fact, 64-bit system archive libraries have never been provided. Because a
109 109 static executable is built against system archive libraries, the executable
110 110 contains system implementation details. This self-containment has a number of
111 111 drawbacks.
112 112 .RS +4
113 113 .TP
114 114 .ie t \(bu
115 115 .el o
116 116 The executable is immune to the benefits of system patches delivered as shared
117 117 objects. The executable therefore, must be rebuilt to take advantage of many
118 118 system improvements.
119 119 .RE
120 120 .RS +4
121 121 .TP
122 122 .ie t \(bu
123 123 .el o
124 124 The ability of the executable to run on future releases can be compromised.
125 125 .RE
126 126 .RS +4
127 127 .TP
128 128 .ie t \(bu
129 129 .el o
130 130 The duplication of system implementation details negatively affects system
131 131 performance.
132 132 .RE
133 133 .sp
134 134 .LP
135 135 With Solaris 10, 32-bit system archive libraries are no longer provided.
136 136 Without these libraries, specifically \fBlibc.a\fR, the creation of static
137 137 executables is no longer achievable without specialized system knowledge.
138 138 However, the capability of \fBld\fR to process static linking options, and the
139 139 processing of archive libraries, remains unchanged.
140 140 .SH OPTIONS
141 141 .LP
142 142 The following options are supported.
143 143 .sp
144 144 .ne 2
145 145 .na
146 146 \fB\fB-32\fR | \fB-64\fR\fR
147 147 .ad
148 148 .sp .6
149 149 .RS 4n
150 150 Creates a 32-bit, or 64-bit object.
151 151 .sp
152 152 By default, the class of the object being generated is determined from the
153 153 first \fBELF\fR object processed from the command line. If no objects are
154 154 specified, the class is determined by the first object encountered within the
155 155 first archive processed from the command line. If there are no objects or
156 156 archives, the link-editor creates a 32-bit object.
157 157 .sp
158 158 The \fB-64\fR option is required to create a 64-bit object solely from a
159 159 mapfile.
160 160 .sp
161 161 This \fB-32\fR or \fB-64\fR options can also be used in the rare case of
162 162 linking entirely from an archive that contains a mixture of 32 and 64-bit
163 163 objects. If the first object in the archive is not the class of the object that
164 164 is required to be created, then the \fB-32\fR or \fB-64\fR option can be used
165 165 to direct the link-editor. See \fIThe 32-bit link-editor and 64-bit
166 166 link-editor\fR in \fILinker and Libraries Guide\fR.
167 167 .RE
168 168
169 169 .sp
170 170 .ne 2
171 171 .na
172 172 \fB\fB-a\fR\fR
173 173 .ad
174 174 .sp .6
175 175 .RS 4n
176 176 In static mode only, produces an executable object file. Undefined references
177 177 are not permitted. This option is the default behavior for static mode. The
178 178 \fB-a\fR option can not be used with the \fB-r\fR option. See \fBStatic
179 179 Executables\fR under DESCRIPTION.
180 180 .RE
181 181
182 182 .sp
183 183 .ne 2
184 184 .na
185 185 \fB\fB-b\fR\fR
186 186 .ad
187 187 .sp .6
188 188 .RS 4n
189 189 In dynamic mode only, provides no special processing for dynamic executable
190 190 relocations that reference symbols in shared objects. Without the \fB-b\fR
191 191 option, the link-editor applies techniques within a dynamic executable so that
192 192 the text segment can remain read-only. One technique is the creation of special
193 193 position-independent relocations for references to functions that are defined
194 194 in shared objects. Another technique arranges for data objects that are defined
195 195 in shared objects to be copied into the memory image of an executable at
196 196 runtime.
197 197 .sp
198 198 The \fB-b\fR option is intended for specialized dynamic objects and is not
199 199 recommended for general use. Its use suppresses all specialized processing
200 200 required to ensure an object's shareability, and can even prevent the
201 201 relocation of 64-bit executables.
202 202 .RE
203 203
204 204 .sp
205 205 .ne 2
206 206 .na
207 207 \fB\fB-B\fR \fBdirect\fR | \fBnodirect\fR\fR
208 208 .ad
209 209 .sp .6
210 210 .RS 4n
211 211 These options govern direct binding. \fB-B\fR \fBdirect\fR establishes direct
212 212 binding information by recording the relationship between each symbol reference
213 213 together with the dependency that provides the definition. In addition, direct
214 214 binding information is established between each symbol reference and an
215 215 associated definition within the object being created. The runtime linker uses
216 216 this information to search directly for a symbol in the associated object
217 217 rather than to carry out a default symbol search.
218 218 .sp
219 219 Direct binding information can only be established to dependencies specified
220 220 with the link-edit. Thus, you should use the \fB-z\fR \fBdefs\fR option.
221 221 Objects that wish to interpose on symbols in a direct binding environment
222 222 should identify themselves as interposers with the \fB-z\fR \fBinterpose\fR
223 223 option. The use of \fB-B\fR \fBdirect\fR enables \fB-z\fR \fBlazyload\fR for
224 224 all dependencies.
225 225 .sp
226 226 The \fB-B\fR \fBnodirect\fR option prevents any direct binding to the
227 227 interfaces offered by the object being created. The object being created can
228 228 continue to directly bind to external interfaces by specifying the \fB-z\fR
229 229 \fBdirect\fR option. See Appendix D, \fIDirect Bindings,\fR in \fILinker and
230 230 Libraries Guide\fR.
231 231 .RE
232 232
233 233 .sp
234 234 .ne 2
235 235 .na
236 236 \fB\fB-B\fR \fBdynamic\fR | \fBstatic\fR\fR
237 237 .ad
238 238 .sp .6
239 239 .RS 4n
240 240 Options governing library inclusion. \fB-B\fR \fBdynamic\fR is valid in dynamic
241 241 mode only. These options can be specified any number of times on the command
242 242 line as toggles: if the \fB-B\fR \fBstatic\fR option is given, no shared
243 243 objects are accepted until \fB-B\fR \fBdynamic\fR is seen. See the \fB-l\fR
244 244 option.
245 245 .RE
246 246
247 247 .sp
248 248 .ne 2
249 249 .na
250 250 \fB\fB-B\fR \fBeliminate\fR\fR
251 251 .ad
252 252 .sp .6
253 253 .RS 4n
254 254 Causes any global symbols, not assigned to a version definition, to be
255 255 eliminated from the symbol table. Version definitions can be supplied by means
256 256 of a \fBmapfile\fR to indicate the global symbols that should remain visible in
257 257 the generated object. This option achieves the same symbol elimination as the
258 258 \fIauto-elimination\fR directive that is available as part of a \fBmapfile\fR
259 259 version definition. This option can be useful when combining versioned and
260 260 non-versioned relocatable objects. See also the \fB-B\fR \fBlocal\fR option and
261 261 the \fB-B\fR \fBreduce\fR option. See \fIDefining Additional Symbols with a
262 262 mapfile\fR in \fILinker and Libraries Guide\fR.
263 263 .RE
264 264
265 265 .sp
266 266 .ne 2
267 267 .na
268 268 \fB\fB-B\fR \fBgroup\fR\fR
269 269 .ad
270 270 .sp .6
271 271 .RS 4n
272 272 Establishes a shared object and its dependencies as a group. Objects within the
273 273 group are bound to other members of the group at runtime. This mode is similar
274 274 to adding the object to the process by using \fBdlopen\fR(3C) with the
275 275 \fBRTLD_GROUP\fR mode. An object that has an explicit dependency on a object
276 276 identified as a group, becomes a member of the group.
277 277 .sp
278 278 As the group must be self contained, use of the \fB-B\fR \fBgroup\fR option
279 279 also asserts the \fB-z\fR \fBdefs\fR option.
280 280 .RE
281 281
282 282 .sp
283 283 .ne 2
284 284 .na
285 285 \fB\fB-B\fR \fBlocal\fR\fR
286 286 .ad
287 287 .sp .6
288 288 .RS 4n
289 289 Causes any global symbols, not assigned to a version definition, to be reduced
290 290 to local. Version definitions can be supplied by means of a \fBmapfile\fR to
291 291 indicate the global symbols that should remain visible in the generated object.
292 292 This option achieves the same symbol reduction as the \fIauto-reduction\fR
293 293 directive that is available as part of a \fBmapfile\fR version definition. This
294 294 option can be useful when combining versioned and non-versioned relocatable
295 295 objects. See also the \fB-B\fR \fBeliminate\fR option and the \fB-B\fR
296 296 \fBreduce\fR option. See \fIDefining Additional Symbols with a mapfile\fR in
297 297 \fILinker and Libraries Guide\fR.
298 298 .RE
299 299
300 300 .sp
301 301 .ne 2
302 302 .na
303 303 \fB\fB-B\fR \fBreduce\fR\fR
304 304 .ad
305 305 .sp .6
306 306 .RS 4n
307 307 When generating a relocatable object, causes the reduction of symbolic
308 308 information defined by any version definitions. Version definitions can be
309 309 supplied by means of a \fBmapfile\fR to indicate the global symbols that should
310 310 remain visible in the generated object. By default, when a relocatable object
311 311 is generated, version definitions are only recorded in the output image. The
312 312 actual reduction of symbolic information is carried out when the object is used
313 313 in the construction of a dynamic executable or shared object. The \fB-B\fR
314 314 \fBreduce\fR option is applied automatically when a dynamic executable or
315 315 shared object is created.
316 316 .RE
317 317
318 318 .sp
319 319 .ne 2
320 320 .na
321 321 \fB\fB-B\fR \fBsymbolic\fR\fR
322 322 .ad
323 323 .sp .6
324 324 .RS 4n
325 325 In dynamic mode only. When building a shared object, binds references to global
326 326 symbols to their definitions, if available, within the object. Normally,
327 327 references to global symbols within shared objects are not bound until runtime,
328 328 even if definitions are available. This model allows definitions of the same
329 329 symbol in an executable or other shared object to override the object's own
330 330 definition. \fBld\fR issues warnings for undefined symbols unless \fB-z\fR
331 331 \fBdefs\fR overrides.
332 332 .sp
333 333 The \fB-B\fR \fBsymbolic\fR option is intended for specialized dynamic objects
334 334 and is not recommended for general use. To reduce the runtime relocation
335 335 processing that is required an object, the creation of a version definition is
336 336 recommended.
337 337 .RE
338 338
339 339 .sp
340 340 .ne 2
341 341 .na
342 342 \fB\fB-c\fR \fIname\fR\fR
343 343 .ad
344 344 .sp .6
345 345 .RS 4n
346 346 Records the configuration file \fIname\fR for use at runtime. Configuration
347 347 files can be employed to alter default search paths, provide a directory cache,
348 348 together with providing alternative object dependencies. See \fBcrle\fR(1).
349 349 .RE
350 350
351 351 .sp
352 352 .ne 2
353 353 .na
354 354 \fB\fB-C\fR\fR
355 355 .ad
356 356 .sp .6
357 357 .RS 4n
358 358 Demangles C++ symbol names displayed in diagnostic messages.
359 359 .RE
360 360
361 361 .sp
362 362 .ne 2
363 363 .na
364 364 \fB\fB-d\fR \fBy\fR | \fBn\fR\fR
365 365 .ad
366 366 .sp .6
367 367 .RS 4n
368 368 When \fB-d\fR \fBy\fR, the default, is specified, \fBld\fR uses dynamic
369 369 linking. When \fB-d\fR \fBn\fR is specified, \fBld\fR uses static linking. See
370 370 \fBStatic Executables\fR under DESCRIPTION, and \fB-B\fR
371 371 \fBdynamic\fR|\fBstatic\fR.
372 372 .RE
373 373
374 374 .sp
375 375 .ne 2
376 376 .na
377 377 \fB\fB-D\fR \fItoken\fR,...\fR
378 378 .ad
379 379 .sp .6
380 380 .RS 4n
381 381 Prints debugging information as specified by each \fItoken\fR, to the standard
382 382 error. The special token \fBhelp\fR indicates the full list of tokens
383 383 available. See \fIDebugging Aids\fR in \fILinker and Libraries Guide\fR.
384 384 .RE
385 385
386 386 .sp
387 387 .ne 2
388 388 .na
389 389 \fB\fB-e\fR \fIepsym\fR\fR
390 390 .ad
391 391 .br
392 392 .na
393 393 \fB\fB--entry\fR \fIepsym\fR\fR
394 394 .ad
395 395 .sp .6
396 396 .RS 4n
397 397 Sets the entry point address for the output file to be the symbol \fIepsym\fR.
398 398 .RE
399 399
400 400 .sp
401 401 .ne 2
402 402 .na
403 403 \fB\fB-f\fR \fIname\fR\fR
404 404 .ad
405 405 .br
406 406 .na
407 407 \fB\fB--auxiliary\fR \fIname\fR\fR
408 408 .ad
409 409 .sp .6
410 410 .RS 4n
411 411 Useful only when building a shared object. Specifies that the symbol table of
412 412 the shared object is used as an auxiliary filter on the symbol table of the
413 413 shared object specified by \fIname\fR. Multiple instances of this option are
414 414 allowed. This option can not be combined with the \fB-F\fR option. See
415 415 \fIGenerating Auxiliary Filters\fR in \fILinker and Libraries Guide\fR.
416 416 .RE
417 417
418 418 .sp
419 419 .ne 2
420 420 .na
421 421 \fB\fB-F\fR \fIname\fR\fR
422 422 .ad
423 423 .br
424 424 .na
425 425 \fB\fB--filter\fR \fIname\fR\fR
426 426 .ad
427 427 .sp .6
428 428 .RS 4n
429 429 Useful only when building a shared object. Specifies that the symbol table of
430 430 the shared object is used as a filter on the symbol table of the shared object
431 431 specified by \fIname\fR. Multiple instances of this option are allowed. This
432 432 option can not be combined with the \fB-f\fR option. See \fIGenerating Standard
433 433 Filters\fR in \fILinker and Libraries Guide\fR.
434 434 .RE
435 435
436 436 .sp
437 437 .ne 2
438 438 .na
439 439 \fB\fB-G\fR\fR
440 440 .ad
441 441 .br
442 442 .na
443 443 \fB\fB-shared\fR\fR
444 444 .ad
445 445 .sp .6
446 446 .RS 4n
447 447 In dynamic mode only, produces a shared object. Undefined symbols are allowed.
448 448 See Chapter 4, \fIShared Objects,\fR in \fILinker and Libraries Guide\fR.
449 449 .RE
450 450
451 451 .sp
452 452 .ne 2
453 453 .na
454 454 \fB\fB-h\fR \fIname\fR\fR
455 455 .ad
456 456 .br
457 457 .na
458 458 \fB\fB--soname\fR \fIname\fR\fR
459 459 .ad
460 460 .sp .6
461 461 .RS 4n
462 462 In dynamic mode only, when building a shared object, records \fIname\fR in the
463 463 object's dynamic section. \fIname\fR is recorded in any dynamic objects that
464 464 are linked with this object rather than the object's file system name.
465 465 Accordingly, \fIname\fR is used by the runtime linker as the name of the shared
466 466 object to search for at runtime. See \fIRecording a Shared Object Name\fR in
467 467 \fILinker and Libraries Guide\fR.
468 468 .RE
469 469
470 470 .sp
471 471 .ne 2
472 472 .na
473 473 \fB\fB-i\fR\fR
474 474 .ad
475 475 .sp .6
476 476 .RS 4n
477 477 Ignores \fBLD_LIBRARY_PATH\fR. This option is useful when an
478 478 \fBLD_LIBRARY_PATH\fR setting is in effect to influence the runtime library
479 479 search, which would interfere with the link-editing being performed.
480 480 .RE
481 481
482 482 .sp
483 483 .ne 2
484 484 .na
485 485 \fB\fB-I\fR \fIname\fR\fR
486 486 .ad
487 487 .br
488 488 .na
489 489 \fB\fB--dynamic-linker\fR \fIname\fR\fR
490 490 .ad
491 491 .sp .6
492 492 .RS 4n
493 493 When building an executable, uses \fIname\fR as the path name of the
494 494 interpreter to be written into the program header. The default in static mode
495 495 is no interpreter. In dynamic mode, the default is the name of the runtime
496 496 linker, \fBld.so.1\fR(1). Either case can be overridden by \fB-I\fR \fIname\fR.
497 497 \fBexec\fR(2) loads this interpreter when the \fBa.out\fR is loaded, and passes
498 498 control to the interpreter rather than to the \fBa.out\fR directly.
499 499 .RE
500 500
501 501 .sp
502 502 .ne 2
503 503 .na
504 504 \fB\fB-l\fR \fIx\fR\fR
505 505 .ad
506 506 .br
507 507 .na
508 508 \fB\fB--library\fR \fIx\fR\fR
509 509 .ad
510 510 .sp .6
511 511 .RS 4n
512 512 Searches a library \fBlib\fR\fIx\fR\fB\&.so\fR or \fBlib\fR\fIx\fR\fB\&.a\fR,
513 513 the conventional names for shared object and archive libraries, respectively.
514 514 In dynamic mode, unless the \fB-B\fR \fBstatic\fR option is in effect, \fBld\fR
515 515 searches each directory specified in the library search path for a
516 516 \fBlib\fR\fIx\fR\fB\&.so\fR or \fBlib\fR\fIx\fR\fB\&.a\fR file. The directory
517 517 search stops at the first directory containing either. \fBld\fR chooses the
518 518 file ending in \fB\&.so\fR if \fB-l\fR\fIx\fR expands to two files with names
519 519 of the form \fBlib\fR\fIx\fR\fB\&.so\fR and \fBlib\fR\fIx\fR\fB\&.a\fR. If no
520 520 \fBlib\fR\fIx\fR\fB\&.so\fR is found, then \fBld\fR accepts
521 521 \fBlib\fR\fIx\fR\fB\&.a\fR. In static mode, or when the \fB-B\fR \fBstatic\fR
522 522 option is in effect, \fBld\fR selects only the file ending in \fB\&.a\fR.
523 523 \fBld\fR searches a library when the library is encountered, so the placement
524 524 of \fB-l\fR is significant. See \fILinking With Additional Libraries\fR in
525 525 \fILinker and Libraries Guide\fR.
526 526 .RE
527 527
528 528 .sp
529 529 .ne 2
530 530 .na
531 531 \fB\fB-L\fR \fIpath\fR\fR
532 532 .ad
533 533 .br
534 534 .na
535 535 \fB\fB--library-path\fR \fIpath\fR\fR
536 536 .ad
537 537 .sp .6
538 538 .RS 4n
539 539 Adds \fIpath\fR to the library search directories. \fBld\fR searches for
540 540 libraries first in any directories specified by the \fB-L\fR options and then
541 541 in the standard directories. This option is useful only if the option precedes
542 542 the \fB-l\fR options to which the \fB-L\fR option applies. See \fIDirectories
543 543 Searched by the Link-Editor\fR in \fILinker and Libraries Guide\fR.
544 544 .sp
545 545 The environment variable \fBLD_LIBRARY_PATH\fR can be used to supplement the
546 546 library search path, however the \fB-L\fR option is recommended, as the
547 547 environment variable is also interpreted by the runtime environment. See
548 548 \fBLD_LIBRARY_PATH\fR under ENVIRONMENT VARIABLES.
549 549 .RE
550 550
551 551 .sp
552 552 .ne 2
553 553 .na
554 554 \fB\fB-m\fR\fR
555 555 .ad
556 556 .sp .6
557 557 .RS 4n
558 558 Produces a memory map or listing of the input/output sections, together with
559 559 any non-fatal multiply-defined symbols, on the standard output.
560 560 .RE
561 561
562 562 .sp
563 563 .ne 2
564 564 .na
565 565 \fB\fB-M\fR \fImapfile\fR\fR
566 566 .ad
567 567 .sp .6
568 568 .RS 4n
569 569 Reads \fImapfile\fR as a text file of directives to \fBld\fR. This option can
570 570 be specified multiple times. If \fImapfile\fR is a directory, then all regular
571 571 files, as defined by \fBstat\fR(2), within the directory are processed. See
572 572 Chapter 9, \fIMapfile Option,\fR in \fILinker and Libraries Guide\fR. Example
573 573 mapfiles are provided in \fB/usr/lib/ld\fR. See FILES.
574 574 .RE
575 575
576 576 .sp
577 577 .ne 2
578 578 .na
579 579 \fB\fB-N\fR \fIstring\fR\fR
580 580 .ad
581 581 .sp .6
582 582 .RS 4n
583 583 This option causes a \fBDT_NEEDED\fR entry to be added to the \fB\&.dynamic\fR
584 584 section of the object being built. The value of the \fBDT_NEEDED\fR string is
585 585 the \fIstring\fR that is specified on the command line. This option is position
586 586 dependent, and the \fBDT_NEEDED\fR \fB\&.dynamic\fR entry is relative to the
587 587 other dynamic dependencies discovered on the link-edit line. This option is
588 588 useful for specifying dependencies within device driver relocatable objects
589 589 when combined with the \fB-dy\fR and \fB-r\fR options.
590 590 .RE
591 591
592 592 .sp
593 593 .ne 2
594 594 .na
595 595 \fB\fB-o\fR \fIoutfile\fR\fR
596 596 .ad
597 597 .br
598 598 .na
599 599 \fB\fB--output\fR \fIoutfile\fR\fR
600 600 .ad
601 601 .sp .6
602 602 .RS 4n
603 603 Produces an output object file that is named \fIoutfile\fR. The name of the
604 604 default object file is \fBa.out\fR.
605 605 .RE
606 606
607 607 .sp
608 608 .ne 2
609 609 .na
610 610 \fB\fB-p\fR \fIauditlib\fR\fR
611 611 .ad
612 612 .sp .6
613 613 .RS 4n
614 614 Identifies an audit library, \fIauditlib\fR. This audit library is used to
615 615 audit the object being created at runtime. A shared object identified as
616 616 requiring auditing with the \fB-p\fR option, has this requirement inherited by
617 617 any object that specifies the shared object as a dependency. See the \fB-P\fR
618 618 option. See \fIRuntime Linker Auditing Interface\fR in \fILinker and Libraries
619 619 Guide\fR.
620 620 .RE
621 621
622 622 .sp
623 623 .ne 2
624 624 .na
625 625 \fB\fB-P\fR \fIauditlib\fR\fR
626 626 .ad
627 627 .sp .6
628 628 .RS 4n
629 629 Identifies an audit library, \fIauditlib\fR. This audit library is used to
630 630 audit the dependencies of the object being created at runtime. Dependency
631 631 auditing can also be inherited from dependencies that are identified as
632 632 requiring auditing. See the \fB-p\fR option, and the \fB-z\fR \fBglobalaudit\fR
633 633 option. See \fIRuntime Linker Auditing Interface\fR in \fILinker and Libraries
634 634 Guide\fR.
635 635 .RE
636 636
637 637 .sp
638 638 .ne 2
639 639 .na
640 640 \fB\fB-Q\fR \fBy\fR | \fBn\fR\fR
641 641 .ad
642 642 .sp .6
643 643 .RS 4n
644 644 Under \fB-Q\fR \fBy\fR, an \fBident\fR string is added to the \fB\&.comment\fR
645 645 section of the output file. This string identifies the version of the \fBld\fR
646 646 used to create the file. This results in multiple \fBld\fR \fBidents\fR when
647 647 there have been multiple linking steps, such as when using \fBld\fR \fB-r\fR.
648 648 This identification is identical with the default action of the \fBcc\fR
649 649 command. \fB-Q\fR \fBn\fR suppresses version identification. \fB\&.comment\fR
650 650 sections can be manipulated by the \fBmcs\fR(1) utility.
651 651 .RE
652 652
653 653 .sp
654 654 .ne 2
655 655 .na
656 656 \fB\fB-r\fR\fR
657 657 .ad
658 658 .br
659 659 .na
660 660 \fB\fB--relocatable\fR\fR
661 661 .ad
662 662 .sp .6
663 663 .RS 4n
664 664 Combines relocatable object files to produce one relocatable object file.
665 665 \fBld\fR does not complain about unresolved references. This option cannot be
666 666 used with the \fB-a\fR option.
667 667 .RE
668 668
669 669 .sp
670 670 .ne 2
671 671 .na
672 672 \fB\fB-R\fR \fIpath\fR\fR
673 673 .ad
674 674 .br
675 675 .na
676 676 \fB\fB-rpath\fR \fIpath\fR\fR
677 677 .ad
678 678 .sp .6
679 679 .RS 4n
680 680 A colon-separated list of directories used to specify library search
681 681 directories to the runtime linker. If present and not NULL, the path is
682 682 recorded in the output object file and passed to the runtime linker. Multiple
683 683 instances of this option are concatenated together with each \fIpath\fR
684 684 separated by a colon. See \fIDirectories Searched by the Runtime Linker\fR in
685 685 \fILinker and Libraries Guide\fR.
686 686 .sp
687 687 The use of a runpath within an associated object is preferable to setting
688 688 global search paths such as through the \fBLD_LIBRARY_PATH\fR environment
689 689 variable. Only the runpaths that are necessary to find the objects dependencies
690 690 should be recorded. \fBldd\fR(1) can also be used to discover unused runpaths
691 691 in dynamic objects, when used with the \fB-U\fR option.
692 692 .sp
693 693 Various tokens can also be supplied with a runpath that provide a flexible
694 694 means of identifying system capabilities or an objects location. See Appendix
695 695 C, \fIEstablishing Dependencies with Dynamic String Tokens,\fR in \fILinker and
696 696 Libraries Guide\fR. The \fB$ORIGIN\fR token is especially useful in allowing
697 697 dynamic objects to be relocated to different locations in the file system.
698 698 .RE
699 699
700 700 .sp
701 701 .ne 2
702 702 .na
703 703 \fB\fB-s\fR\fR
704 704 .ad
705 705 .br
706 706 .na
707 707 \fB\fB--strip-all\fR\fR
708 708 .ad
709 709 .sp .6
710 710 .RS 4n
711 711 Strips symbolic information from the output file. Any debugging information,
712 712 that is, \fB\&.line\fR, \fB\&.debug*\fR, and \fB\&.stab*\fR sections, and their
713 713 associated relocation entries are removed. Except for relocatable files, a
714 714 symbol table \fBSHT_SYMTAB\fR and its associated string table section are not
715 715 created in the output object file. The elimination of a \fBSHT_SYMTAB\fR symbol
716 716 table can reduce the \fB\&.stab*\fR debugging information that is generated
717 717 using the compiler drivers \fB-g\fR option. See the \fB-z\fR \fBredlocsym\fR
718 718 and \fB-z\fR \fBnoldynsym\fR options.
719 719 .RE
720 720
721 721 .sp
722 722 .ne 2
723 723 .na
724 724 \fB\fB-S\fR \fIsupportlib\fR\fR
725 725 .ad
726 726 .sp .6
727 727 .RS 4n
728 728 The shared object \fIsupportlib\fR is loaded with \fBld\fR and given
729 729 information regarding the linking process. Shared objects that are defined by
730 730 using the \fB-S\fR option can also be supplied using the \fBSGS_SUPPORT\fR
731 731 environment variable. See \fILink-Editor Support Interface\fR in \fILinker and
732 732 Libraries Guide\fR.
733 733 .RE
734 734
735 735 .sp
736 736 .ne 2
737 737 .na
738 738 \fB\fB-t\fR\fR
739 739 .ad
740 740 .sp .6
741 741 .RS 4n
742 742 Turns off the warning for multiply-defined symbols that have different sizes or
743 743 different alignments.
744 744 .RE
745 745
746 746 .sp
747 747 .ne 2
748 748 .na
749 749 \fB\fB-u\fR \fIsymname\fR\fR
750 750 .ad
751 751 .br
752 752 .na
753 753 \fB\fB--undefined\fR \fIsymname\fR\fR
754 754 .ad
755 755 .sp .6
756 756 .RS 4n
757 757 Enters \fIsymname\fR as an undefined symbol in the symbol table. This option is
758 758 useful for loading entirely from an archive library. In this instance, an
759 759 unresolved reference is needed to force the loading of the first routine. The
760 760 placement of this option on the command line is significant. This option must
761 761 be placed before the library that defines the symbol. See \fIDefining
762 762 Additional Symbols with the u option\fR in \fILinker and Libraries Guide\fR.
763 763 .RE
764 764
765 765 .sp
766 766 .ne 2
767 767 .na
768 768 \fB\fB-V\fR\fR
769 769 .ad
770 770 .br
771 771 .na
772 772 \fB\fB--version\fR\fR
773 773 .ad
774 774 .sp .6
775 775 .RS 4n
776 776 Outputs a message giving information about the version of \fBld\fR being used.
777 777 .RE
778 778
779 779 .sp
780 780 .ne 2
781 781 .na
782 782 \fB\fB-Y\fR \fBP,\fR\fIdirlist\fR\fR
783 783 .ad
784 784 .sp .6
785 785 .RS 4n
786 786 Changes the default directories used for finding libraries. \fIdirlist\fR is a
787 787 colon-separated path list.
788 788 .RE
789 789
790 790 .sp
791 791 .ne 2
792 792 .na
793 793 \fB\fB-z\fR \fBabsexec\fR\fR
794 794 .ad
795 795 .sp .6
796 796 .RS 4n
797 797 Useful only when building a dynamic executable. Specifies that references to
798 798 external absolute symbols should be resolved immediately instead of being left
799 799 for resolution at runtime. In very specialized circumstances, this option
800 800 removes text relocations that can result in excessive swap space demands by an
801 801 executable.
802 802 .RE
803 803
804 804 .sp
805 805 .ne 2
806 806 .na
807 807 \fB\fB-z\fR \fBallextract\fR | \fBdefaultextract\fR | \fBweakextract\fR\fR
808 808 .ad
809 809 .br
810 810 .na
811 811 \fB\fB--whole-archive\fR | \fB--no-whole-archive\fR\fR
812 812 .ad
813 813 .sp .6
814 814 .RS 4n
815 815 Alters the extraction criteria of objects from any archives that follow. By
816 816 default, archive members are extracted to satisfy undefined references and to
817 817 promote tentative definitions with data definitions. Weak symbol references do
818 818 not trigger extraction. Under the \fB-z\fR \fBallextract\fR or
819 819 \fB--whole-archive\fR options, all archive members are extracted from the
820 820 archive. Under \fB-z\fR \fBweakextract\fR, weak references trigger archive
821 821 extraction. The \fB-z\fR \fBdefaultextract\fR or \fB--no-whole-archive\fR
822 822 options provide a means of returning to the default following use of the former
823 823 extract options. See \fIArchive Processing\fR in \fILinker and Libraries
824 824 Guide\fR.
825 825 .RE
826 826
827 827 .sp
828 828 .ne 2
829 829 .na
830 830 \fB\fB-z\fR \fBaltexec64\fR\fR
831 831 .ad
832 832 .sp .6
833 833 .RS 4n
834 834 Execute the 64-bit \fBld\fR. The creation of very large 32-bit objects can
835 835 exhaust the virtual memory that is available to the 32-bit \fBld\fR. The
836 836 \fB-z\fR \fBaltexec64\fR option can be used to force the use of the associated
837 837 64-bit \fBld\fR. The 64-bit \fBld\fR provides a larger virtual address space
838 838 for building 32-bit objects. See \fIThe 32-bit link-editor and 64-bit
839 839 link-editor\fR in \fILinker and Libraries Guide\fR.
840 840 .RE
841 841
842 842 .sp
843 843 .ne 2
844 844 .na
845 845 \fB-z\fR \fBaslr[=\fIstate\fR]\fR
846 846 .ad
847 847 .sp .6
848 848 .RS 4n
849 849 Specify whether the executable's address space should be randomized on
850 850 execution. If \fIstate\fR is "enabled" randomization will always occur when
851 851 this executable is run (regardless of inherited settings). If \fIstate\fR is
852 852 "disabled" randomization will never occur when this executable is run. If
853 853 \fIstate\fR is omitted, ASLR is enabled.
854 854
855 855 An executable that should simply use the settings inherited from its
856 856 environment should not use this flag at all.
857 857 .RE
858 858
859 859 .sp
860 860 .ne 2
861 861 .na
862 862 \fB\fB-z\fR \fBcombreloc\fR | \fBnocombreloc\fR\fR
863 863 .ad
864 864 .sp .6
865 865 .RS 4n
866 866 By default, \fBld\fR combines multiple relocation sections when building
867 867 executables or shared objects. This section combination differs from
868 868 relocatable objects, in which relocation sections are maintained in a
869 869 one-to-one relationship with the sections to which the relocations must be
870 870 applied. The \fB-z\fR \fBnocombreloc\fR option disables this merging of
871 871 relocation sections, and preserves the one-to-one relationship found in the
872 872 original relocatable objects.
873 873 .sp
874 874 \fBld\fR sorts the entries of data relocation sections by their symbol
875 875 reference. This sorting reduces runtime symbol lookup. When multiple relocation
876 876 sections are combined, this sorting produces the least possible relocation
877 877 overhead when objects are loaded into memory, and speeds the runtime loading of
878 878 dynamic objects.
879 879 .sp
880 880 Historically, the individual relocation sections were carried over to any
881 881 executable or shared object, and the \fB-z\fR \fBcombreloc\fR option was
882 882 required to enable the relocation section merging previously described.
883 883 Relocation section merging is now the default. The \fB-z\fR \fBcombreloc\fR
884 884 option is still accepted for the benefit of old build environments, but the
885 885 option is unnecessary, and has no effect.
886 886 .RE
887 887
888 888 .sp
889 889 .ne 2
890 890 .na
891 891 \fB\fB-z\fR \fBassert-deflib\fR\fR
892 892 .ad
893 893 .br
894 894 .na
895 895 \fB\fB-z\fR \fBassert-deflib=\fR\fIlibname\fR\fR
896 896 .ad
897 897 .sp .6
898 898 .RS 4n
899 899 Enables warnings that check the location of where libraries passed in with
900 900 \fB-l\fR are found. If the link-editor finds a library on its default search
901 901 path it will emit a warning. This warning can be made fatal in conjunction with
902 902 the option \fB-z fatal-warnings\fR. Passing \fIlibname\fR white lists a library
903 903 from this check. The library must be the full name of the library, e.g.
904 904 \fIlibc.so\fR. To white list multiple libraries, the \fB-z
905 905 assert-deflib=\fR\fIlibname\fR option can be repeated multiple times. This
906 906 option is useful when trying to build self-contained objects where a referenced
907 907 library might exist in the default system library path and in alternate paths
908 908 specified by \fB-L\fR, but you only want the alternate paths to be used.
909 909 .RE
910 910
911 911 .sp
912 912 .ne 2
913 913 .na
914 914 \fB\fB-z\fR \fBdefs\fR | \fBnodefs\fR\fR
915 915 .ad
916 916 .br
917 917 .na
918 918 \fB\fB--no-undefined\fR\fR
919 919 .ad
920 920 .sp .6
921 921 .RS 4n
922 922 The \fB-z\fR \fBdefs\fR option and the \fB--no-undefined\fR option force a
923 923 fatal error if any undefined symbols remain at the end of the link. This mode
924 924 is the default when an executable is built. For historic reasons, this mode is
925 925 \fBnot\fR the default when building a shared object. Use of the \fB-z\fR
926 926 \fBdefs\fR option is recommended, as this mode assures the object being built
927 927 is self-contained. A self-contained object has all symbolic references resolved
928 928 internally, or to the object's immediate dependencies.
929 929 .sp
930 930 The \fB-z\fR \fBnodefs\fR option allows undefined symbols. For historic
931 931 reasons, this mode is the default when a shared object is built. When used with
932 932 executables, the behavior of references to such undefined symbols is
933 933 unspecified. Use of the \fB-z\fR \fBnodefs\fR option is not recommended.
934 934 .RE
935 935
936 936 .sp
937 937 .ne 2
938 938 .na
939 939 \fB\fB-z\fR \fBdirect\fR | \fBnodirect\fR\fR
940 940 .ad
941 941 .sp .6
942 942 .RS 4n
943 943 Enables or disables direct binding to any dependencies that follow on the
944 944 command line. These options allow finer control over direct binding than the
945 945 global counterpart \fB-B\fR \fBdirect\fR. The \fB-z\fR \fBdirect\fR option also
946 946 differs from the \fB-B\fR \fBdirect\fR option in the following areas. Direct
947 947 binding information is not established between a symbol reference and an
948 948 associated definition within the object being created. Lazy loading is not
949 949 enabled.
950 950 .RE
951 951
952 952 .sp
953 953 .ne 2
954 954 .na
955 955 \fB\fB-z\fR \fBendfiltee\fR\fR
956 956 .ad
957 957 .sp .6
958 958 .RS 4n
959 959 Marks a filtee so that when processed by a filter, the filtee terminates any
960 960 further filtee searches by the filter. See \fIReducing Filtee Searches\fR in
961 961 \fILinker and Libraries Guide\fR.
962 962 .RE
963 963
964 964 .sp
965 965 .ne 2
966 966 .na
967 967 \fB\fB-z\fR \fBfatal-warnings\fR | \fBnofatal-warnings\fR\fR
968 968 .ad
969 969 .br
970 970 .na
971 971 \fB\fB--fatal-warnings\fR | \fB--no-fatal-warnings\fR
972 972 .ad
973 973 .sp .6
974 974 .RS 4n
975 975 Controls the behavior of warnings emitted from the link-editor. Setting \fB-z
976 976 fatal-warnings\fR promotes warnings emitted by the link-editor to fatal errors
977 977 that will cause the link-editor to fail before linking. \fB-z
978 978 nofatal-warnings\fR instead demotes these warnings such that they will not cause
979 979 the link-editor to exit prematurely.
980 980 .RE
981 981
982 982
983 983 .sp
984 984 .ne 2
985 985 .na
986 986 \fB\fB-z\fR \fBfiniarray=\fR\fIfunction\fR\fR
987 987 .ad
988 988 .sp .6
989 989 .RS 4n
990 990 Appends an entry to the \fB\&.finiarray\fR section of the object being built.
991 991 If no \fB\&.finiarray\fR section is present, a section is created. The new
992 992 entry is initialized to point to \fIfunction\fR. See \fIInitialization and
993 993 Termination Sections\fR in \fILinker and Libraries Guide\fR.
994 994 .RE
995 995
996 996 .sp
997 997 .ne 2
998 998 .na
999 999 \fB\fB-z\fR \fBglobalaudit\fR\fR
1000 1000 .ad
1001 1001 .sp .6
1002 1002 .RS 4n
1003 1003 This option supplements an audit library definition that has been recorded with
1004 1004 the \fB-P\fR option. This option is only meaningful when building a dynamic
1005 1005 executable. Audit libraries that are defined within an object with the \fB-P\fR
1006 1006 option typically allow for the auditing of the immediate dependencies of the
1007 1007 object. The \fB-z\fR \fBglobalaudit\fR promotes the auditor to a global
1008 1008 auditor, thus allowing the auditing of all dependencies. See \fIInvoking the
1009 1009 Auditing Interface\fR in \fILinker and Libraries Guide\fR.
1010 1010 .sp
1011 1011 An auditor established with the \fB-P\fR option and the \fB-z\fR
1012 1012 \fBglobalaudit\fR option, is equivalent to the auditor being established with
1013 1013 the \fBLD_AUDIT\fR environment variable. See \fBld.so.1\fR(1).
1014 1014 .RE
1015 1015
1016 1016 .sp
1017 1017 .ne 2
1018 1018 .na
1019 1019 \fB\fB-z\fR \fBgroupperm\fR | \fBnogroupperm\fR\fR
1020 1020 .ad
1021 1021 .sp .6
1022 1022 .RS 4n
1023 1023 Assigns, or deassigns each dependency that follows to a unique group. The
1024 1024 assignment of a dependency to a group has the same effect as if the dependency
1025 1025 had been built using the \fB-B\fR \fBgroup\fR option.
1026 1026 .RE
1027 1027
1028 1028 .sp
1029 1029 .ne 2
1030 1030 .na
1031 1031 \fB-z\fR \fBguidance\fR[=\fIid1\fR,\fIid2\fR...]
1032 1032 .ad
1033 1033 .sp .6
1034 1034 .RS 4n
1035 1035 Give messages suggesting link-editor features that could improve the resulting
1036 1036 dynamic object.
1037 1037 .LP
1038 1038 Specific classes of suggestion can be silenced by specifying an optional comma separated
1039 1039 list of guidance identifiers.
1040 1040 .LP
1041 1041 The current classes of suggestion provided are:
1042 1042
1043 1043 .sp
1044 1044 .ne 2
1045 1045 .na
1046 1046 Enable use of direct binding
1047 1047 .ad
1048 1048 .sp .6
1049 1049 .RS 4n
1050 1050 Suggests that \fB-z direct\fR or \fB-B direct\fR be present prior to any
1051 1051 specified dependency. This allows predictable symbol binding at runtime.
1052 1052
1053 1053 Can be disabled with \fB-z guidance=nodirect\fR
1054 1054 .RE
1055 1055
1056 1056 .sp
1057 1057 .ne 2
1058 1058 .na
1059 1059 Enable lazy dependency loading
1060 1060 .ad
1061 1061 .sp .6
1062 1062 .RS 4n
1063 1063 Suggests that \fB-z lazyload\fR be present prior to any specified dependency.
1064 1064 This allows the dynamic object to be loaded more quickly.
1065 1065
1066 1066 Can be disabled with \fB-z guidance=nolazyload\fR.
1067 1067 .RE
1068 1068
1069 1069 .sp
1070 1070 .ne 2
1071 1071 .na
1072 1072 Shared objects should define all their dependencies.
1073 1073 .ad
1074 1074 .sp .6
1075 1075 .RS 4n
1076 1076 Suggests that \fB-z defs\fR be specified on the link-editor command line.
1077 1077 Shared objects that explicitly state all their dependencies behave more
1078 1078 predictably when used.
1079 1079
1080 1080 Can be be disabled with \fB-z guidance=nodefs\fR
1081 1081 .RE
1082 1082
1083 1083 .sp
1084 1084 .ne 2
1085 1085 .na
1086 1086 Version 2 mapfile syntax
1087 1087 .ad
1088 1088 .sp .6
1089 1089 .RS 4n
1090 1090 Suggests that any specified mapfiles use the more readable version 2 syntax.
1091 1091
1092 1092 Can be disabled with \fB-z guidance=nomapfile\fR.
1093 1093 .RE
1094 1094
1095 1095 .sp
1096 1096 .ne 2
1097 1097 .na
1098 1098 Read-only text segment
1099 1099 .ad
1100 1100 .sp .6
1101 1101 .RS 4n
1102 1102 Should any runtime relocations within the text segment exist, suggests that
1103 1103 the object be compiled with position independent code (PIC). Keeping large
1104 1104 allocatable sections read-only allows them to be shared between processes
1105 1105 using a given shared object.
1106 1106
1107 1107 Can be disabled with \fB-z guidance=notext\fR
1108 1108 .RE
1109 1109
1110 1110 .sp
1111 1111 .ne 2
1112 1112 .na
1113 1113 No unused dependencies
1114 1114 .ad
1115 1115 .sp .6
1116 1116 .RS 4n
1117 1117 Suggests that any dependency not referenced by the resulting dynamic object be
1118 1118 removed from the link-editor command line.
1119 1119
1120 1120 Can be disabled with \fB-z guidance=nounused\fR.
1121 1121 .RE
1122 1122 .RE
1123 1123
1124 1124 .sp
1125 1125 .ne 2
1126 1126 .na
1127 1127 \fB\fB-z\fR \fBhelp\fR\fR
1128 1128 .ad
1129 1129 .br
1130 1130 .na
1131 1131 \fB\fB--help\fR\fR
1132 1132 .ad
1133 1133 .sp .6
1134 1134 .RS 4n
1135 1135 Print a summary of the command line options on the standard output and exit.
1136 1136 .RE
1137 1137
1138 1138 .sp
1139 1139 .ne 2
1140 1140 .na
1141 1141 \fB\fB-z\fR \fBignore\fR | \fBrecord\fR\fR
1142 1142 .ad
1143 1143 .sp .6
1144 1144 .RS 4n
1145 1145 Ignores, or records, dynamic dependencies that are not referenced as part of
1146 1146 the link-edit. Ignores, or records, unreferenced \fBELF\fR sections from the
1147 1147 relocatable objects that are read as part of the link-edit. By default,
1148 1148 \fB-z\fR \fBrecord\fR is in effect.
1149 1149 .sp
1150 1150 If an \fBELF\fR section is ignored, the section is eliminated from the output
1151 1151 file being generated. A section is ignored when three conditions are true. The
1152 1152 eliminated section must contribute to an allocatable segment. The eliminated
1153 1153 section must provide no global symbols. No other section from any object that
1154 1154 contributes to the link-edit, must reference an eliminated section.
1155 1155 .RE
1156 1156
1157 1157 .sp
1158 1158 .ne 2
1159 1159 .na
1160 1160 \fB\fB-z\fR \fBinitarray=\fR\fIfunction\fR\fR
1161 1161 .ad
1162 1162 .sp .6
1163 1163 .RS 4n
1164 1164 Appends an entry to the \fB\&.initarray\fR section of the object being built.
1165 1165 If no \fB\&.initarray\fR section is present, a section is created. The new
1166 1166 entry is initialized to point to \fIfunction\fR. See \fIInitialization and
1167 1167 Termination Sections\fR in \fILinker and Libraries Guide\fR.
1168 1168 .RE
1169 1169
1170 1170 .sp
1171 1171 .ne 2
1172 1172 .na
1173 1173 \fB\fB-z\fR \fBinitfirst\fR\fR
1174 1174 .ad
1175 1175 .sp .6
1176 1176 .RS 4n
1177 1177 Marks the object so that its runtime initialization occurs before the runtime
1178 1178 initialization of any other objects brought into the process at the same time.
1179 1179 In addition, the object runtime finalization occurs after the runtime
1180 1180 finalization of any other objects removed from the process at the same time.
1181 1181 This option is only meaningful when building a shared object.
1182 1182 .RE
1183 1183
1184 1184 .sp
1185 1185 .ne 2
1186 1186 .na
1187 1187 \fB\fB-z\fR \fBinterpose\fR\fR
1188 1188 .ad
1189 1189 .sp .6
1190 1190 .RS 4n
1191 1191 Marks the object as an interposer. At runtime, an object is identified as an
1192 1192 explicit interposer if the object has been tagged using the \fB-z interpose\fR
1193 1193 option. An explicit interposer is also established when an object is loaded
1194 1194 using the \fBLD_PRELOAD\fR environment variable. Implicit interposition can
1195 1195 occur because of the load order of objects, however, this implicit
1196 1196 interposition is unknown to the runtime linker. Explicit interposition can
1197 1197 ensure that interposition takes place regardless of the order in which objects
1198 1198 are loaded. Explicit interposition also ensures that the runtime linker
1199 1199 searches for symbols in any explicit interposers when direct bindings are in
1200 1200 effect.
1201 1201 .RE
1202 1202
1203 1203 .sp
1204 1204 .ne 2
1205 1205 .na
1206 1206 \fB\fB-z\fR \fBlazyload\fR | \fBnolazyload\fR\fR
1207 1207 .ad
1208 1208 .sp .6
1209 1209 .RS 4n
1210 1210 Enables or disables the marking of dynamic dependencies to be lazily loaded.
1211 1211 Dynamic dependencies which are marked \fBlazyload\fR are not loaded at initial
1212 1212 process start-up. These dependencies are delayed until the first binding to the
1213 1213 object is made. \fBNote:\fR Lazy loading requires the correct declaration of
1214 1214 dependencies, together with associated runpaths for each dynamic object used
1215 1215 within a process. See \fILazy Loading of Dynamic Dependencies\fR in \fILinker
1216 1216 and Libraries Guide\fR.
1217 1217 .RE
1218 1218
1219 1219 .sp
1220 1220 .ne 2
1221 1221 .na
1222 1222 \fB\fB-z\fR \fBld32\fR=\fIarg1\fR,\fIarg2\fR,...\fR
1223 1223 .ad
1224 1224 .br
1225 1225 .na
1226 1226 \fB\fB-z\fR \fBld64\fR=\fIarg1\fR,\fIarg2\fR,...\fR
1227 1227 .ad
1228 1228 .sp .6
1229 1229 .RS 4n
1230 1230 The class of the link-editor is affected by the class of the output file being
1231 1231 created and by the capabilities of the underlying operating system. The
1232 1232 \fB-z\fR \fBld\fR[\fB32\fR|\fB64\fR] options provide a means of defining any
1233 1233 link-editor argument. The defined argument is only interpreted, respectively,
1234 1234 by the 32-bit class or 64-bit class of the link-editor.
1235 1235 .sp
1236 1236 For example, support libraries are class specific, so the correct class of
1237 1237 support library can be ensured using:
1238 1238 .sp
1239 1239 .in +2
1240 1240 .nf
1241 1241 \fBld ... -z ld32=-Saudit32.so.1 -z ld64=-Saudit64.so.1 ...\fR
1242 1242 .fi
1243 1243 .in -2
1244 1244 .sp
1245 1245
1246 1246 The class of link-editor that is invoked is determined from the \fBELF\fR class
1247 1247 of the first relocatable file that is seen on the command line. This
1248 1248 determination is carried out \fBprior\fR to any \fB-z\fR
1249 1249 \fBld\fR[\fB32\fR|\fB64\fR] processing.
1250 1250 .RE
1251 1251
1252 1252 .sp
1253 1253 .ne 2
1254 1254 .na
1255 1255 \fB\fB-z\fR \fBloadfltr\fR\fR
1256 1256 .ad
1257 1257 .sp .6
1258 1258 .RS 4n
1259 1259 Marks a filter to indicate that filtees must be processed immediately at
1260 1260 runtime. Normally, filter processing is delayed until a symbol reference is
1261 1261 bound to the filter. The runtime processing of an object that contains this
1262 1262 flag mimics that which occurs if the \fBLD_LOADFLTR\fR environment variable is
1263 1263 in effect. See the \fBld.so.1\fR(1).
1264 1264 .RE
1265 1265
1266 1266 .sp
1267 1267 .ne 2
1268 1268 .na
1269 1269 \fB\fB-z\fR \fBmuldefs\fR\fR
1270 1270 .ad
1271 1271 .br
1272 1272 .na
1273 1273 \fB\fB--allow-multiple-definition\fR\fR
1274 1274 .ad
1275 1275 .sp .6
1276 1276 .RS 4n
1277 1277 Allows multiple symbol definitions. By default, multiple symbol definitions
1278 1278 that occur between relocatable objects result in a fatal error condition. This
1279 1279 option, suppresses the error condition, allowing the first symbol definition to
1280 1280 be taken.
1281 1281 .RE
1282 1282
1283 1283 .sp
1284 1284 .ne 2
1285 1285 .na
1286 1286 \fB\fB-z\fR \fBnocompstrtab\fR\fR
1287 1287 .ad
1288 1288 .sp .6
1289 1289 .RS 4n
1290 1290 Disables the compression of \fBELF\fR string tables. By default, string
1291 1291 compression is applied to \fBSHT_STRTAB\fR sections, and to \fBSHT_PROGBITS\fR
1292 1292 sections that have their \fBSHF_MERGE\fR and \fBSHF_STRINGS\fR section flags
1293 1293 set.
1294 1294 .RE
1295 1295
1296 1296 .sp
1297 1297 .ne 2
1298 1298 .na
1299 1299 \fB\fB-z\fR \fBnodefaultlib\fR\fR
1300 1300 .ad
1301 1301 .sp .6
1302 1302 .RS 4n
1303 1303 Marks the object so that the runtime default library search path, used after
1304 1304 any \fBLD_LIBRARY_PATH\fR or runpaths, is ignored. This option implies that all
1305 1305 dependencies of the object can be satisfied from its runpath.
1306 1306 .RE
1307 1307
1308 1308 .sp
1309 1309 .ne 2
1310 1310 .na
1311 1311 \fB\fB-z\fR \fBnodelete\fR\fR
1312 1312 .ad
1313 1313 .sp .6
1314 1314 .RS 4n
1315 1315 Marks the object as non-deletable at runtime. This mode is similar to adding
1316 1316 the object to the process by using \fBdlopen\fR(3C) with the
1317 1317 \fBRTLD_NODELETE\fR mode.
1318 1318 .RE
1319 1319
1320 1320 .sp
1321 1321 .ne 2
1322 1322 .na
1323 1323 \fB\fB-z\fR \fBnodlopen\fR\fR
1324 1324 .ad
1325 1325 .sp .6
1326 1326 .RS 4n
1327 1327 Marks the object as not available to \fBdlopen\fR(3C), either as the object
1328 1328 specified by the \fBdlopen()\fR, or as any form of dependency required by the
1329 1329 object specified by the \fBdlopen()\fR. This option is only meaningful when
1330 1330 building a shared object.
1331 1331 .RE
1332 1332
1333 1333 .sp
1334 1334 .ne 2
1335 1335 .na
1336 1336 \fB\fB-z\fR \fBnodump\fR\fR
1337 1337 .ad
1338 1338 .sp .6
1339 1339 .RS 4n
1340 1340 Marks the object as not available to \fBdldump\fR(3C).
1341 1341 .RE
1342 1342
1343 1343 .sp
1344 1344 .ne 2
1345 1345 .na
1346 1346 \fB\fB-z\fR \fBnoldynsym\fR\fR
1347 1347 .ad
1348 1348 .sp .6
1349 1349 .RS 4n
1350 1350 Prevents the inclusion of a \fB\&.SUNW_ldynsym\fR section in dynamic
1351 1351 executables or sharable libraries. The \fB\&.SUNW_ldynsym\fR section augments
1352 1352 the \fB\&.dynsym\fR section by providing symbols for local functions. Local
1353 1353 function symbols allow debuggers to display local function names in stack
1354 1354 traces from stripped programs. Similarly, \fBdladdr\fR(3C) is able to supply
1355 1355 more accurate results.
1356 1356 .sp
1357 1357 The \fB-z\fR \fBnoldynsym\fR option also prevents the inclusion of the two
1358 1358 symbol sort sections that are related to the \fB\&.SUNW_ldynsym\fR section. The
1359 1359 \fB\&.SUNW_dynsymsort\fR section provides sorted access to regular function and
1360 1360 variable symbols. The \fB\&.SUNW_dyntlssort\fR section provides sorted access
1361 1361 to thread local storage (\fBTLS\fR) variable symbols.
1362 1362 .sp
1363 1363 The \fB\&.SUNW_ldynsym\fR, \fB\&.SUNW_dynsymsort\fR, and
1364 1364 \fB\&.SUNW_dyntlssort\fR sections, which becomes part of the allocable text
1365 1365 segment of the resulting file, cannot be removed by \fBstrip\fR(1). Therefore,
1366 1366 the \fB-z\fR \fBnoldynsym\fR option is the only way to prevent their inclusion.
1367 1367 See the \fB-s\fR and \fB-z\fR \fBredlocsym\fR options.
1368 1368 .RE
1369 1369
1370 1370 .sp
1371 1371 .ne 2
1372 1372 .na
1373 1373 \fB\fB-z\fR \fBnopartial\fR\fR
1374 1374 .ad
1375 1375 .sp .6
1376 1376 .RS 4n
1377 1377 Partially initialized symbols, that are defined within relocatable object
1378 1378 files, are expanded in the output file being generated.
1379 1379 .RE
1380 1380
1381 1381 .sp
1382 1382 .ne 2
1383 1383 .na
1384 1384 \fB\fB-z\fR \fBnoversion\fR\fR
1385 1385 .ad
1386 1386 .sp .6
1387 1387 .RS 4n
1388 1388 Does not record any versioning sections. Any version sections or associated
1389 1389 \fB\&.dynamic\fR section entries are not generated in the output image.
1390 1390 .RE
1391 1391
1392 1392 .sp
1393 1393 .ne 2
1394 1394 .na
1395 1395 \fB\fB-z\fR \fBnow\fR\fR
1396 1396 .ad
1397 1397 .sp .6
1398 1398 .RS 4n
1399 1399 Marks the object as requiring non-lazy runtime binding. This mode is similar to
1400 1400 adding the object to the process by using \fBdlopen\fR(3C) with the
1401 1401 \fBRTLD_NOW\fR mode. This mode is also similar to having the \fBLD_BIND_NOW\fR
1402 1402 environment variable in effect. See \fBld.so.1\fR(1).
1403 1403 .RE
1404 1404
1405 1405 .sp
1406 1406 .ne 2
1407 1407 .na
1408 1408 \fB\fB-z\fR \fBorigin\fR\fR
1409 1409 .ad
1410 1410 .sp .6
1411 1411 .RS 4n
1412 1412 Marks the object as requiring immediate \fB$ORIGIN\fR processing at runtime.
1413 1413 This option is only maintained for historic compatibility, as the runtime
1414 1414 analysis of objects to provide for \fB$ORIGIN\fR processing is now default.
1415 1415 .RE
1416 1416
1417 1417 .sp
1418 1418 .ne 2
1419 1419 .na
1420 1420 \fB\fB-z\fR \fBpreinitarray=\fR\fIfunction\fR\fR
1421 1421 .ad
1422 1422 .sp .6
1423 1423 .RS 4n
1424 1424 Appends an entry to the \fB\&.preinitarray\fR section of the object being
1425 1425 built. If no \fB\&.preinitarray\fR section is present, a section is created.
1426 1426 The new entry is initialized to point to \fIfunction\fR. See \fIInitialization
1427 1427 and Termination Sections\fR in \fILinker and Libraries Guide\fR.
1428 1428 .RE
1429 1429
1430 1430 .sp
1431 1431 .ne 2
1432 1432 .na
1433 1433 \fB\fB-z\fR \fBredlocsym\fR\fR
1434 1434 .ad
1435 1435 .sp .6
1436 1436 .RS 4n
1437 1437 Eliminates all local symbols except for the \fISECT\fR symbols from the symbol
1438 1438 table \fBSHT_SYMTAB\fR. All relocations that refer to local symbols are updated
1439 1439 to refer to the corresponding \fISECT\fR symbol. This option allows specialized
1440 1440 objects to greatly reduce their symbol table sizes. Eliminated local symbols
1441 1441 can reduce the \fB\&.stab*\fR debugging information that is generated using the
1442 1442 compiler drivers \fB-g\fR option. See the \fB-s\fR and \fB-z\fR \fBnoldynsym\fR
1443 1443 options.
1444 1444 .RE
1445 1445
1446 1446 .sp
1447 1447 .ne 2
1448 1448 .na
1449 1449 \fB\fB-z\fR \fBrelaxreloc\fR\fR
1450 1450 .ad
1451 1451 .sp .6
1452 1452 .RS 4n
1453 1453 \fBld\fR normally issues a fatal error upon encountering a relocation using a
1454 1454 symbol that references an eliminated COMDAT section. If \fB-z\fR
1455 1455 \fBrelaxreloc\fR is enabled, \fBld\fR instead redirects such relocations to the
1456 1456 equivalent symbol in the COMDAT section that was kept. \fB-z\fR
1457 1457 \fBrelaxreloc\fR is a specialized option, mainly of interest to compiler
1458 1458 authors, and is not intended for general use.
1459 1459 .RE
1460 1460
1461 1461 .sp
1462 1462 .ne 2
1463 1463 .na
1464 1464 \fB\fB-z\fR \fBrescan-now\fR\fR
1465 1465 .ad
1466 1466 .br
1467 1467 .na
1468 1468 \fB\fB-z\fR \fBrescan\fR\fR
1469 1469 .ad
1470 1470 .sp .6
1471 1471 .RS 4n
1472 1472 These options rescan the archive files that are provided to the link-edit. By
1473 1473 default, archives are processed once as the archives appear on the command
1474 1474 line. Archives are traditionally specified at the end of the command line so
1475 1475 that their symbol definitions resolve any preceding references. However,
1476 1476 specifying archives multiple times to satisfy their own interdependencies can
1477 1477 be necessary.
1478 1478 .sp
1479 1479 \fB-z\fR \fBrescan-now\fR is a positional option, and is processed by the
1480 1480 link-editor immediately when encountered on the command line. All archives seen
1481 1481 on the command line up to that point are immediately reprocessed in an attempt
1482 1482 to locate additional archive members that resolve symbol references. This
1483 1483 archive rescanning is repeated until a pass over the archives occurs in which
1484 1484 no new members are extracted.
1485 1485 .sp
1486 1486 \fB-z\fR \fBrescan\fR is a position independent option. The link-editor defers
1487 1487 the rescan operation until after it has processed the entire command line, and
1488 1488 then initiates a final rescan operation over all archives seen on the command
1489 1489 line. The \fB-z\fR \fBrescan\fR operation can interact incorrectly
1490 1490 with objects that contain initialization (.init) or finalization (.fini)
1491 1491 sections, preventing the code in those sections from running. For this reason,
1492 1492 \fB-z\fR \fBrescan\fR is deprecated, and use of \fB-z\fR \fBrescan-now\fR is
1493 1493 advised.
1494 1494 .RE
1495 1495
1496 1496 .sp
1497 1497 .ne 2
1498 1498 .na
1499 1499 \fB\fB-z\fR \fBrescan-start\fR ... \fB-z\fR \fBrescan-end\fR\fR
1500 1500 .ad
1501 1501 .br
1502 1502 .na
1503 1503 \fB\fB--start-group\fR ... \fB--end-group\fR\fR
1504 1504 .ad
1505 1505 .br
1506 1506 .na
1507 1507 \fB\fB-(\fR ... \fB-)\fR\fR
1508 1508 .ad
1509 1509 .sp .6
1510 1510 .RS 4n
1511 1511 Defines an archive rescan group. This is a positional construct, and is
1512 1512 processed by the link-editor immediately upon encountering the closing
1513 1513 delimiter option. Archives found within the group delimiter options are
1514 1514 reprocessed as a group in an attempt to locate additional archive members that
1515 1515 resolve symbol references. This archive rescanning is repeated until a pass
1516 1516 over the archives On the occurs in which no new members are extracted.
1517 1517 Archive rescan groups cannot be nested.
1518 1518 .RE
1519 1519
1520 1520 .sp
1521 1521 .ne 2
1522 1522 .na
1523 1523 \fB\fB-z\fR \fBtarget=sparc|x86\fR \fI\fR\fR
1524 1524 .ad
1525 1525 .sp .6
1526 1526 .RS 4n
1527 1527 Specifies the machine type for the output object. Supported targets are Sparc
1528 1528 and x86. The 32-bit machine type for the specified target is used unless the
1529 1529 \fB-64\fR option is also present, in which case the corresponding 64-bit
1530 1530 machine type is used. By default, the machine type of the object being
1531 1531 generated is determined from the first \fBELF\fR object processed from the
1532 1532 command line. If no objects are specified, the machine type is determined by
1533 1533 the first object encountered within the first archive processed from the
1534 1534 command line. If there are no objects or archives, the link-editor assumes the
1535 1535 native machine. This option is useful when creating an object directly with
1536 1536 \fBld\fR whose input is solely from a \fBmapfile\fR. See the \fB-M\fR option.
1537 1537 It can also be useful in the rare case of linking entirely from an archive that
1538 1538 contains objects of different machine types for which the first object is not
1539 1539 of the desired machine type. See \fIThe 32-bit link-editor and 64-bit
1540 1540 link-editor\fR in \fILinker and Libraries Guide\fR.
1541 1541 .RE
1542 1542
1543 1543 .sp
1544 1544 .ne 2
1545 1545 .na
1546 1546 \fB\fB-z\fR \fBtext\fR\fR
1547 1547 .ad
1548 1548 .sp .6
1549 1549 .RS 4n
1550 1550 In dynamic mode only, forces a fatal error if any relocations against
1551 1551 non-writable, allocatable sections remain. For historic reasons, this mode is
1552 1552 not the default when building an executable or shared object. However, its use
1553 1553 is recommended to ensure that the text segment of the dynamic object being
1554 1554 built is shareable between multiple running processes. A shared text segment
1555 1555 incurs the least relocation overhead when loaded into memory. See
1556 1556 \fIPosition-Independent Code\fR in \fILinker and Libraries Guide\fR.
1557 1557 .RE
1558 1558
1559 1559 .sp
1560 1560 .ne 2
1561 1561 .na
1562 1562 \fB\fB-z\fR \fBtextoff\fR\fR
1563 1563 .ad
1564 1564 .sp .6
1565 1565 .RS 4n
1566 1566 In dynamic mode only, allows relocations against all allocatable sections,
1567 1567 including non-writable ones. This mode is the default when building a shared
1568 1568 object.
1569 1569 .RE
1570 1570
1571 1571 .sp
1572 1572 .ne 2
1573 1573 .na
1574 1574 \fB\fB-z\fR \fBtextwarn\fR\fR
1575 1575 .ad
1576 1576 .sp .6
1577 1577 .RS 4n
1578 1578 In dynamic mode only, lists a warning if any relocations against non-writable,
1579 1579 allocatable sections remain. This mode is the default when building an
1580 1580 executable.
1581 1581 .RE
1582 1582
1583 1583 .sp
1584 1584 .ne 2
1585 1585 .na
1586 1586 \fB\fB-z\fR \fBverbose\fR\fR
1587 1587 .ad
1588 1588 .sp .6
1589 1589 .RS 4n
1590 1590 This option provides additional warning diagnostics during a link-edit.
1591 1591 Presently, this option conveys suspicious use of displacement relocations. This
1592 1592 option also conveys the restricted use of static \fBTLS\fR relocations when
1593 1593 building shared objects. In future, this option might be enhanced to provide
1594 1594 additional diagnostics that are deemed too noisy to be generated by default.
1595 1595 .RE
1596 1596
1597 1597 .sp
1598 1598 .ne 2
1599 1599 .na
1600 1600 \fB\fB-z\fR\fBwrap=\fR\fIsymbol\fR\fR
1601 1601 .ad
1602 1602 .br
1603 1603 .na
1604 1604 \fB\fB-wrap=\fR \fIsymbol\fR\fR
1605 1605 .ad
1606 1606 .br
1607 1607 .na
1608 1608 \fB\fB--wrap=\fR \fIsymbol\fR\fR
1609 1609 .ad
1610 1610 .sp .6
1611 1611 .RS 4n
1612 1612 Rename undefined references to \fIsymbol\fR in order to allow wrapper code to
1613 1613 be linked into the output object without having to modify source code. When
1614 1614 \fB-z wrap\fR is specified, all undefined references to \fIsymbol\fR are
1615 1615 modified to reference \fB__wrap_\fR\fIsymbol\fR, and all references to
1616 1616 \fB__real_\fR\fIsymbol\fR are modified to reference \fIsymbol\fR. The user is
1617 1617 expected to provide an object containing the \fB__wrap_\fR\fIsymbol\fR
1618 1618 function. This wrapper function can call \fB__real_\fR\fIsymbol\fR in order to
1619 1619 reference the actual function being wrapped.
1620 1620 .sp
1621 1621 The following is an example of a wrapper for the \fBmalloc\fR(3C) function:
1622 1622 .sp
1623 1623 .in +2
1624 1624 .nf
1625 1625 void *
1626 1626 __wrap_malloc(size_t c)
1627 1627 {
1628 1628 (void) printf("malloc called with %zu\en", c);
1629 1629 return (__real_malloc(c));
1630 1630 }
1631 1631 .fi
1632 1632 .in -2
1633 1633
1634 1634 If you link other code with this file using \fB-z\fR \fBwrap=malloc\fR to
1635 1635 compile all the objects, then all calls to \fBmalloc\fR will call the function
1636 1636 \fB__wrap_malloc\fR instead. The call to \fB__real_malloc\fR will call the real
1637 1637 \fBmalloc\fR function.
1638 1638 .sp
1639 1639 The real and wrapped functions should be maintained in separate source files.
1640 1640 Otherwise, the compiler or assembler may resolve the call instead of leaving
1641 1641 that operation for the link-editor to carry out, and prevent the wrap from
1642 1642 occurring.
1643 1643 .RE
1644 1644
1645 1645 .SH ENVIRONMENT VARIABLES
1646 1646 .ne 2
1647 1647 .na
1648 1648 \fB\fBLD_ALTEXEC\fR\fR
1649 1649 .ad
1650 1650 .sp .6
1651 1651 .RS 4n
1652 1652 An alternative link-editor path name. \fBld\fR executes, and passes control to
1653 1653 this alternative link-editor. This environment variable provides a generic
1654 1654 means of overriding the default link-editor that is called from the various
1655 1655 compiler drivers. See the \fB-z altexec64\fR option.
1656 1656 .RE
1657 1657
1658 1658 .sp
1659 1659 .ne 2
1660 1660 .na
1661 1661 \fB\fBLD_LIBRARY_PATH\fR\fR
1662 1662 .ad
1663 1663 .sp .6
1664 1664 .RS 4n
1665 1665 A list of directories in which to search for the libraries specified using the
1666 1666 \fB-l\fR option. Multiple directories are separated by a colon. In the most
1667 1667 general case, this environment variable contains two directory lists separated
1668 1668 by a semicolon:
1669 1669 .sp
1670 1670 .in +2
1671 1671 .nf
1672 1672 \fIdirlist1\fR\fB;\fR\fIdirlist2\fR
1673 1673 .fi
1674 1674 .in -2
1675 1675 .sp
1676 1676
1677 1677 If \fBld\fR is called with any number of occurrences of \fB-L\fR, as in:
1678 1678 .sp
1679 1679 .in +2
1680 1680 .nf
1681 1681 \fBld ... -L\fIpath1\fR ... -L\fIpathn\fR ...\fR
1682 1682 .fi
1683 1683 .in -2
1684 1684 .sp
1685 1685
1686 1686 then the search path ordering is:
1687 1687 .sp
1688 1688 .in +2
1689 1689 .nf
1690 1690 \fB\fIdirlist1 path1\fR ... \fIpathn dirlist2\fR LIBPATH\fR
1691 1691 .fi
1692 1692 .in -2
1693 1693 .sp
1694 1694
1695 1695 When the list of directories does not contain a semicolon, the list is
1696 1696 interpreted as \fIdirlist2\fR.
1697 1697 .sp
1698 1698 The \fBLD_LIBRARY_PATH\fR environment variable also affects the runtime linkers
1699 1699 search for dynamic dependencies.
1700 1700 .sp
1701 1701 This environment variable can be specified with a _32 or _64 suffix. This makes
1702 1702 the environment variable specific, respectively, to 32-bit or 64-bit processes
1703 1703 and overrides any non-suffixed version of the environment variable that is in
1704 1704 effect.
1705 1705 .RE
1706 1706
1707 1707 .sp
1708 1708 .ne 2
1709 1709 .na
1710 1710 \fB\fBLD_NOEXEC_64\fR\fR
1711 1711 .ad
1712 1712 .sp .6
1713 1713 .RS 4n
1714 1714 Suppresses the automatic execution of the 64-bit link-editor. By default, the
1715 1715 link-editor executes the 64-bit version when the \fBELF\fR class of the first
1716 1716 relocatable file identifies a 64-bit object. The 64-bit image that a 32-bit
1717 1717 link-editor can create, has some limitations. However, some link-edits might
1718 1718 find the use of the 32-bit link-editor faster.
1719 1719 .RE
1720 1720
1721 1721 .sp
1722 1722 .ne 2
1723 1723 .na
1724 1724 \fB\fBLD_OPTIONS\fR\fR
1725 1725 .ad
1726 1726 .sp .6
1727 1727 .RS 4n
1728 1728 A default set of options to \fBld\fR. \fBLD_OPTIONS\fR is interpreted by
1729 1729 \fBld\fR just as though its value had been placed on the command line,
1730 1730 immediately following the name used to invoke \fBld\fR, as in:
1731 1731 .sp
1732 1732 .in +2
1733 1733 .nf
1734 1734 \fBld $LD_OPTIONS ... \fIother-arguments\fR ...\fR
1735 1735 .fi
1736 1736 .in -2
1737 1737 .sp
1738 1738
1739 1739 .RE
1740 1740
1741 1741 .sp
1742 1742 .ne 2
1743 1743 .na
1744 1744 \fB\fBLD_RUN_PATH\fR\fR
1745 1745 .ad
1746 1746 .sp .6
1747 1747 .RS 4n
1748 1748 An alternative mechanism for specifying a runpath to the link-editor. See the
1749 1749 \fB-R\fR option. If both \fBLD_RUN_PATH\fR and the \fB-R\fR option are
1750 1750 specified, \fB-R\fR supersedes.
1751 1751 .RE
1752 1752
1753 1753 .sp
1754 1754 .ne 2
1755 1755 .na
1756 1756 \fB\fBSGS_SUPPORT\fR\fR
1757 1757 .ad
1758 1758 .sp .6
1759 1759 .RS 4n
1760 1760 Provides a colon-separated list of shared objects that are loaded with the
1761 1761 link-editor and given information regarding the linking process. This
1762 1762 environment variable can be specified with a _32 or _64 suffix. This makes the
1763 1763 environment variable specific, respectively, to the 32-bit or 64-bit class of
1764 1764 \fBld\fR and overrides any non-suffixed version of the environment variable
1765 1765 that is in effect. See the \fB-S\fR option.
1766 1766 .RE
1767 1767
1768 1768 .sp
1769 1769 .LP
1770 1770 Notice that environment variable-names that begin with the
1771 1771 characters '\fBLD_\fR' are reserved for possible future enhancements to \fBld\fR and
1772 1772 \fBld.so.1\fR(1).
1773 1773 .SH FILES
1774 1774 .ne 2
1775 1775 .na
1776 1776 \fB\fBlib\fIx\fR.so\fR\fR
1777 1777 .ad
1778 1778 .RS 15n
1779 1779 shared object libraries.
1780 1780 .RE
1781 1781
1782 1782 .sp
1783 1783 .ne 2
1784 1784 .na
1785 1785 \fB\fBlib\fIx\fR.a\fR\fR
1786 1786 .ad
1787 1787 .RS 15n
1788 1788 archive libraries.
1789 1789 .RE
1790 1790
1791 1791 .sp
1792 1792 .ne 2
1793 1793 .na
1794 1794 \fB\fBa.out\fR\fR
1795 1795 .ad
1796 1796 .RS 15n
1797 1797 default output file.
1798 1798 .RE
1799 1799
1800 1800 .sp
1801 1801 .ne 2
1802 1802 .na
1803 1803 \fB\fILIBPATH\fR\fR
1804 1804 .ad
1805 1805 .RS 15n
1806 1806 For 32-bit libraries, the default search path is \fB/usr/ccs/lib\fR, followed
1807 1807 by \fB/lib\fR, and finally \fB/usr/lib\fR. For 64-bit libraries, the default
1808 1808 search path is \fB/lib/64\fR, followed by \fB/usr/lib/64\fR.
1809 1809 .RE
1810 1810
1811 1811 .sp
1812 1812 .ne 2
1813 1813 .na
1814 1814 \fB\fB/usr/lib/ld\fR\fR
1815 1815 .ad
1816 1816 .RS 15n
1817 1817 A directory containing several \fBmapfiles\fR that can be used during
1818 1818 link-editing. These \fBmapfiles\fR provide various capabilities, such as
1819 1819 defining memory layouts, aligning bss, and defining non-executable stacks.
1820 1820 .RE
1821 1821
1822 1822 .SH ATTRIBUTES
1823 1823 .LP
1824 1824 See \fBattributes\fR(5) for descriptions of the following attributes:
1825 1825 .sp
1826 1826
1827 1827 .sp
1828 1828 .TS
1829 1829 box;
1830 1830 c | c
1831 1831 l | l .
1832 1832 ATTRIBUTE TYPE ATTRIBUTE VALUE
1833 1833 _
1834 1834 Interface Stability Committed
1835 1835 .TE
1836 1836
1837 1837 .SH SEE ALSO
1838 1838 .LP
1839 1839 \fBas\fR(1), \fBcrle\fR(1), \fBgprof\fR(1), \fBld.so.1\fR(1), \fBldd\fR(1),
1840 1840 \fBmcs\fR(1), \fBpvs\fR(1), \fBexec\fR(2), \fBstat\fR(2), \fBdlopen\fR(3C),
1841 1841 \fBdldump\fR(3C), \fBelf\fR(3ELF), \fBar.h\fR(3HEAD), \fBa.out\fR(4),
1842 1842 \fBattributes\fR(5)
1843 1843 .sp
1844 1844 .LP
1845 1845 \fILinker and Libraries Guide\fR
1846 1846 .SH NOTES
1847 1847 .LP
1848 1848 Default options applied by \fBld\fR are maintained for historic reasons. In
1849 1849 today's programming environment, where dynamic objects dominate, alternative
1850 1850 defaults would often make more sense. However, historic defaults must be
1851 1851 maintained to ensure compatibility with existing program development
1852 1852 environments. Historic defaults are called out wherever possible in this
1853 1853 manual. For a description of the current recommended options, see Appendix A,
1854 1854 \fILink-Editor Quick Reference,\fR in \fILinker and Libraries Guide\fR.
1855 1855 .sp
1856 1856 .LP
1857 1857 If the file being created by \fBld\fR already exists, the file is unlinked
1858 1858 after all input files have been processed. A new file with the specified name
1859 1859 is then created. This allows \fBld\fR to create a new version of the file,
1860 1860 while simultaneously allowing existing processes that are accessing the old
1861 1861 file contents to continue running. If the old file has no other links, the disk
1862 1862 space of the removed file is freed when the last process referencing the file
1863 1863 terminates.
1864 1864 .sp
1865 1865 .LP
1866 1866 The behavior of \fBld\fR when the file being created already exists was changed
1867 1867 with \fBSXCE\fR build \fB43\fR. In older versions, the existing file was
1868 1868 rewritten in place, an approach with the potential to corrupt any running
1869 1869 processes that is using the file. This change has an implication for output
1870 1870 files that have multiple hard links in the file system. Previously, all links
1871 1871 would remain intact, with all links accessing the new file contents. The new
1872 1872 \fBld\fR behavior \fBbreaks\fR such links, with the result that only the
1873 1873 specified output file name references the new file. All the other links
1874 1874 continue to reference the old file. To ensure consistent behavior, applications
1875 1875 that rely on multiple hard links to linker output files should explicitly
1876 1876 remove and relink the other file names.
↓ open down ↓ |
1858 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX