Print this page
10366 ld(1) should support GNU-style linker sets
10581 ld(1) should know kernel modules are a thing
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/ld.1.man.txt
+++ new/usr/src/man/man1/ld.1.man.txt
1 1 LD(1) User Commands LD(1)
2 2
3 3
4 4
5 5 NAME
6 6 ld - link-editor for object files
7 7
8 8 SYNOPSIS
9 9 ld [-32 | -64] [-a | -r] [-b] [-Bdirect | nodirect]
10 10 [-B dynamic | static] [-B eliminate] [-B group] [-B local]
11 11 [-B reduce] [-B symbolic] [-c name] [-C] [-d y | n]
12 12 [-D token,...] [-e epsym] [-f name | -F name] [-G] [-h name]
13 13 [-i] [-I name] [-l x] [-L path] [-m] [-M mapfile]
14 14 [-N string] [-o outfile] [-p auditlib] [-P auditlib]
15 15 [-Q y | n] [-R path] [-s] [-S supportlib] [-t]
16 16 [-u symname] [-V] [-Y P,dirlist] [-z absexec]
17 17 [-z allextract | defaultextract | weakextract ] [-z altexec64]
18 18 [-z aslr[=state]] [-z assert-deflib] [ -z assert-deflib=libname]
19 19 [-z combreloc | nocombreloc ] [-z defs | nodefs]
20 20 [-z direct | nodirect] [-z endfiltee]
21 21 [-z fatal-warnings | nofatal-warnings ] [-z finiarray=function]
22 22 [-z globalaudit] [-z groupperm | nogroupperm]
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 [-z guidance[=id1,id2...] [-z help ]
24 24 [-z ignore | record] [-z initarray=function] [-z initfirst]
25 25 [-z interpose] [-z lazyload | nolazyload]
26 26 [-z ld32=arg1,arg2,...] [-z ld64=arg1,arg2,...]
27 27 [-z loadfltr] [-z muldefs] [-z nocompstrtab] [-z nodefaultlib]
28 28 [-z nodelete] [-z nodlopen] [-z nodump] [-z noldynsym]
29 29 [-z nopartial] [-z noversion] [-z now] [-z origin]
30 30 [-z preinitarray=function] [-z redlocsym] [-z relaxreloc]
31 31 [-z rescan-now] [-z recan] [-z rescan-start ... -z rescan-end]]
32 32 [-z target=sparc|x86] [-z text | textwarn | textoff]
33 + [-z type=exec|kmod|reloc|shared]
33 34 [-z verbose] [-z wrap=symbol] filename...
34 35
35 36
36 37 DESCRIPTION
37 38 The link-editor, ld, combines relocatable object files by resolving
38 39 symbol references to symbol definitions, together with performing
39 40 relocations. ld operates in two modes, static or dynamic, as governed
40 41 by the -d option. In all cases, the output of ld is left in the file
41 42 a.out by default. See NOTES.
42 43
43 44
44 45 In dynamic mode, -dy, the default, relocatable object files that are
45 46 provided as arguments are combined to produce an executable object
46 47 file. This file is linked at execution with any shared object files
47 48 that are provided as arguments. If the -G option is specified,
48 49 relocatable object files are combined to produce a shared object.
49 50 Without the -G option, a dynamic executable is created.
50 51
51 52
52 53 In static mode, -dn, relocatable object files that are provided as
53 54 arguments are combined to produce a static executable file. If the -r
54 55 option is specified, relocatable object files are combined to produce
55 56 one relocatable object file. See Static Executables.
56 57
57 58
58 59 Dynamic linking is the most common model for combining relocatable
59 60 objects, and the eventual creation of processes within Solaris. This
60 61 environment tightly couples the work of the link-editor and the runtime
61 62 linker, ld.so.1(1). Both of these utilities, together with their
62 63 related technologies and utilities, are extensively documented in the
63 64 Linker and Libraries Guide.
64 65
65 66
66 67 If any argument is a library, ld by default searches the library
67 68 exactly once at the point the library is encountered on the argument
68 69 list. The library can be either a shared object or relocatable archive.
69 70 See ar.h(3HEAD)).
70 71
71 72
72 73 A shared object consists of an indivisible, whole unit that has been
73 74 generated by a previous link-edit of one or more input files. When the
74 75 link-editor processes a shared object, the entire contents of the
75 76 shared object become a logical part of the resulting output file image.
76 77 The shared object is not physically copied during the link-edit as its
77 78 actual inclusion is deferred until process execution. This logical
78 79 inclusion means that all symbol entries defined in the shared object
79 80 are made available to the link-editing process. See Chapter 4, Shared
80 81 Objects, in Linker and Libraries Guide
81 82
82 83
83 84 For an archive library, ld loads only those routines that define an
84 85 unresolved external reference. ld searches the symbol table of the
85 86 archive library sequentially to resolve external references that can be
86 87 satisfied by library members. This search is repeated until no external
87 88 references can be resolved by the archive. Thus, the order of members
88 89 in the library is functionally unimportant, unless multiple library
89 90 members exist that define the same external symbol. Archive libraries
90 91 that have interdependencies can require multiple command line
91 92 definitions, or the use of one of the -z rescan options. See Archive
92 93 Processing in Linker and Libraries Guide.
93 94
94 95
95 96 ld is a cross link-editor, able to link 32-bit objects or 64-bit
96 97 objects, for Sparc or x86 targets. ld uses the ELF class and machine
97 98 type of the first relocatable object on the command line to govern the
98 99 mode in which to operate. The mixing of 32-bit objects and 64-bit
99 100 objects is not permitted. Similarly, only objects of a single machine
100 101 type are allowed. See the -32, -64 and -z target options, and the
101 102 LD_NOEXEC_64 environment variable.
102 103
103 104 Static Executables
104 105 The creation of static executables has been discouraged for many
105 106 releases. In fact, 64-bit system archive libraries have never been
106 107 provided. Because a static executable is built against system archive
107 108 libraries, the executable contains system implementation details. This
108 109 self-containment has a number of drawbacks.
109 110
110 111 o The executable is immune to the benefits of system updates
111 112 delivered as shared objects. The executable therefore, must
112 113 be rebuilt to take advantage of many system improvements.
113 114
114 115 o The ability of the executable to run on future releases can
115 116 be compromised.
116 117
117 118 o The duplication of system implementation details negatively
118 119 affects system performance.
119 120
120 121
121 122 With Solaris 10, 32-bit system archive libraries are no longer
122 123 provided. Without these libraries, specifically libc.a, the creation
123 124 of static executables is no longer achievable without specialized
124 125 system knowledge. However, the capability of ld to process static
125 126 linking options, and the processing of archive libraries, remains
126 127 unchanged.
127 128
128 129 OPTIONS
129 130 The following options are supported.
130 131
131 132 -32 | -64
132 133
133 134 Creates a 32-bit, or 64-bit object.
134 135
135 136 By default, the class of the object being generated is determined
136 137 from the first ELF object processed from the command line. If no
137 138 objects are specified, the class is determined by the first object
138 139 encountered within the first archive processed from the command
139 140 line. If there are no objects or archives, the link-editor creates
140 141 a 32-bit object.
141 142
142 143 The -64 option is required to create a 64-bit object solely from a
143 144 mapfile.
144 145
145 146 This -32 or -64 options can also be used in the rare case of
146 147 linking entirely from an archive that contains a mixture of 32 and
147 148 64-bit objects. If the first object in the archive is not the class
148 149 of the object that is required to be created, then the -32 or -64
149 150 option can be used to direct the link-editor. See The 32-bit link-
150 151 editor and 64-bit link-editor in Linker and Libraries Guide.
151 152
152 153
153 154 -a
154 155
155 156 In static mode only, produces an executable object file. Undefined
156 157 references are not permitted. This option is the default behavior
157 158 for static mode. The -a option can not be used with the -r option.
158 159 See Static Executables under DESCRIPTION.
159 160
160 161
161 162 -b
162 163
163 164 In dynamic mode only, provides no special processing for dynamic
164 165 executable relocations that reference symbols in shared objects.
165 166 Without the -b option, the link-editor applies techniques within a
166 167 dynamic executable so that the text segment can remain read-only.
167 168 One technique is the creation of special position-independent
168 169 relocations for references to functions that are defined in shared
169 170 objects. Another technique arranges for data objects that are
170 171 defined in shared objects to be copied into the memory image of an
171 172 executable at runtime.
172 173
173 174 The -b option is intended for specialized dynamic objects and is
174 175 not recommended for general use. Its use suppresses all specialized
175 176 processing required to ensure an object's shareability, and can
176 177 even prevent the relocation of 64-bit executables.
177 178
178 179
179 180 -B direct | nodirect
180 181
181 182 These options govern direct binding. -B direct establishes direct
182 183 binding information by recording the relationship between each
183 184 symbol reference together with the dependency that provides the
184 185 definition. In addition, direct binding information is established
185 186 between each symbol reference and an associated definition within
186 187 the object being created. The runtime linker uses this information
187 188 to search directly for a symbol in the associated object rather
188 189 than to carry out a default symbol search.
189 190
190 191 Direct binding information can only be established to dependencies
191 192 specified with the link-edit. Thus, you should use the -z defs
192 193 option. Objects that wish to interpose on symbols in a direct
193 194 binding environment should identify themselves as interposers with
194 195 the -z interpose option. The use of -B direct enables -z lazyload
195 196 for all dependencies.
196 197
197 198 The -B nodirect option prevents any direct binding to the
198 199 interfaces offered by the object being created. The object being
199 200 created can continue to directly bind to external interfaces by
200 201 specifying the -z direct option. See Appendix D, Direct Bindings,
201 202 in Linker and Libraries Guide.
202 203
203 204
204 205 -B dynamic | static
205 206
206 207 Options governing library inclusion. -B dynamic is valid in dynamic
207 208 mode only. These options can be specified any number of times on
208 209 the command line as toggles: if the -B static option is given, no
209 210 shared objects are accepted until -B dynamic is seen. See the -l
210 211 option.
211 212
212 213
213 214 -B eliminate
214 215
215 216 Causes any global symbols, not assigned to a version definition, to
216 217 be eliminated from the symbol table. Version definitions can be
217 218 supplied by means of a mapfile to indicate the global symbols that
218 219 should remain visible in the generated object. This option achieves
219 220 the same symbol elimination as the auto-elimination directive that
220 221 is available as part of a mapfile version definition. This option
221 222 can be useful when combining versioned and non-versioned
222 223 relocatable objects. See also the -B local option and the -B reduce
223 224 option. See Defining Additional Symbols with a mapfile in Linker
224 225 and Libraries Guide.
225 226
226 227
227 228 -B group
228 229
229 230 Establishes a shared object and its dependencies as a group.
230 231 Objects within the group are bound to other members of the group at
231 232 runtime. This mode is similar to adding the object to the process
232 233 by using dlopen(3C) with the RTLD_GROUP mode. An object that has an
233 234 explicit dependency on a object identified as a group, becomes a
234 235 member of the group.
235 236
236 237 As the group must be self contained, use of the -B group option
237 238 also asserts the -z defs option.
238 239
239 240
240 241 -B local
241 242
242 243 Causes any global symbols, not assigned to a version definition, to
243 244 be reduced to local. Version definitions can be supplied by means
244 245 of a mapfile to indicate the global symbols that should remain
245 246 visible in the generated object. This option achieves the same
246 247 symbol reduction as the auto-reduction directive that is available
247 248 as part of a mapfile version definition. This option can be useful
248 249 when combining versioned and non-versioned relocatable objects. See
249 250 also the -B eliminate option and the -B reduce option. See Defining
250 251 Additional Symbols with a mapfile in Linker and Libraries Guide.
251 252
252 253
253 254 -B reduce
254 255
255 256 When generating a relocatable object, causes the reduction of
256 257 symbolic information defined by any version definitions. Version
257 258 definitions can be supplied by means of a mapfile to indicate the
258 259 global symbols that should remain visible in the generated object.
259 260 By default, when a relocatable object is generated, version
260 261 definitions are only recorded in the output image. The actual
261 262 reduction of symbolic information is carried out when the object is
262 263 used in the construction of a dynamic executable or shared object.
263 264 The -B reduce option is applied automatically when a dynamic
264 265 executable or shared object is created.
265 266
266 267
267 268 -B symbolic
268 269
269 270 In dynamic mode only. When building a shared object, binds
270 271 references to global symbols to their definitions, if available,
271 272 within the object. Normally, references to global symbols within
272 273 shared objects are not bound until runtime, even if definitions are
273 274 available. This model allows definitions of the same symbol in an
274 275 executable or other shared object to override the object's own
275 276 definition. ld issues warnings for undefined symbols unless -z defs
276 277 overrides.
277 278
278 279 The -B symbolic option is intended for specialized dynamic objects
279 280 and is not recommended for general use. To reduce the runtime
280 281 relocation processing that is required an object, the creation of a
281 282 version definition is recommended.
282 283
283 284
284 285 -c name
285 286
286 287 Records the configuration file name for use at runtime.
287 288 Configuration files can be employed to alter default search paths,
288 289 provide a directory cache, together with providing alternative
289 290 object dependencies. See crle(1).
290 291
291 292
292 293 -C
293 294
294 295 Demangles C++ symbol names displayed in diagnostic messages.
295 296
296 297
297 298 -d y | n
298 299
299 300 When -d y, the default, is specified, ld uses dynamic linking. When
300 301 -d n is specified, ld uses static linking. See Static Executables
301 302 under DESCRIPTION, and -B dynamic|static.
302 303
303 304
304 305 -D token,...
305 306
306 307 Prints debugging information as specified by each token, to the
307 308 standard error. The special token help indicates the full list of
308 309 tokens available. See Debugging Aids in Linker and Libraries Guide.
309 310
310 311
311 312 -e epsym
312 313 --entry epsym
313 314
314 315 Sets the entry point address for the output file to be the symbol
315 316 epsym.
316 317
317 318
318 319 -f name
319 320 --auxiliary name
320 321
321 322 Useful only when building a shared object. Specifies that the
322 323 symbol table of the shared object is used as an auxiliary filter on
323 324 the symbol table of the shared object specified by name. Multiple
324 325 instances of this option are allowed. This option can not be
325 326 combined with the -F option. See Generating Auxiliary Filters in
326 327 Linker and Libraries Guide.
327 328
328 329
329 330 -F name
330 331 --filter name
331 332
332 333 Useful only when building a shared object. Specifies that the
333 334 symbol table of the shared object is used as a filter on the symbol
334 335 table of the shared object specified by name. Multiple instances of
335 336 this option are allowed. This option can not be combined with the
336 337 -f option. See Generating Standard Filters in Linker and Libraries
337 338 Guide.
338 339
339 340
340 341 -G
341 342 -shared
342 343
343 344 In dynamic mode only, produces a shared object. Undefined symbols
344 345 are allowed. See Chapter 4, Shared Objects, in Linker and
345 346 Libraries Guide.
346 347
347 348
348 349 -h name
349 350 --soname name
350 351
351 352 In dynamic mode only, when building a shared object, records name
352 353 in the object's dynamic section. name is recorded in any dynamic
353 354 objects that are linked with this object rather than the object's
354 355 file system name. Accordingly, name is used by the runtime linker
355 356 as the name of the shared object to search for at runtime. See
356 357 Recording a Shared Object Name in Linker and Libraries Guide.
357 358
358 359
359 360 -i
360 361
361 362 Ignores LD_LIBRARY_PATH. This option is useful when an
362 363 LD_LIBRARY_PATH setting is in effect to influence the runtime
363 364 library search, which would interfere with the link-editing being
364 365 performed.
365 366
366 367
367 368 -I name
368 369 --dynamic-linker name
369 370
370 371 When building an executable, uses name as the path name of the
371 372 interpreter to be written into the program header. The default in
372 373 static mode is no interpreter. In dynamic mode, the default is the
373 374 name of the runtime linker, ld.so.1(1). Either case can be
374 375 overridden by -I name. exec(2) loads this interpreter when the
375 376 a.out is loaded, and passes control to the interpreter rather than
376 377 to the a.out directly.
377 378
378 379
379 380 -l x
380 381 --library x
381 382
382 383 Searches a library libx.so or libx.a, the conventional names for
383 384 shared object and archive libraries, respectively. In dynamic
384 385 mode, unless the -B static option is in effect, ld searches each
385 386 directory specified in the library search path for a libx.so or
386 387 libx.a file. The directory search stops at the first directory
387 388 containing either. ld chooses the file ending in .so if -lx expands
388 389 to two files with names of the form libx.so and libx.a. If no
389 390 libx.so is found, then ld accepts libx.a. In static mode, or when
390 391 the -B static option is in effect, ld selects only the file ending
391 392 in .a. ld searches a library when the library is encountered, so
392 393 the placement of -l is significant. See Linking With Additional
393 394 Libraries in Linker and Libraries Guide.
394 395
395 396
396 397 -L path
397 398 --library-path path
398 399
399 400 Adds path to the library search directories. ld searches for
400 401 libraries first in any directories specified by the -L options and
401 402 then in the standard directories. This option is useful only if the
402 403 option precedes the -l options to which the -L option applies. See
403 404 Directories Searched by the Link-Editor in Linker and Libraries
404 405 Guide.
405 406
406 407 The environment variable LD_LIBRARY_PATH can be used to supplement
407 408 the library search path, however the -L option is recommended, as
408 409 the environment variable is also interpreted by the runtime
409 410 environment. See LD_LIBRARY_PATH under ENVIRONMENT VARIABLES.
410 411
411 412
412 413 -m
413 414
414 415 Produces a memory map or listing of the input/output sections,
415 416 together with any non-fatal multiply-defined symbols, on the
416 417 standard output.
417 418
418 419
419 420 -M mapfile
420 421
421 422 Reads mapfile as a text file of directives to ld. This option can
422 423 be specified multiple times. If mapfile is a directory, then all
423 424 regular files, as defined by stat(2), within the directory are
424 425 processed. See Chapter 9, Mapfile Option, in Linker and Libraries
425 426 Guide. Example mapfiles are provided in /usr/lib/ld. See FILES.
426 427
427 428
428 429 -N string
429 430
430 431 This option causes a DT_NEEDED entry to be added to the .dynamic
431 432 section of the object being built. The value of the DT_NEEDED
432 433 string is the string that is specified on the command line. This
433 434 option is position dependent, and the DT_NEEDED .dynamic entry is
434 435 relative to the other dynamic dependencies discovered on the link-
435 436 edit line. This option is useful for specifying dependencies within
436 437 device driver relocatable objects when combined with the -dy and -r
437 438 options.
438 439
439 440
440 441 -o outfile
441 442 --output outfile
442 443
443 444 Produces an output object file that is named outfile. The name of
444 445 the default object file is a.out.
445 446
446 447
447 448 -p auditlib
448 449
449 450 Identifies an audit library, auditlib. This audit library is used
450 451 to audit the object being created at runtime. A shared object
451 452 identified as requiring auditing with the -p option, has this
452 453 requirement inherited by any object that specifies the shared
453 454 object as a dependency. See the -P option. See Runtime Linker
454 455 Auditing Interface in Linker and Libraries Guide.
455 456
456 457
457 458 -P auditlib
458 459
459 460 Identifies an audit library, auditlib. This audit library is used
460 461 to audit the dependencies of the object being created at runtime.
461 462 Dependency auditing can also be inherited from dependencies that
462 463 are identified as requiring auditing. See the -p option, and the -z
463 464 globalaudit option. See Runtime Linker Auditing Interface in Linker
464 465 and Libraries Guide.
465 466
466 467
467 468 -Q y | n
468 469
469 470 Under -Q y, an ident string is added to the .comment section of the
470 471 output file. This string identifies the version of the ld used to
471 472 create the file. This results in multiple ld idents when there have
472 473 been multiple linking steps, such as when using ld -r. This
473 474 identification is identical with the default action of the cc
474 475 command. -Q n suppresses version identification. .comment sections
475 476 can be manipulated by the mcs(1) utility.
476 477
477 478
478 479 -r
479 480 --relocatable
480 481
481 482 Combines relocatable object files to produce one relocatable object
482 483 file. ld does not complain about unresolved references. This
483 484 option cannot be used with the -a option.
484 485
485 486
486 487 -R path
487 488 -rpath path
488 489
489 490 A colon-separated list of directories used to specify library
490 491 search directories to the runtime linker. If present and not NULL,
491 492 the path is recorded in the output object file and passed to the
492 493 runtime linker. Multiple instances of this option are concatenated
493 494 together with each path separated by a colon. See Directories
494 495 Searched by the Runtime Linker in Linker and Libraries Guide.
495 496
496 497 The use of a runpath within an associated object is preferable to
497 498 setting global search paths such as through the LD_LIBRARY_PATH
498 499 environment variable. Only the runpaths that are necessary to find
499 500 the objects dependencies should be recorded. ldd(1) can also be
500 501 used to discover unused runpaths in dynamic objects, when used with
501 502 the -U option.
502 503
503 504 Various tokens can also be supplied with a runpath that provide a
504 505 flexible means of identifying system capabilities or an objects
505 506 location. See Appendix C, Establishing Dependencies with Dynamic
506 507 String Tokens, in Linker and Libraries Guide. The $ORIGIN token is
507 508 especially useful in allowing dynamic objects to be relocated to
508 509 different locations in the file system.
509 510
510 511
511 512 -s
512 513 --strip-all
513 514
514 515 Strips symbolic information from the output file. Any debugging
515 516 information, that is, .line, .debug*, and .stab* sections, and
516 517 their associated relocation entries are removed. Except for
517 518 relocatable files, a symbol table SHT_SYMTAB and its associated
518 519 string table section are not created in the output object file. The
519 520 elimination of a SHT_SYMTAB symbol table can reduce the .stab*
520 521 debugging information that is generated using the compiler drivers
521 522 -g option. See the -z redlocsym and -z noldynsym options.
522 523
523 524
524 525 -S supportlib
525 526
526 527 The shared object supportlib is loaded with ld and given
527 528 information regarding the linking process. Shared objects that are
528 529 defined by using the -S option can also be supplied using the
529 530 SGS_SUPPORT environment variable. See Link-Editor Support Interface
530 531 in Linker and Libraries Guide.
531 532
532 533
533 534 -t
534 535
535 536 Turns off the warning for multiply-defined symbols that have
536 537 different sizes or different alignments.
537 538
538 539
539 540 -u symname
540 541 --undefined symname
541 542
542 543 Enters symname as an undefined symbol in the symbol table. This
543 544 option is useful for loading entirely from an archive library. In
544 545 this instance, an unresolved reference is needed to force the
545 546 loading of the first routine. The placement of this option on the
546 547 command line is significant. This option must be placed before the
547 548 library that defines the symbol. See Defining Additional Symbols
548 549 with the u option in Linker and Libraries Guide.
549 550
550 551
551 552 -V
552 553 --version
553 554
554 555 Outputs a message giving information about the version of ld being
555 556 used.
556 557
557 558
558 559 -Y P,dirlist
559 560
560 561 Changes the default directories used for finding libraries. dirlist
561 562 is a colon-separated path list.
562 563
563 564
564 565 -z absexec
565 566
566 567 Useful only when building a dynamic executable. Specifies that
567 568 references to external absolute symbols should be resolved
568 569 immediately instead of being left for resolution at runtime. In
569 570 very specialized circumstances, this option removes text
570 571 relocations that can result in excessive swap space demands by an
571 572 executable.
572 573
573 574
574 575 -z allextract | defaultextract | weakextract
575 576 --whole-archive | --no-whole-archive
576 577
577 578 Alters the extraction criteria of objects from any archives that
578 579 follow. By default, archive members are extracted to satisfy
579 580 undefined references and to promote tentative definitions with data
580 581 definitions. Weak symbol references do not trigger extraction.
581 582 Under the -z allextract or --whole-archive options, all archive
582 583 members are extracted from the archive. Under -z weakextract, weak
583 584 references trigger archive extraction. The -z defaultextract or
584 585 --no-whole-archive options provide a means of returning to the
585 586 default following use of the former extract options. See Archive
586 587 Processing in Linker and Libraries Guide.
587 588
588 589
589 590 -z altexec64
590 591
591 592 Execute the 64-bit ld. The creation of very large 32-bit objects
592 593 can exhaust the virtual memory that is available to the 32-bit ld.
593 594 The -z altexec64 option can be used to force the use of the
594 595 associated 64-bit ld. The 64-bit ld provides a larger virtual
595 596 address space for building 32-bit objects. See The 32-bit link-
596 597 editor and 64-bit link-editor in Linker and Libraries Guide.
597 598
598 599
599 600 -z aslr[=state]
600 601
601 602 Specify whether the executable's address space should be randomized
602 603 on execution. If state is "enabled" randomization will always
603 604 occur when this executable is run (regardless of inherited
604 605 settings). If state is "disabled" randomization will never occur
605 606 when this executable is run. If state is omitted, ASLR is enabled.
606 607
607 608 An executable that should simply use the settings inherited from
608 609 its environment should not use this flag at all.
609 610
610 611
611 612 -z combreloc | nocombreloc
612 613
613 614 By default, ld combines multiple relocation sections when building
614 615 executables or shared objects. This section combination differs
615 616 from relocatable objects, in which relocation sections are
616 617 maintained in a one-to-one relationship with the sections to which
617 618 the relocations must be applied. The -z nocombreloc option disables
618 619 this merging of relocation sections, and preserves the one-to-one
619 620 relationship found in the original relocatable objects.
620 621
621 622 ld sorts the entries of data relocation sections by their symbol
622 623 reference. This sorting reduces runtime symbol lookup. When
623 624 multiple relocation sections are combined, this sorting produces
624 625 the least possible relocation overhead when objects are loaded into
625 626 memory, and speeds the runtime loading of dynamic objects.
626 627
627 628 Historically, the individual relocation sections were carried over
628 629 to any executable or shared object, and the -z combreloc option was
629 630 required to enable the relocation section merging previously
630 631 described. Relocation section merging is now the default. The -z
631 632 combreloc option is still accepted for the benefit of old build
632 633 environments, but the option is unnecessary, and has no effect.
633 634
634 635
635 636 -z assert-deflib
636 637 -z assert-deflib=libname
637 638
638 639 Enables warnings that check the location of where libraries passed
639 640 in with -l are found. If the link-editor finds a library on its
640 641 default search path it will emit a warning. This warning can be
641 642 made fatal in conjunction with the option -z fatal-warnings.
642 643 Passing libname white lists a library from this check. The library
643 644 must be the full name of the library, e.g. libc.so. To white list
644 645 multiple libraries, the -z assert-deflib=libname option can be
645 646 repeated multiple times. This option is useful when trying to build
646 647 self-contained objects where a referenced library might exist in
647 648 the default system library path and in alternate paths specified by
648 649 -L, but you only want the alternate paths to be used.
649 650
650 651
651 652 -z defs | nodefs
652 653 --no-undefined
653 654
654 655 The -z defs option and the --no-undefined option force a fatal
655 656 error if any undefined symbols remain at the end of the link. This
656 657 mode is the default when an executable is built. For historic
657 658 reasons, this mode is not the default when building a shared
658 659 object. Use of the -z defs option is recommended, as this mode
659 660 assures the object being built is self-contained. A self-contained
660 661 object has all symbolic references resolved internally, or to the
661 662 object's immediate dependencies.
662 663
663 664 The -z nodefs option allows undefined symbols. For historic
664 665 reasons, this mode is the default when a shared object is built.
665 666 When used with executables, the behavior of references to such
666 667 undefined symbols is unspecified. Use of the -z nodefs option is
667 668 not recommended.
668 669
669 670
670 671 -z direct | nodirect
671 672
672 673 Enables or disables direct binding to any dependencies that follow
673 674 on the command line. These options allow finer control over direct
674 675 binding than the global counterpart -B direct. The -z direct option
675 676 also differs from the -B direct option in the following areas.
676 677 Direct binding information is not established between a symbol
677 678 reference and an associated definition within the object being
678 679 created. Lazy loading is not enabled.
679 680
680 681
681 682 -z endfiltee
682 683
683 684 Marks a filtee so that when processed by a filter, the filtee
684 685 terminates any further filtee searches by the filter. See Reducing
685 686 Filtee Searches in Linker and Libraries Guide.
686 687
687 688
688 689 -z fatal-warnings | nofatal-warnings
689 690 --fatal-warnings | --no-fatal-warnings
690 691
691 692 Controls the behavior of warnings emitted from the link-editor.
692 693 Setting -z fatal-warnings promotes warnings emitted by the link-
693 694 editor to fatal errors that will cause the link-editor to fail
694 695 before linking. -z nofatal-warnings instead demotes these warnings
695 696 such that they will not cause the link-editor to exit prematurely.
696 697
697 698
698 699
699 700 -z finiarray=function
700 701
701 702 Appends an entry to the .fini_array section of the object being
702 703 built. If no .fini_array section is present, a section is created.
703 704 The new entry is initialized to point to function. See
704 705 Initialization and Termination Sections in Linker and Libraries
705 706 Guide.
706 707
707 708
708 709 -z globalaudit
709 710
710 711 This option supplements an audit library definition that has been
711 712 recorded with the -P option. This option is only meaningful when
712 713 building a dynamic executable. Audit libraries that are defined
713 714 within an object with the -P option typically allow for the
714 715 auditing of the immediate dependencies of the object. The -z
715 716 globalaudit promotes the auditor to a global auditor, thus allowing
716 717 the auditing of all dependencies. See Invoking the Auditing
717 718 Interface in Linker and Libraries Guide.
718 719
719 720 An auditor established with the -P option and the -z globalaudit
720 721 option, is equivalent to the auditor being established with the
721 722 LD_AUDIT environment variable. See ld.so.1(1).
722 723
723 724
724 725 -z groupperm | nogroupperm
725 726
726 727 Assigns, or deassigns each dependency that follows to a unique
727 728 group. The assignment of a dependency to a group has the same
728 729 effect as if the dependency had been built using the -B group
729 730 option.
730 731
731 732
732 733 -z guidance[=id1,id2...]
733 734
734 735 Give messages suggesting link-editor features that could improve
735 736 the resulting dynamic object.
736 737
737 738 Specific classes of suggestion can be silenced by specifying an
738 739 optional comma separated list of guidance identifiers.
739 740
740 741 The current classes of suggestion provided are:
741 742
742 743
743 744 Enable use of direct binding
744 745
745 746 Suggests that -z direct or -B direct be present prior to any
746 747 specified dependency. This allows predictable symbol binding
747 748 at runtime.
748 749
749 750 Can be disabled with -z guidance=nodirect
750 751
751 752
752 753 Enable lazy dependency loading
753 754
754 755 Suggests that -z lazyload be present prior to any specified
755 756 dependency. This allows the dynamic object to be loaded more
756 757 quickly.
757 758
758 759 Can be disabled with -z guidance=nolazyload.
759 760
760 761
761 762 Shared objects should define all their dependencies.
762 763
763 764 Suggests that -z defs be specified on the link-editor command
764 765 line. Shared objects that explicitly state all their
765 766 dependencies behave more predictably when used.
766 767
767 768 Can be be disabled with -z guidance=nodefs
768 769
769 770
770 771 Version 2 mapfile syntax
771 772
772 773 Suggests that any specified mapfiles use the more readable
773 774 version 2 syntax.
774 775
775 776 Can be disabled with -z guidance=nomapfile.
776 777
777 778
778 779 Read-only text segment
779 780
780 781 Should any runtime relocations within the text segment exist,
781 782 suggests that the object be compiled with position independent
782 783 code (PIC). Keeping large allocatable sections read-only
783 784 allows them to be shared between processes using a given shared
784 785 object.
785 786
786 787 Can be disabled with -z guidance=notext
787 788
788 789
789 790 No unused dependencies
790 791
791 792 Suggests that any dependency not referenced by the resulting
792 793 dynamic object be removed from the link-editor command line.
793 794
794 795 Can be disabled with -z guidance=nounused.
795 796
796 797
797 798 -z help
798 799 --help
799 800
800 801 Print a summary of the command line options on the standard output
801 802 and exit.
802 803
803 804
804 805 -z ignore | record
805 806
806 807 Ignores, or records, dynamic dependencies that are not referenced
807 808 as part of the link-edit. Ignores, or records, unreferenced ELF
808 809 sections from the relocatable objects that are read as part of the
809 810 link-edit. By default, -z record is in effect.
810 811
811 812 If an ELF section is ignored, the section is eliminated from the
812 813 output file being generated. A section is ignored when three
813 814 conditions are true. The eliminated section must contribute to an
814 815 allocatable segment. The eliminated section must provide no global
815 816 symbols. No other section from any object that contributes to the
816 817 link-edit, must reference an eliminated section.
817 818
818 819
819 820 -z initarray=function
820 821
821 822 Appends an entry to the .init_array section of the object being
822 823 built. If no .init_array section is present, a section is created.
823 824 The new entry is initialized to point to function. See
824 825 Initialization and Termination Sections in Linker and Libraries
825 826 Guide.
826 827
827 828
828 829 -z initfirst
829 830
830 831 Marks the object so that its runtime initialization occurs before
831 832 the runtime initialization of any other objects brought into the
832 833 process at the same time. In addition, the object runtime
833 834 finalization occurs after the runtime finalization of any other
834 835 objects removed from the process at the same time. This option is
835 836 only meaningful when building a shared object.
836 837
837 838
838 839 -z interpose
839 840
840 841 Marks the object as an interposer. At runtime, an object is
841 842 identified as an explicit interposer if the object has been tagged
842 843 using the -z interpose option. An explicit interposer is also
843 844 established when an object is loaded using the LD_PRELOAD
844 845 environment variable. Implicit interposition can occur because of
845 846 the load order of objects, however, this implicit interposition is
846 847 unknown to the runtime linker. Explicit interposition can ensure
847 848 that interposition takes place regardless of the order in which
848 849 objects are loaded. Explicit interposition also ensures that the
849 850 runtime linker searches for symbols in any explicit interposers
850 851 when direct bindings are in effect.
851 852
852 853
853 854 -z lazyload | nolazyload
854 855
855 856 Enables or disables the marking of dynamic dependencies to be
856 857 lazily loaded. Dynamic dependencies which are marked lazyload are
857 858 not loaded at initial process start-up. These dependencies are
858 859 delayed until the first binding to the object is made. Note: Lazy
859 860 loading requires the correct declaration of dependencies, together
860 861 with associated runpaths for each dynamic object used within a
861 862 process. See Lazy Loading of Dynamic Dependencies in Linker and
862 863 Libraries Guide.
863 864
864 865
865 866 -z ld32=arg1,arg2,...
866 867 -z ld64=arg1,arg2,...
867 868
868 869 The class of the link-editor is affected by the class of the output
869 870 file being created and by the capabilities of the underlying
870 871 operating system. The -z ld[32|64] options provide a means of
871 872 defining any link-editor argument. The defined argument is only
872 873 interpreted, respectively, by the 32-bit class or 64-bit class of
873 874 the link-editor.
874 875
875 876 For example, support libraries are class specific, so the correct
876 877 class of support library can be ensured using:
877 878
878 879 ld ... -z ld32=-Saudit32.so.1 -z ld64=-Saudit64.so.1 ...
879 880
880 881
881 882 The class of link-editor that is invoked is determined from the ELF
882 883 class of the first relocatable file that is seen on the command
883 884 line. This determination is carried out prior to any -z ld[32|64]
884 885 processing.
885 886
886 887
887 888 -z loadfltr
888 889
889 890 Marks a filter to indicate that filtees must be processed
890 891 immediately at runtime. Normally, filter processing is delayed
891 892 until a symbol reference is bound to the filter. The runtime
892 893 processing of an object that contains this flag mimics that which
893 894 occurs if the LD_LOADFLTR environment variable is in effect. See
894 895 the ld.so.1(1).
895 896
896 897
897 898 -z muldefs
898 899 --allow-multiple-definition
899 900
900 901 Allows multiple symbol definitions. By default, multiple symbol
901 902 definitions that occur between relocatable objects result in a
902 903 fatal error condition. This option, suppresses the error condition,
903 904 allowing the first symbol definition to be taken.
904 905
905 906
906 907 -z nocompstrtab
907 908
908 909 Disables the compression of ELF string tables. By default, string
909 910 compression is applied to SHT_STRTAB sections, and to SHT_PROGBITS
910 911 sections that have their SHF_MERGE and SHF_STRINGS section flags
911 912 set.
912 913
913 914
914 915 -z nodefaultlib
915 916
916 917 Marks the object so that the runtime default library search path,
917 918 used after any LD_LIBRARY_PATH or runpaths, is ignored. This option
918 919 implies that all dependencies of the object can be satisfied from
919 920 its runpath.
920 921
921 922
922 923 -z nodelete
923 924
924 925 Marks the object as non-deletable at runtime. This mode is similar
925 926 to adding the object to the process by using dlopen(3C) with the
926 927 RTLD_NODELETE mode.
927 928
928 929
929 930 -z nodlopen
930 931
931 932 Marks the object as not available to dlopen(3C), either as the
932 933 object specified by the dlopen(), or as any form of dependency
933 934 required by the object specified by the dlopen(). This option is
934 935 only meaningful when building a shared object.
935 936
936 937
937 938 -z nodump
938 939
939 940 Marks the object as not available to dldump(3C).
940 941
941 942
942 943 -z noldynsym
943 944
944 945 Prevents the inclusion of a .SUNW_ldynsym section in dynamic
945 946 executables or sharable libraries. The .SUNW_ldynsym section
946 947 augments the .dynsym section by providing symbols for local
947 948 functions. Local function symbols allow debuggers to display local
948 949 function names in stack traces from stripped programs. Similarly,
949 950 dladdr(3C) is able to supply more accurate results.
950 951
951 952 The -z noldynsym option also prevents the inclusion of the two
952 953 symbol sort sections that are related to the .SUNW_ldynsym section.
953 954 The .SUNW_dynsymsort section provides sorted access to regular
954 955 function and variable symbols. The .SUNW_dyntlssort section
955 956 provides sorted access to thread local storage (TLS) variable
956 957 symbols.
957 958
958 959 The .SUNW_ldynsym, .SUNW_dynsymsort, and .SUNW_dyntlssort sections,
959 960 which becomes part of the allocable text segment of the resulting
960 961 file, cannot be removed by strip(1). Therefore, the -z noldynsym
961 962 option is the only way to prevent their inclusion. See the -s and
962 963 -z redlocsym options.
963 964
964 965
965 966 -z nopartial
966 967
967 968 Partially initialized symbols, that are defined within relocatable
968 969 object files, are expanded in the output file being generated.
969 970
970 971
971 972 -z noversion
972 973
973 974 Does not record any versioning sections. Any version sections or
974 975 associated .dynamic section entries are not generated in the output
975 976 image.
976 977
977 978
978 979 -z now
979 980
980 981 Marks the object as requiring non-lazy runtime binding. This mode
981 982 is similar to adding the object to the process by using dlopen(3C)
982 983 with the RTLD_NOW mode. This mode is also similar to having the
983 984 LD_BIND_NOW environment variable in effect. See ld.so.1(1).
984 985
985 986
986 987 -z origin
987 988
988 989 Marks the object as requiring immediate $ORIGIN processing at
989 990 runtime. This option is only maintained for historic
990 991 compatibility, as the runtime analysis of objects to provide for
991 992 $ORIGIN processing is now default.
992 993
993 994
994 995 -z preinitarray=function
995 996
996 997 Appends an entry to the .preinitarray section of the object being
997 998 built. If no .preinitarray section is present, a section is
998 999 created. The new entry is initialized to point to function. See
999 1000 Initialization and Termination Sections in Linker and Libraries
1000 1001 Guide.
1001 1002
1002 1003
1003 1004 -z redlocsym
1004 1005
1005 1006 Eliminates all local symbols except for the SECT symbols from the
1006 1007 symbol table SHT_SYMTAB. All relocations that refer to local
1007 1008 symbols are updated to refer to the corresponding SECT symbol. This
1008 1009 option allows specialized objects to greatly reduce their symbol
1009 1010 table sizes. Eliminated local symbols can reduce the .stab*
1010 1011 debugging information that is generated using the compiler drivers
1011 1012 -g option. See the -s and -z noldynsym options.
1012 1013
1013 1014
1014 1015 -z relaxreloc
1015 1016
1016 1017 ld normally issues a fatal error upon encountering a relocation
1017 1018 using a symbol that references an eliminated COMDAT section. If -z
1018 1019 relaxreloc is enabled, ld instead redirects such relocations to the
1019 1020 equivalent symbol in the COMDAT section that was kept. -z
1020 1021 relaxreloc is a specialized option, mainly of interest to compiler
1021 1022 authors, and is not intended for general use.
1022 1023
1023 1024
1024 1025 -z rescan-now
1025 1026 -z rescan
1026 1027
1027 1028 These options rescan the archive files that are provided to the
1028 1029 link-edit. By default, archives are processed once as the archives
1029 1030 appear on the command line. Archives are traditionally specified at
1030 1031 the end of the command line so that their symbol definitions
1031 1032 resolve any preceding references. However, specifying archives
1032 1033 multiple times to satisfy their own interdependencies can be
1033 1034 necessary.
1034 1035
1035 1036 -z rescan-now is a positional option, and is processed by the link-
1036 1037 editor immediately when encountered on the command line. All
1037 1038 archives seen on the command line up to that point are immediately
1038 1039 reprocessed in an attempt to locate additional archive members that
1039 1040 resolve symbol references. This archive rescanning is repeated
1040 1041 until a pass over the archives occurs in which no new members are
1041 1042 extracted.
1042 1043
1043 1044 -z rescan is a position independent option. The link-editor defers
1044 1045 the rescan operation until after it has processed the entire
1045 1046 command line, and then initiates a final rescan operation over all
1046 1047 archives seen on the command line. The -z rescan operation can
1047 1048 interact incorrectly with objects that contain initialization
1048 1049 (.init) or finalization (.fini) sections, preventing the code in
1049 1050 those sections from running. For this reason, -z rescan is
1050 1051 deprecated, and use of -z rescan-now is advised.
1051 1052
1052 1053
1053 1054 -z rescan-start ... -z rescan-end
1054 1055 --start-group ... --end-group
1055 1056 -( ... -)
1056 1057
1057 1058 Defines an archive rescan group. This is a positional construct,
1058 1059 and is processed by the link-editor immediately upon encountering
1059 1060 the closing delimiter option. Archives found within the group
1060 1061 delimiter options are reprocessed as a group in an attempt to
1061 1062 locate additional archive members that resolve symbol references.
1062 1063 This archive rescanning is repeated until a pass over the archives
1063 1064 occurs in which no new members are extracted. Archive rescan
1064 1065 groups cannot be nested.
1065 1066
1066 1067
1067 1068 -z target=sparc|x86
1068 1069
1069 1070 Specifies the machine type for the output object. Supported targets
1070 1071 are Sparc and x86. The 32-bit machine type for the specified target
1071 1072 is used unless the -64 option is also present, in which case the
1072 1073 corresponding 64-bit machine type is used. By default, the machine
1073 1074 type of the object being generated is determined from the first ELF
1074 1075 object processed from the command line. If no objects are
1075 1076 specified, the machine type is determined by the first object
1076 1077 encountered within the first archive processed from the command
1077 1078 line. If there are no objects or archives, the link-editor assumes
1078 1079 the native machine. This option is useful when creating an object
1079 1080 directly with ld whose input is solely from a mapfile. See the -M
1080 1081 option. It can also be useful in the rare case of linking entirely
1081 1082 from an archive that contains objects of different machine types
1082 1083 for which the first object is not of the desired machine type. See
1083 1084 The 32-bit link-editor and 64-bit link-editor in Linker and
1084 1085 Libraries Guide.
1085 1086
1086 1087
1087 1088 -z text
1088 1089
1089 1090 In dynamic mode only, forces a fatal error if any relocations
1090 1091 against non-writable, allocatable sections remain. For historic
1091 1092 reasons, this mode is not the default when building an executable
1092 1093 or shared object. However, its use is recommended to ensure that
1093 1094 the text segment of the dynamic object being built is shareable
1094 1095 between multiple running processes. A shared text segment incurs
1095 1096 the least relocation overhead when loaded into memory. See
1096 1097 Position-Independent Code in Linker and Libraries Guide.
1097 1098
1098 1099
1099 1100 -z textoff
1100 1101
↓ open down ↓ |
1058 lines elided |
↑ open up ↑ |
1101 1102 In dynamic mode only, allows relocations against all allocatable
1102 1103 sections, including non-writable ones. This mode is the default
1103 1104 when building a shared object.
1104 1105
1105 1106
1106 1107 -z textwarn
1107 1108
1108 1109 In dynamic mode only, lists a warning if any relocations against
1109 1110 non-writable, allocatable sections remain. This mode is the default
1110 1111 when building an executable.
1112 +
1113 +
1114 + -z type=exec|kmod|reloc|shared
1115 +
1116 + Specifies the type of object to create.
1117 +
1118 +
1119 + exec
1120 +
1121 + Dynamic executable
1122 +
1123 +
1124 + reloc
1125 +
1126 + Relocatable object
1127 +
1128 +
1129 + shared
1130 +
1131 + Dynamic shared object
1132 +
1133 +
1134 + kmod
1135 +
1136 + illumos kernel module
1111 1137
1112 1138
1113 1139 -z verbose
1114 1140
1115 1141 This option provides additional warning diagnostics during a link-
1116 1142 edit. Presently, this option conveys suspicious use of
1117 1143 displacement relocations. This option also conveys the restricted
1118 1144 use of static TLS relocations when building shared objects. In
1119 1145 future, this option might be enhanced to provide additional
1120 1146 diagnostics that are deemed too noisy to be generated by default.
1121 1147
1122 1148
1123 1149 -zwrap=symbol
1124 1150 -wrap= symbol
1125 1151 --wrap= symbol
1126 1152
1127 1153 Rename undefined references to symbol in order to allow wrapper
1128 1154 code to be linked into the output object without having to modify
1129 1155 source code. When -z wrap is specified, all undefined references to
1130 1156 symbol are modified to reference __wrap_symbol, and all references
1131 1157 to __real_symbol are modified to reference symbol. The user is
1132 1158 expected to provide an object containing the __wrap_symbol
1133 1159 function. This wrapper function can call __real_symbol in order to
1134 1160 reference the actual function being wrapped.
1135 1161
1136 1162 The following is an example of a wrapper for the malloc(3C)
1137 1163 function:
1138 1164
1139 1165 void *
1140 1166 __wrap_malloc(size_t c)
1141 1167 {
1142 1168 (void) printf("malloc called with %zu\n", c);
1143 1169 return (__real_malloc(c));
1144 1170 }
1145 1171
1146 1172 If you link other code with this file using -z wrap=malloc to
1147 1173 compile all the objects, then all calls to malloc will call the
1148 1174 function __wrap_malloc instead. The call to __real_malloc will call
1149 1175 the real malloc function.
1150 1176
1151 1177 The real and wrapped functions should be maintained in separate
1152 1178 source files. Otherwise, the compiler or assembler may resolve the
1153 1179 call instead of leaving that operation for the link-editor to carry
1154 1180 out, and prevent the wrap from occurring.
1155 1181
1156 1182
1157 1183 ENVIRONMENT VARIABLES
1158 1184 LD_ALTEXEC
1159 1185
1160 1186 An alternative link-editor path name. ld executes, and passes
1161 1187 control to this alternative link-editor. This environment variable
1162 1188 provides a generic means of overriding the default link-editor that
1163 1189 is called from the various compiler drivers. See the -z altexec64
1164 1190 option.
1165 1191
1166 1192
1167 1193 LD_LIBRARY_PATH
1168 1194
1169 1195 A list of directories in which to search for the libraries
1170 1196 specified using the -l option. Multiple directories are separated
1171 1197 by a colon. In the most general case, this environment variable
1172 1198 contains two directory lists separated by a semicolon:
1173 1199
1174 1200 dirlist1;dirlist2
1175 1201
1176 1202
1177 1203 If ld is called with any number of occurrences of -L, as in:
1178 1204
1179 1205 ld ... -Lpath1 ... -Lpathn ...
1180 1206
1181 1207
1182 1208 then the search path ordering is:
1183 1209
1184 1210 dirlist1 path1 ... pathn dirlist2 LIBPATH
1185 1211
1186 1212
1187 1213 When the list of directories does not contain a semicolon, the list
1188 1214 is interpreted as dirlist2.
1189 1215
1190 1216 The LD_LIBRARY_PATH environment variable also affects the runtime
1191 1217 linkers search for dynamic dependencies.
1192 1218
1193 1219 This environment variable can be specified with a _32 or _64
1194 1220 suffix. This makes the environment variable specific, respectively,
1195 1221 to 32-bit or 64-bit processes and overrides any non-suffixed
1196 1222 version of the environment variable that is in effect.
1197 1223
1198 1224
1199 1225 LD_NOEXEC_64
1200 1226
1201 1227 Suppresses the automatic execution of the 64-bit link-editor. By
1202 1228 default, the link-editor executes the 64-bit version when the ELF
1203 1229 class of the first relocatable file identifies a 64-bit object. The
1204 1230 64-bit image that a 32-bit link-editor can create, has some
1205 1231 limitations. However, some link-edits might find the use of the
1206 1232 32-bit link-editor faster.
1207 1233
1208 1234
1209 1235 LD_OPTIONS
1210 1236
1211 1237 A default set of options to ld. LD_OPTIONS is interpreted by ld
1212 1238 just as though its value had been placed on the command line,
1213 1239 immediately following the name used to invoke ld, as in:
1214 1240
1215 1241 ld $LD_OPTIONS ... other-arguments ...
1216 1242
1217 1243
1218 1244
1219 1245
1220 1246 LD_RUN_PATH
1221 1247
1222 1248 An alternative mechanism for specifying a runpath to the link-
1223 1249 editor. See the -R option. If both LD_RUN_PATH and the -R option
1224 1250 are specified, -R supersedes.
1225 1251
1226 1252
1227 1253 SGS_SUPPORT
1228 1254
1229 1255 Provides a colon-separated list of shared objects that are loaded
1230 1256 with the link-editor and given information regarding the linking
1231 1257 process. This environment variable can be specified with a _32 or
1232 1258 _64 suffix. This makes the environment variable specific,
1233 1259 respectively, to the 32-bit or 64-bit class of ld and overrides any
1234 1260 non-suffixed version of the environment variable that is in effect.
1235 1261 See the -S option.
1236 1262
1237 1263
1238 1264
1239 1265 Notice that environment variable-names that begin with the characters
1240 1266 'LD_' are reserved for possible future enhancements to ld and
1241 1267 ld.so.1(1).
1242 1268
1243 1269 FILES
1244 1270 libx.so
1245 1271 shared object libraries.
1246 1272
1247 1273
1248 1274 libx.a
1249 1275 archive libraries.
1250 1276
1251 1277
1252 1278 a.out
1253 1279 default output file.
1254 1280
1255 1281
1256 1282 LIBPATH
1257 1283 For 32-bit libraries, the default search path is
1258 1284 /usr/ccs/lib, followed by /lib, and finally /usr/lib.
1259 1285 For 64-bit libraries, the default search path is
1260 1286 /lib/64, followed by /usr/lib/64.
1261 1287
1262 1288
1263 1289 /usr/lib/ld
1264 1290 A directory containing several mapfiles that can be used
1265 1291 during link-editing. These mapfiles provide various
1266 1292 capabilities, such as defining memory layouts, aligning
1267 1293 bss, and defining non-executable stacks.
1268 1294
1269 1295
1270 1296 ATTRIBUTES
1271 1297 See attributes(5) for descriptions of the following attributes:
1272 1298
1273 1299
1274 1300
1275 1301
1276 1302 +--------------------+-----------------+
1277 1303 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
1278 1304 +--------------------+-----------------+
1279 1305 |Interface Stability | Committed |
1280 1306 +--------------------+-----------------+
1281 1307
1282 1308 SEE ALSO
1283 1309 as(1), crle(1), gprof(1), ld.so.1(1), ldd(1), mcs(1), pvs(1), exec(2),
1284 1310 stat(2), dlopen(3C), dldump(3C), elf(3ELF), ar.h(3HEAD), a.out(4),
1285 1311 attributes(5)
1286 1312
1287 1313
1288 1314 Linker and Libraries Guide
1289 1315
1290 1316 NOTES
1291 1317 Default options applied by ld are maintained for historic reasons. In
1292 1318 today's programming environment, where dynamic objects dominate,
1293 1319 alternative defaults would often make more sense. However, historic
1294 1320 defaults must be maintained to ensure compatibility with existing
1295 1321 program development environments. Historic defaults are called out
1296 1322 wherever possible in this manual. For a description of the current
1297 1323 recommended options, see Appendix A, Link-Editor Quick Reference, in
1298 1324 Linker and Libraries Guide.
1299 1325
1300 1326
1301 1327 If the file being created by ld already exists, the file is unlinked
1302 1328 after all input files have been processed. A new file with the
1303 1329 specified name is then created. This allows ld to create a new version
1304 1330 of the file, while simultaneously allowing existing processes that are
1305 1331 accessing the old file contents to continue running. If the old file
1306 1332 has no other links, the disk space of the removed file is freed when
1307 1333 the last process referencing the file terminates.
1308 1334
1309 1335
1310 1336 The behavior of ld when the file being created already exists was
1311 1337 changed with SXCE build 43. In older versions, the existing file was
1312 1338 rewritten in place, an approach with the potential to corrupt any
1313 1339 running processes that is using the file. This change has an
1314 1340 implication for output files that have multiple hard links in the file
1315 1341 system. Previously, all links would remain intact, with all links
1316 1342 accessing the new file contents. The new ld behavior breaks such links,
1317 1343 with the result that only the specified output file name references the
1318 1344 new file. All the other links continue to reference the old file. To
1319 1345 ensure consistent behavior, applications that rely on multiple hard
1320 1346 links to linker output files should explicitly remove and relink the
1321 1347 other file names.
1322 1348
1323 1349
1324 1350
1325 1351 May 13, 2017 LD(1)
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX