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