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