Add IBM 370 support.
[deliverable/binutils-gdb.git] / ld / ld.1
1 .\" Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
3 .TH ld 1 "17 August 1992" "cygnus support" "GNU Development Tools"
4 .de BP
5 .sp
6 .ti \-.2i
7 \(**
8 ..
9
10 .SH NAME
11 ld \- the GNU linker
12
13 .SH SYNOPSIS
14 .hy 0
15 .na
16 .TP
17 .B ld
18 .RB "[\|" \-o "
19 .I output\c
20 \&\|] \c
21 .I objfile\c
22 \&.\|.\|.
23 .br
24 .RB "[\|" \-A\c
25 .I architecture\c
26 \&\|]
27 .RB "[\|" "\-b\ "\c
28 .I input-format\c
29 \&\|]
30 .RB "[\|" \-Bstatic "\|]"
31 .RB "[\|" \-Bdynamic "\|]"
32 .RB "[\|" \-Bsymbolic "\|]"
33 .RB "[\|" "\-c\ "\c
34 .I commandfile\c
35 \&\|]
36 .RB "[\|" \-\-cref "\|]"
37 .RB "[\|" \-d | \-dc | \-dp\c
38 \|]
39 .br
40 .RB "[\|" "\-defsym\ "\c
41 .I symbol\c
42 \& = \c
43 .I expression\c
44 \&\|]
45 .RB "[\|" \-\-demangle "\|]"
46 .RB "[\|" \-\-no\-demangle "\|]"
47 .RB "[\|" "\-e\ "\c
48 .I entry\c
49 \&\|]
50 .RB "[\|" \-embedded\-relocs "\|]"
51 .RB "[\|" \-E "\|]"
52 .RB "[\|" \-export\-dynamic "\|]"
53 .RB "[\|" "\-f\ "\c
54 .I name\c
55 \&\|]
56 .RB "[\|" "\-\-auxiliary\ "\c
57 .I name\c
58 \&\|]
59 .RB "[\|" "\-F\ "\c
60 .I name\c
61 \&\|]
62 .RB "[\|" "\-\-filter\ "\c
63 .I name\c
64 \&\|]
65 .RB "[\|" "\-format\ "\c
66 .I input-format\c
67 \&\|]
68 .RB "[\|" \-g "\|]"
69 .RB "[\|" \-G
70 .I size\c
71 \&\|]
72 .RB "[\|" "\-h\ "\c
73 .I name\c
74 \&\|]
75 .RB "[\|" "\-soname\ "\c
76 .I name\c
77 \&\|]
78 .RB "[\|" \-\-help "\|]"
79 .RB "[\|" \-i "\|]"
80 .RB "[\|" \-l\c
81 .I ar\c
82 \&\|]
83 .RB "[\|" \-L\c
84 .I searchdir\c
85 \&\|]
86 .RB "[\|" \-M "\|]"
87 .RB "[\|" \-Map
88 .I mapfile\c
89 \&\|]
90 .RB "[\|" \-m
91 .I emulation\c
92 \&\|]
93 .RB "[\|" \-n | \-N "\|]"
94 .RB "[\|" \-noinhibit-exec "\|]"
95 .RB "[\|" \-no\-keep\-memory "\|]"
96 .RB "[\|" \-no\-warn\-mismatch "\|]"
97 .RB "[\|" \-O\c
98 .I level\c
99 \&\|]
100 .RB "[\|" "\-oformat\ "\c
101 .I output-format\c
102 \&\|]
103 .RB "[\|" "\-R\ "\c
104 .I filename\c
105 \&\|]
106 .RB "[\|" \-relax "\|]"
107 .RB "[\|" \-r | \-Ur "\|]"
108 .RB "[\|" "\-rpath\ "\c
109 .I directory\c
110 \&\|]
111 .RB "[\|" "\-rpath\-link\ "\c
112 .I directory\c
113 \&\|]
114 .RB "[\|" \-S "\|]"
115 .RB "[\|" \-s "\|]"
116 .RB "[\|" \-shared "\|]"
117 .RB "[\|" \-sort\-common "\|]"
118 .RB "[\|" "\-split\-by\-reloc\ "\c
119 .I count\c
120 \&\|]
121 .RB "[\|" \-split\-by\-file "\|]"
122 .RB "[\|" "\-T\ "\c
123 .I commandfile\c
124 \&\|]
125 .RB "[\|" "\-Ttext\ "\c
126 .I textorg\c
127 \&\|]
128 .RB "[\|" "\-Tdata\ "\c
129 .I dataorg\c
130 \&\|]
131 .RB "[\|" "\-Tbss\ "\c
132 .I bssorg\c
133 \&\|]
134 .RB "[\|" \-t "\|]"
135 .RB "[\|" "\-u\ "\c
136 .I sym\c
137 \&]
138 .RB "[\|" \-V "\|]"
139 .RB "[\|" \-v "\|]"
140 .RB "[\|" \-\-verbose "\|]"
141 .RB "[\|" \-\-version "\|]"
142 .RB "[\|" \-warn\-common "\|]"
143 .RB "[\|" \-warn\-constructors "\|]"
144 .RB "[\|" \-warn\-multiple\-gp "\|]"
145 .RB "[\|" \-warn\-once "\|]"
146 .RB "[\|" \-warn\-section\-align "\|]"
147 .RB "[\|" \-\-whole\-archive "\|]"
148 .RB "[\|" \-\-no\-whole\-archive "\|]"
149 .RB "[\|" "\-\-wrap\ "\c
150 .I symbol\c
151 \&\|]
152 .RB "[\|" \-X "\|]"
153 .RB "[\|" \-x "\|]"
154 .ad b
155 .hy 1
156 .SH DESCRIPTION
157 \c
158 .B ld\c
159 \& combines a number of object and archive files, relocates
160 their data and ties up symbol references. Often the last step in
161 building a new compiled program to run is a call to \c
162 .B ld\c
163 \&.
164
165 \c
166 .B ld\c
167 \& accepts Linker Command Language files
168 to provide explicit and total control over the linking process.
169 This man page does not describe the command language; see the `\|\c
170 .B ld\c
171 \|' entry in `\|\c
172 .B info\c
173 \|', or the manual
174 .I
175 ld: the GNU linker
176 \&, for full details on the command language and on other aspects of
177 the GNU linker.
178
179 This version of \c
180 .B ld\c
181 \& uses the general purpose BFD libraries
182 to operate on object files. This allows \c
183 .B ld\c
184 \& to read, combine, and
185 write object files in many different formats\(em\&for example, COFF or
186 \c
187 .B a.out\c
188 \&. Different formats may be linked together to produce any
189 available kind of object file. You can use `\|\c
190 .B objdump \-i\c
191 \|' to get a list of formats supported on various architectures; see
192 .BR objdump ( 1 ).
193
194 Aside from its flexibility, the GNU linker is more helpful than other
195 linkers in providing diagnostic information. Many linkers abandon
196 execution immediately upon encountering an error; whenever possible,
197 \c
198 .B ld\c
199 \& continues executing, allowing you to identify other errors
200 (or, in some cases, to get an output file in spite of the error).
201
202 The GNU linker \c
203 .B ld\c
204 \& is meant to cover a broad range of situations,
205 and to be as compatible as possible with other linkers. As a result,
206 you have many choices to control its behavior through the command line,
207 and through environment variables.
208
209 .SH OPTIONS
210 The plethora of command-line options may seem intimidating, but in
211 actual practice few of them are used in any particular context.
212 For instance, a frequent use of \c
213 .B ld\c
214 \& is to link standard Unix
215 object files on a standard, supported Unix system. On such a system, to
216 link a file \c
217 .B hello.o\c
218 \&:
219 .sp
220 .br
221 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
222 .br
223 .sp
224 This tells \c
225 .B ld\c
226 \& to produce a file called \c
227 .B output\c
228 \& as the
229 result of linking the file \c
230 .B /lib/crt0.o\c
231 \& with \c
232 .B hello.o\c
233 \& and
234 the library \c
235 .B libc.a\c
236 \& which will come from the standard search
237 directories.
238
239 The command-line options to \c
240 .B ld\c
241 \& may be specified in any order, and
242 may be repeated at will. For the most part, repeating an option with a
243 different argument will either have no further effect, or override prior
244 occurrences (those further to the left on the command line) of an
245 option.
246
247 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
248 \c
249 .B \-A\c
250 \&, \c
251 .B \-b\c
252 \& (or its synonym \c
253 .B \-format\c
254 \&), \c
255 .B \-defsym\c
256 \&,
257 \c
258 .B \-L\c
259 \&, \c
260 .B \-l\c
261 \&, \c
262 .B \-R\c
263 \&, and \c
264 .B \-u\c
265 \&.
266
267 The list of object files to be linked together, shown as \c
268 .I objfile\c
269 \&,
270 may follow, precede, or be mixed in with command-line options; save that
271 an \c
272 .I objfile\c
273 \& argument may not be placed between an option flag and
274 its argument.
275
276 Usually the linker is invoked with at least one object file, but other
277 forms of binary input files can also be specified with \c
278 .B \-l\c
279 \&,
280 \c
281 .B \-R\c
282 \&, and the script command language. If \c
283 .I no\c
284 \& binary input
285 files at all are specified, the linker does not produce any output, and
286 issues the message `\|\c
287 .B No input files\c
288 \|'.
289
290 Option arguments must either follow the option letter without intervening
291 whitespace, or be given as separate arguments immediately following the
292 option that requires them.
293
294 .TP
295 .BI "-A" "architecture"
296 In the current release of \c
297 .B ld\c
298 \&, this option is useful only for the
299 Intel 960 family of architectures. In that \c
300 .B ld\c
301 \& configuration, the
302 \c
303 .I architecture\c
304 \& argument is one of the two-letter names identifying
305 members of the 960 family; the option specifies the desired output
306 target, and warns of any incompatible instructions in the input files.
307 It also modifies the linker's search strategy for archive libraries, to
308 support the use of libraries specific to each particular
309 architecture, by including in the search loop names suffixed with the
310 string identifying the architecture.
311
312 For example, if your \c
313 .B ld\c
314 \& command line included `\|\c
315 .B \-ACA\c
316 \|' as
317 well as `\|\c
318 .B \-ltry\c
319 \|', the linker would look (in its built-in search
320 paths, and in any paths you specify with \c
321 .B \-L\c
322 \&) for a library with
323 the names
324 .sp
325 .br
326 try
327 .br
328 libtry.a
329 .br
330 tryca
331 .br
332 libtryca.a
333 .br
334 .sp
335
336 The first two possibilities would be considered in any event; the last
337 two are due to the use of `\|\c
338 .B \-ACA\c
339 \|'.
340
341 Future releases of \c
342 .B ld\c
343 \& may support similar functionality for
344 other architecture families.
345
346 You can meaningfully use \c
347 .B \-A\c
348 \& more than once on a command line, if
349 an architecture family allows combination of target architectures; each
350 use will add another pair of name variants to search for when \c
351 .B \-l
352 specifies a library.
353
354 .TP
355 .BI "\-b " "input-format"
356 Specify the binary format for input object files that follow this option
357 on the command line. You don't usually need to specify this, as
358 \c
359 .B ld\c
360 \& is configured to expect as a default input format the most
361 usual format on each machine. \c
362 .I input-format\c
363 \& is a text string, the
364 name of a particular format supported by the BFD libraries.
365 \c
366 .B \-format \c
367 .I input-format\c
368 \&\c
369 \& has the same effect, as does the script command
370 .BR TARGET .
371
372 You may want to use this option if you are linking files with an unusual
373 binary format. You can also use \c
374 .B \-b\c
375 \& to switch formats explicitly (when
376 linking object files of different formats), by including
377 \c
378 .B \-b \c
379 .I input-format\c
380 \&\c
381 \& before each group of object files in a
382 particular format.
383
384 The default format is taken from the environment variable
385 .B GNUTARGET\c
386 \&. You can also define the input
387 format from a script, using the command \c
388 .B TARGET\c
389 \&.
390
391 .TP
392 .B \-Bstatic
393 Do not link against shared libraries. This is only meaningful on
394 platforms for which shared libraries are supported.
395
396 .TP
397 .B \-Bdynamic
398 Link against dynamic libraries. This is only meaningful on platforms
399 for which shared libraries are supported. This option is normally the
400 default on such platforms.
401
402 .TP
403 .B \-Bsymbolic
404 When creating a shared library, bind references to global symbols to
405 the definition within the shared library, if any. Normally, it is
406 possible for a program linked against a shared library to override the
407 definition within the shared library. This option is only meaningful
408 on ELF platforms which support shared libraries.
409
410 .TP
411 .BI "\-c " "commandfile"
412 Directs \c
413 .B ld\c
414 \& to read link commands from the file
415 \c
416 .I commandfile\c
417 \&. These commands will completely override \c
418 .B ld\c
419 \&'s
420 default link format (rather than adding to it); \c
421 .I commandfile\c
422 \& must
423 specify everything necessary to describe the target format.
424
425
426 You may also include a script of link commands directly in the command
427 line by bracketing it between `\|\c
428 .B {\c
429 \|' and `\|\c
430 .B }\c
431 \|' characters.
432
433 .TP
434 .B \-\-cref
435 Output a cross reference table. If a linker map file is being
436 generated, the cross reference table is printed to the map file.
437 Otherwise, it is printed on the standard output.
438
439 .TP
440 .B \-d
441 .TP
442 .B \-dc
443 .TP
444 .B \-dp
445 These three options are equivalent; multiple forms are supported for
446 compatibility with other linkers. Use any of them to make \c
447 .B ld
448 assign space to common symbols even if a relocatable output file is
449 specified (\c
450 .B \-r\c
451 \&). The script command
452 \c
453 .B FORCE_COMMON_ALLOCATION\c
454 \& has the same effect.
455
456 .TP
457 .BI "-defsym " "symbol" "\fR = \fP" expression
458 Create a global symbol in the output file, containing the absolute
459 address given by \c
460 .I expression\c
461 \&. You may use this option as many
462 times as necessary to define multiple symbols in the command line. A
463 limited form of arithmetic is supported for the \c
464 .I expression\c
465 \& in this
466 context: you may give a hexadecimal constant or the name of an existing
467 symbol, or use \c
468 .B +\c
469 \& and \c
470 .B \-\c
471 \& to add or subtract hexadecimal
472 constants or symbols. If you need more elaborate expressions, consider
473 using the linker command language from a script.
474
475 .TP
476 .B \-\-demangle
477 .TP
478 .B \-\-no\-demangle
479 These options control whether to demangle symbol names in error
480 messages and other output. When the linker is told to demangle, it
481 tries to present symbol names in a readable fashion: it strips leading
482 underscores if they are used by the object file format, and converts
483 C++ mangled symbol names into user readable names. The linker will
484 demangle by default unless the environment variable
485 .B COLLECT_NO_DEMANGLE
486 is set. These options may be used to override the default.
487
488 .TP
489 .BI "-e " "entry"\c
490 \&
491 Use \c
492 .I entry\c
493 \& as the explicit symbol for beginning execution of your
494 program, rather than the default entry point. See the `\|\c
495 .B ld\c
496 \|' entry in `\|\c
497 .B info\c
498 \|' for a
499 discussion of defaults and other ways of specifying the
500 entry point.
501
502 .TP
503 .B \-embedded\-relocs
504 This option is only meaningful when linking MIPS embedded PIC code,
505 generated by the
506 .B \-membedded\-pic
507 option to the GNU compiler and assembler. It causes the linker to
508 create a table which may be used at runtime to relocate any data which
509 was statically initialized to pointer values. See the code in
510 testsuite/ld-empic for details.
511
512 .TP
513 .B \-E
514 .TP
515 .B \-export\-dynamic
516 When creating an ELF file, add all symbols to the dynamic symbol table.
517 Normally, the dynamic symbol table contains only symbols which are used
518 by a dynamic object. This option is needed for some uses of
519 .I dlopen.
520
521 .TP
522 .BI "-f " "name"
523 .TP
524 .BI "--auxiliary " "name"
525 When creating an ELF shared object, set the internal DT_AUXILIARY field
526 to the specified name. This tells the dynamic linker that the symbol
527 table of the shared object should be used as an auxiliary filter on the
528 symbol table of the shared object
529 .I name.
530
531 .TP
532 .BI "-F " "name"
533 .TP
534 .BI "--filter " "name"
535 When creating an ELF shared object, set the internal DT_FILTER field to
536 the specified name. This tells the dynamic linker that the symbol table
537 of the shared object should be used as a filter on the symbol table of
538 the shared object
539 .I name.
540
541 .TP
542 .BI "\-format " "input\-format"
543 Synonym for \c
544 .B \-b\c
545 \& \c
546 .I input\-format\c
547 \&.
548
549 .TP
550 .B \-g
551 Accepted, but ignored; provided for compatibility with other tools.
552
553 .TP
554 .BI "\-G " "size"\c
555 Set the maximum size of objects to be optimized using the GP register
556 to
557 .I size
558 under MIPS ECOFF. Ignored for other object file formats.
559
560 .TP
561 .BI "-h " "name"
562 .TP
563 .BI "-soname " "name"
564 When creating an ELF shared object, set the internal DT_SONAME field to
565 the specified name. When an executable is linked with a shared object
566 which has a DT_SONAME field, then when the executable is run the dynamic
567 linker will attempt to load the shared object specified by the DT_SONAME
568 field rather than the using the file name given to the linker.
569
570 .TP
571 .B \-\-help
572 Print a summary of the command-line options on the standard output and exit.
573 This option and
574 .B \-\-version
575 begin with two dashes instead of one
576 for compatibility with other GNU programs. The other options start with
577 only one dash for compatibility with other linkers.
578
579 .TP
580 .B \-i
581 Perform an incremental link (same as option \c
582 .B \-r\c
583 \&).
584
585 .TP
586 .BI "\-l" "ar"\c
587 \&
588 Add an archive file \c
589 .I ar\c
590 \& to the list of files to link. This
591 option may be used any number of times. \c
592 .B ld\c
593 \& will search its
594 path-list for occurrences of \c
595 .B lib\c
596 .I ar\c
597 \&.a\c
598 \& for every \c
599 .I ar
600 specified.
601
602 .TP
603 .BI "\-L" "searchdir"
604 This command adds path \c
605 .I searchdir\c
606 \& to the list of paths that
607 \c
608 .B ld\c
609 \& will search for archive libraries. You may use this option
610 any number of times.
611
612 The default set of paths searched (without being specified with
613 \c
614 .B \-L\c
615 \&) depends on what emulation mode \c
616 .B ld\c
617 \& is using, and in
618 some cases also on how it was configured. The
619 paths can also be specified in a link script with the \c
620 .B SEARCH_DIR
621 command.
622
623 .TP
624 .B \-M
625 Print (to the standard output file) a link map\(em\&diagnostic information
626 about where symbols are mapped by \c
627 .B ld\c
628 \&, and information on global
629 common storage allocation.
630
631 .TP
632 .BI "\-Map " "mapfile"\c
633 Print to the file
634 .I mapfile
635 a link map\(em\&diagnostic information
636 about where symbols are mapped by \c
637 .B ld\c
638 \&, and information on global
639 common storage allocation.
640
641 .TP
642 .BI "\-m " "emulation"\c
643 Emulate the
644 .I emulation
645 linker. You can list the available emulations with the
646 .I \-\-verbose
647 or
648 .I \-V
649 options. This option overrides the compiled-in default, which is the
650 system for which you configured
651 .BR ld .
652
653 .TP
654 .B \-N
655 specifies readable and writable \c
656 .B text\c
657 \& and \c
658 .B data\c
659 \& sections. If
660 the output format supports Unix style magic numbers, the output is
661 marked as \c
662 .B OMAGIC\c
663 \&.
664
665 When you use the `\|\c
666 .B \-N\c
667 \&\|' option, the linker does not page-align the
668 data segment.
669
670 .TP
671 .B \-n
672 sets the text segment to be read only, and \c
673 .B NMAGIC\c
674 \& is written
675 if possible.
676
677 .TP
678 .B \-noinhibit\-exec
679 Normally, the linker will not produce an output file if it encounters
680 errors during the link process. With this flag, you can specify that
681 you wish the output file retained even after non-fatal errors.
682
683 .TP
684 .B \-no\-keep\-memory
685 The linker normally optimizes for speed over memory usage by caching
686 the symbol tables of input files in memory. This option tells the
687 linker to instead optimize for memory usage, by rereading the symbol
688 tables as necessary. This may be required if the linker runs out of
689 memory space while linking a large executable.
690
691 .TP
692 .B \-no\-warn\-mismatch
693 Normally the linker will give an error if you try to link together
694 input files that are mismatched for some reason, perhaps because they
695 have been compiled for different processors or for different
696 endiannesses. This option tells the linker that it should silently
697 permit such possible errors. This option should only be used with
698 care, in cases when you have taken some special action that ensures
699 that the linker errors are inappropriate.
700
701 .TP
702 .BI "\-o " "output"
703 .I output\c
704 \& is a name for the program produced by \c
705 .B ld\c
706 \&; if this
707 option is not specified, the name `\|\c
708 .B a.out\c
709 \|' is used by default. The
710 script command \c
711 .B OUTPUT\c
712 \& can also specify the output file name.
713
714 .TP
715 .BI "\-O" "level"
716 Generate optimized output files. This might use significantly more
717 time and therefore probably should be enabled only for generating the
718 final binary.
719 \c
720 .I level\c
721 \& is supposed to be a numeric value. Any value greater than zero enables
722 the optimizations.
723
724 .TP
725 .BI "\-oformat " "output\-format"
726 Specify the binary format for the output object file.
727 You don't usually need to specify this, as
728 \c
729 .B ld\c
730 \& is configured to produce as a default output format the most
731 usual format on each machine. \c
732 .I output-format\c
733 \& is a text string, the
734 name of a particular format supported by the BFD libraries.
735 The script command
736 .B OUTPUT_FORMAT
737 can also specify the output format, but this option overrides it.
738
739 .TP
740 .BI "\-R " "filename"
741 Read symbol names and their addresses from \c
742 .I filename\c
743 \&, but do not
744 relocate it or include it in the output. This allows your output file
745 to refer symbolically to absolute locations of memory defined in other
746 programs.
747
748 .TP
749 .B \-relax
750 An option with machine dependent effects. Currently this option is only
751 supported on the H8/300.
752
753 On some platforms, use this option to perform global optimizations that
754 become possible when the linker resolves addressing in your program, such
755 as relaxing address modes and synthesizing new instructions in the
756 output object file.
757
758 On platforms where this is not supported, `\|\c
759 .B \-relax\c
760 \&\|' is accepted, but has no effect.
761
762 .TP
763 .B \-r
764 Generates relocatable output\(em\&i.e., generate an output file that can in
765 turn serve as input to \c
766 .B ld\c
767 \&. This is often called \c
768 .I partial
769 linking\c
770 \&. As a side effect, in environments that support standard Unix
771 magic numbers, this option also sets the output file's magic number to
772 \c
773 .B OMAGIC\c
774 \&.
775 If this option is not specified, an absolute file is produced. When
776 linking C++ programs, this option \c
777 .I will not\c
778 \& resolve references to
779 constructors; \c
780 .B \-Ur\c
781 \& is an alternative.
782
783 This option does the same as \c
784 .B \-i\c
785 \&.
786
787 .TP
788 .B \-rpath\ \fIdirectory
789 Add a directory to the runtime library search path. This is used when
790 linking an ELF executable with shared objects. All
791 .B \-rpath
792 arguments are concatenated and passed to the runtime linker, which uses
793 them to locate shared objects at runtime. The
794 .B \-rpath
795 option is also used when locating shared objects which are needed by
796 shared objects explicitly included in the link; see the description of
797 the
798 .B \-rpath\-link
799 option. If
800 .B \-rpath
801 is not used when linking an ELF executable, the contents of the
802 environment variable
803 .B LD_RUN_PATH
804 will be used if it is defined.
805
806 The
807 .B \-rpath
808 option may also be used on SunOS. By default, on SunOS, the linker
809 will form a runtime search path out of all the
810 .B \-L
811 options it is given. If a
812 .B \-rpath
813 option is used, the runtime search path will be formed exclusively
814 using the
815 .B \-rpath
816 options, ignoring
817 the
818 .B \-L
819 options. This can be useful when using gcc, which adds many
820 .B \-L
821 options which may be on NFS mounted filesystems.
822
823 .TP
824 .B \-rpath\-link\ \fIdirectory
825 When using ELF or SunOS, one shared library may require another. This
826 happens when an
827 .B ld\ \-shared
828 link includes a shared library as one of the input files.
829
830 When the linker encounters such a dependency when doing a non-shared,
831 non-relocateable link, it will automatically try to locate the required
832 shared library and include it in the link, if it is not included
833 explicitly. In such a case, the
834 .B \-rpath\-link
835 option specifies the first set of directories to search. The
836 .B \-rpath\-link
837 option may specify a sequence of directory names either by specifying
838 a list of names separated by colons, or by appearing multiple times.
839
840 If the required shared library is not found, the linker will issue a
841 warning and continue with the link.
842
843 .TP
844 .B \-S
845 Omits debugger symbol information (but not all symbols) from the output file.
846
847 .TP
848 .B \-s
849 Omits all symbol information from the output file.
850
851 .TP
852 .B \-shared
853 Create a shared library. This is currently only supported on ELF and
854 SunOS platforms (on SunOS it is not required, as the linker will
855 automatically create a shared library when there are undefined symbols
856 and the
857 .B \-e
858 option is not used).
859
860 .TP
861 .B \-sort\-common
862 Normally, when
863 .B ld
864 places the global common symbols in the appropriate output sections,
865 it sorts them by size. First come all the one byte symbols, then all
866 the two bytes, then all the four bytes, and then everything else.
867 This is to prevent gaps between symbols due to
868 alignment constraints. This option disables that sorting.
869
870 .TP
871 .B \-split\-by\-reloc\ \fIcount
872 Trys to creates extra sections in the output file so that no single
873 output section in the file contains more than
874 .I count
875 relocations.
876 This is useful when generating huge relocatable for downloading into
877 certain real time kernels with the COFF object file format; since COFF
878 cannot represent more than 65535 relocations in a single section.
879 Note that this will fail to work with object file formats which do not
880 support arbitrary sections. The linker will not split up individual
881 input sections for redistribution, so if a single input section
882 contains more than
883 .I count
884 relocations one output section will contain that many relocations.
885
886 .TP
887 .B \-split\-by\-file
888 Similar to
889 .B \-split\-by\-reloc
890 but creates a new output section for each input file.
891
892 .TP
893 .BI "\-Tbss " "org"\c
894 .TP
895 .BI "\-Tdata " "org"\c
896 .TP
897 .BI "\-Ttext " "org"\c
898 Use \c
899 .I org\c
900 \& as the starting address for\(em\&respectively\(em\&the
901 \c
902 .B bss\c
903 \&, \c
904 .B data\c
905 \&, or the \c
906 .B text\c
907 \& segment of the output file.
908 \c
909 .I org\c
910 \& must be a hexadecimal integer.
911
912 .TP
913 .BI "\-T " "commandfile"
914 Equivalent to \c
915 .B \-c \c
916 .I commandfile\c
917 \&\c
918 \&; supported for compatibility with
919 other tools.
920
921 .TP
922 .B \-t
923 Prints names of input files as \c
924 .B ld\c
925 \& processes them.
926
927 .TP
928 .BI "\-u " "sym"
929 Forces \c
930 .I sym\c
931 \& to be entered in the output file as an undefined symbol.
932 This may, for example, trigger linking of additional modules from
933 standard libraries. \c
934 .B \-u\c
935 \& may be repeated with different option
936 arguments to enter additional undefined symbols.
937
938 .TP
939 .B \-Ur
940 For anything other than C++ programs, this option is equivalent to
941 \c
942 .B \-r\c
943 \&: it generates relocatable output\(em\&i.e., an output file that can in
944 turn serve as input to \c
945 .B ld\c
946 \&. When linking C++ programs, \c
947 .B \-Ur
948 .I will\c
949 \& resolve references to constructors, unlike \c
950 .B \-r\c
951 \&.
952
953 .TP
954 .B \-\-verbose
955 Display the version number for \c
956 .B ld
957 and list the supported emulations.
958 Display which input files can and can not be opened.
959
960 .TP
961 .B \-v, \-V
962 Display the version number for \c
963 .B ld\c
964 \&.
965 The
966 .B \-V
967 option also lists the supported emulations.
968
969 .TP
970 .B \-\-version
971 Display the version number for \c
972 .B ld
973 and exit.
974
975 .TP
976 .B \-warn\-common
977 Warn when a common symbol is combined with another common symbol or with
978 a symbol definition. Unix linkers allow this somewhat sloppy practice,
979 but linkers on some other operating systems do not. This option allows
980 you to find potential problems from combining global symbols.
981
982 .TP
983 .B \-warn\-constructors
984 Warn if any global constructors are used. This is only useful for a
985 few object file formats. For formats like COFF or ELF, the linker can
986 not detect the use of global constructors.
987
988 .TP
989 .B \-warn\-multiple\-gp
990 Warn if the output file requires multiple global-pointer values. This
991 option is only meaningful for certain processors, such as the Alpha.
992
993 .TP
994 .B \-warn\-once
995 Only warn once for each undefined symbol, rather than once per module
996 which refers to it.
997
998 .TP
999 .B \-warn\-section\-align
1000 Warn if the address of an output section is changed because of
1001 alignment. Typically, the alignment will be set by an input section.
1002 The address will only be changed if it not explicitly specified; that
1003 is, if the SECTIONS command does not specify a start address for the
1004 section.
1005
1006 .TP
1007 .B \-\-whole\-archive
1008 For each archive mentioned on the command line after the
1009 .B \-\-whole\-archive
1010 option, include every object file in the archive in the link, rather
1011 than searching the archive for the required object files. This is
1012 normally used to turn an archive file into a shared library, forcing
1013 every object to be included in the resulting shared library.
1014
1015 .TP
1016 .B \-\-no\-whole\-archive
1017 Turn off the effect of the
1018 .B \-\-whole\-archive
1019 option for archives which appear later on the command line.
1020
1021 .TP
1022 .BI "--wrap " "symbol"
1023 Use a wrapper function for
1024 .I symbol.
1025 Any undefined reference to
1026 .I symbol
1027 will be resolved to
1028 .BI "__wrap_" "symbol".
1029 Any undefined reference to
1030 .BI "__real_" "symbol"
1031 will be resolved to
1032 .I symbol.
1033
1034 .TP
1035 .B \-X
1036 Delete all temporary local symbols. For most targets, this is all local
1037 symbols whose names begin with `\|\c
1038 .B L\c
1039 \|'.
1040
1041 .TP
1042 .B \-x
1043 Delete all local symbols.
1044
1045 .PP
1046
1047 .SH ENVIRONMENT
1048 \c
1049 You can change the behavior of
1050 .B ld\c
1051 \& with the environment variable \c
1052 .B GNUTARGET\c
1053 \&.
1054
1055 \c
1056 .B GNUTARGET\c
1057 \& determines the input-file object format if you don't
1058 use \c
1059 .B \-b\c
1060 \& (or its synonym \c
1061 .B \-format\c
1062 \&). Its value should be one
1063 of the BFD names for an input format. If there is no
1064 \c
1065 .B GNUTARGET\c
1066 \& in the environment, \c
1067 .B ld\c
1068 \& uses the natural format
1069 of the host. If \c
1070 .B GNUTARGET\c
1071 \& is set to \c
1072 .B default\c
1073 \& then BFD attempts to discover the
1074 input format by examining binary input files; this method often
1075 succeeds, but there are potential ambiguities, since there is no method
1076 of ensuring that the magic number used to flag object-file formats is
1077 unique. However, the configuration procedure for BFD on each system
1078 places the conventional format for that system first in the search-list,
1079 so ambiguities are resolved in favor of convention.
1080
1081 .PP
1082
1083 .SH "SEE ALSO"
1084
1085 .BR objdump ( 1 )
1086 .br
1087 .br
1088 .RB "`\|" ld "\|' and `\|" binutils "\|'"
1089 entries in
1090 .B info\c
1091 .br
1092 .I
1093 ld: the GNU linker\c
1094 , Steve Chamberlain and Roland Pesch;
1095 .I
1096 The GNU Binary Utilities\c
1097 , Roland H. Pesch.
1098
1099 .SH COPYING
1100 Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
1101 .PP
1102 Permission is granted to make and distribute verbatim copies of
1103 this manual provided the copyright notice and this permission notice
1104 are preserved on all copies.
1105 .PP
1106 Permission is granted to copy and distribute modified versions of this
1107 manual under the conditions for verbatim copying, provided that the
1108 entire resulting derived work is distributed under the terms of a
1109 permission notice identical to this one.
1110 .PP
1111 Permission is granted to copy and distribute translations of this
1112 manual into another language, under the above conditions for modified
1113 versions, except that this permission notice may be included in
1114 translations approved by the Free Software Foundation instead of in
1115 the original English.
This page took 0.053924 seconds and 4 git commands to generate.