OSDN Git Service

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