* dwarf2dbg.c (user_filenum, user_filenum_allocated): Remove.
[deliverable/binutils-gdb.git] / ld / ld.1
CommitLineData
a2b64bed
NC
1.\" Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2.\" 2001 Free Software Foundation, Inc.
252b5132 3.\" See section COPYING for conditions for redistribution
fd89e65f 4.TH ld 1 "" "Free Software Foundation" "GNU Development Tools"
252b5132
RH
5.de BP
6.sp
7.ti \-.2i
8\(**
9..
10
11.SH NAME
12ld \- the GNU linker
13
14.SH SYNOPSIS
15.hy 0
16.na
17.TP
18.B ld
19.RB "[\|" \-o "
20.I output\c
21\&\|] \c
22.I objfile\c
23\&.\|.\|.
24.br
25.RB "[\|" \-A\c
26.I architecture\c
27\&\|]
28.RB "[\|" "\-b\ "\c
29.I input-format\c
30\&\|]
31.RB "[\|" \-Bstatic "\|]"
32.RB "[\|" \-Bdynamic "\|]"
33.RB "[\|" \-Bsymbolic "\|]"
34.RB "[\|" "\-c\ "\c
35.I commandfile\c
36\&\|]
37.RB "[\|" \-\-cref "\|]"
38.RB "[\|" \-d | \-dc | \-dp\c
39\|]
40.br
41.RB "[\|" "\-defsym\ "\c
42.I symbol\c
176355da 43\&=\c
252b5132
RH
44.I expression\c
45\&\|]
46.RB "[\|" \-\-demangle "\|]"
47.RB "[\|" \-\-no\-demangle "\|]"
48.RB "[\|" "\-e\ "\c
49.I entry\c
50\&\|]
51.RB "[\|" \-embedded\-relocs "\|]"
52.RB "[\|" \-E "\|]"
53.RB "[\|" \-export\-dynamic "\|]"
54.RB "[\|" "\-f\ "\c
55.I name\c
56\&\|]
57.RB "[\|" "\-\-auxiliary\ "\c
58.I name\c
59\&\|]
60.RB "[\|" "\-F\ "\c
61.I name\c
62\&\|]
63.RB "[\|" "\-\-filter\ "\c
64.I name\c
65\&\|]
66.RB "[\|" "\-format\ "\c
67.I input-format\c
68\&\|]
69.RB "[\|" \-g "\|]"
70.RB "[\|" \-G
71.I size\c
72\&\|]
73.RB "[\|" "\-h\ "\c
74.I name\c
75\&\|]
76.RB "[\|" "\-soname\ "\c
77.I name\c
78\&\|]
79.RB "[\|" \-\-help "\|]"
80.RB "[\|" \-i "\|]"
81.RB "[\|" \-l\c
82.I ar\c
83\&\|]
84.RB "[\|" \-L\c
85.I searchdir\c
86\&\|]
87.RB "[\|" \-M "\|]"
88.RB "[\|" \-Map
89.I mapfile\c
90\&\|]
91.RB "[\|" \-m
92.I emulation\c
93\&\|]
94.RB "[\|" \-n | \-N "\|]"
95.RB "[\|" \-noinhibit-exec "\|]"
96.RB "[\|" \-no\-keep\-memory "\|]"
97.RB "[\|" \-no\-warn\-mismatch "\|]"
98.RB "[\|" \-O\c
99.I level\c
100\&\|]
0088edd2 101.RB "[\|" "\--oformat\ "\c
252b5132
RH
102.I output-format\c
103\&\|]
104.RB "[\|" "\-R\ "\c
105.I filename\c
106\&\|]
107.RB "[\|" \-relax "\|]"
108.RB "[\|" \-r | \-Ur "\|]"
109.RB "[\|" "\-rpath\ "\c
110.I directory\c
111\&\|]
112.RB "[\|" "\-rpath\-link\ "\c
113.I directory\c
114\&\|]
115.RB "[\|" \-S "\|]"
116.RB "[\|" \-s "\|]"
117.RB "[\|" \-shared "\|]"
118.RB "[\|" \-sort\-common "\|]"
119.RB "[\|" "\-split\-by\-reloc\ "\c
120.I count\c
121\&\|]
122.RB "[\|" \-split\-by\-file "\|]"
123.RB "[\|" "\-T\ "\c
124.I commandfile\c
125\&\|]
176355da
NC
126.RB "[\|" "\-\-section\-start\ "\c
127.I sectionname\c
128\&=\c
129.I sectionorg\c
130\&\|]
252b5132
RH
131.RB "[\|" "\-Ttext\ "\c
132.I textorg\c
133\&\|]
134.RB "[\|" "\-Tdata\ "\c
135.I dataorg\c
136\&\|]
137.RB "[\|" "\-Tbss\ "\c
138.I bssorg\c
139\&\|]
140.RB "[\|" \-t "\|]"
141.RB "[\|" "\-u\ "\c
142.I sym\c
143\&]
144.RB "[\|" \-V "\|]"
145.RB "[\|" \-v "\|]"
146.RB "[\|" \-\-verbose "\|]"
147.RB "[\|" \-\-version "\|]"
148.RB "[\|" \-warn\-common "\|]"
149.RB "[\|" \-warn\-constructors "\|]"
150.RB "[\|" \-warn\-multiple\-gp "\|]"
151.RB "[\|" \-warn\-once "\|]"
152.RB "[\|" \-warn\-section\-align "\|]"
153.RB "[\|" \-\-whole\-archive "\|]"
154.RB "[\|" \-\-no\-whole\-archive "\|]"
155.RB "[\|" "\-\-wrap\ "\c
156.I symbol\c
157\&\|]
158.RB "[\|" \-X "\|]"
159.RB "[\|" \-x "\|]"
160.ad b
161.hy 1
162.SH DESCRIPTION
163\c
164.B ld\c
165\& combines a number of object and archive files, relocates
166their data and ties up symbol references. Often the last step in
167building a new compiled program to run is a call to \c
168.B ld\c
169\&.
170
171\c
172.B ld\c
173\& accepts Linker Command Language files
174to provide explicit and total control over the linking process.
175This man page does not describe the command language; see the `\|\c
176.B ld\c
177\|' entry in `\|\c
178.B info\c
179\|', or the manual
180.I
181ld: the GNU linker
182\&, for full details on the command language and on other aspects of
183the GNU linker.
184
185This version of \c
186.B ld\c
187\& uses the general purpose BFD libraries
188to operate on object files. This allows \c
189.B ld\c
190\& to read, combine, and
191write object files in many different formats\(em\&for example, COFF or
192\c
193.B a.out\c
194\&. Different formats may be linked together to produce any
195available kind of object file. You can use `\|\c
196.B objdump \-i\c
197\|' to get a list of formats supported on various architectures; see
198.BR objdump ( 1 ).
199
200Aside from its flexibility, the GNU linker is more helpful than other
201linkers in providing diagnostic information. Many linkers abandon
202execution immediately upon encountering an error; whenever possible,
203\c
204.B ld\c
205\& continues executing, allowing you to identify other errors
206(or, in some cases, to get an output file in spite of the error).
207
208The GNU linker \c
209.B ld\c
210\& is meant to cover a broad range of situations,
211and to be as compatible as possible with other linkers. As a result,
212you have many choices to control its behavior through the command line,
213and through environment variables.
214
215.SH OPTIONS
216The plethora of command-line options may seem intimidating, but in
217actual practice few of them are used in any particular context.
218For instance, a frequent use of \c
219.B ld\c
220\& is to link standard Unix
221object files on a standard, supported Unix system. On such a system, to
222link a file \c
223.B hello.o\c
224\&:
225.sp
226.br
227$\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
228.br
229.sp
230This tells \c
231.B ld\c
232\& to produce a file called \c
233.B output\c
234\& as the
235result of linking the file \c
236.B /lib/crt0.o\c
237\& with \c
238.B hello.o\c
239\& and
240the library \c
241.B libc.a\c
242\& which will come from the standard search
243directories.
244
245The command-line options to \c
246.B ld\c
247\& may be specified in any order, and
248may be repeated at will. For the most part, repeating an option with a
249different argument will either have no further effect, or override prior
250occurrences (those further to the left on the command line) of an
251option.
252
253The exceptions\(em\&which may meaningfully be used more than once\(em\&are
254\c
255.B \-A\c
256\&, \c
257.B \-b\c
258\& (or its synonym \c
259.B \-format\c
260\&), \c
261.B \-defsym\c
176355da
NC
262\&, \c
263.B \-\-section\-start\c
264\&, \c
252b5132
RH
265.B \-L\c
266\&, \c
267.B \-l\c
268\&, \c
269.B \-R\c
270\&, and \c
271.B \-u\c
272\&.
273
274The list of object files to be linked together, shown as \c
275.I objfile\c
276\&,
277may follow, precede, or be mixed in with command-line options; save that
278an \c
279.I objfile\c
280\& argument may not be placed between an option flag and
281its argument.
282
283Usually the linker is invoked with at least one object file, but other
284forms of binary input files can also be specified with \c
285.B \-l\c
286\&,
287\c
288.B \-R\c
289\&, and the script command language. If \c
290.I no\c
291\& binary input
292files at all are specified, the linker does not produce any output, and
293issues the message `\|\c
294.B No input files\c
295\|'.
296
297Option arguments must either follow the option letter without intervening
298whitespace, or be given as separate arguments immediately following the
299option that requires them.
300
301.TP
302.BI "-A" "architecture"
303In the current release of \c
304.B ld\c
305\&, this option is useful only for the
306Intel 960 family of architectures. In that \c
307.B ld\c
308\& configuration, the
309\c
310.I architecture\c
311\& argument is one of the two-letter names identifying
312members of the 960 family; the option specifies the desired output
313target, and warns of any incompatible instructions in the input files.
314It also modifies the linker's search strategy for archive libraries, to
315support the use of libraries specific to each particular
316architecture, by including in the search loop names suffixed with the
317string identifying the architecture.
318
319For example, if your \c
320.B ld\c
321\& command line included `\|\c
322.B \-ACA\c
323\|' as
324well as `\|\c
325.B \-ltry\c
326\|', the linker would look (in its built-in search
327paths, and in any paths you specify with \c
328.B \-L\c
329\&) for a library with
330the names
331.sp
332.br
333try
334.br
335libtry.a
336.br
337tryca
338.br
339libtryca.a
340.br
341.sp
342
343The first two possibilities would be considered in any event; the last
344two are due to the use of `\|\c
345.B \-ACA\c
346\|'.
347
348Future releases of \c
349.B ld\c
350\& may support similar functionality for
351other architecture families.
352
353You can meaningfully use \c
354.B \-A\c
355\& more than once on a command line, if
356an architecture family allows combination of target architectures; each
357use will add another pair of name variants to search for when \c
358.B \-l
359specifies a library.
360
361.TP
362.BI "\-b " "input-format"
363Specify the binary format for input object files that follow this option
364on the command line. You don't usually need to specify this, as
365\c
366.B ld\c
367\& is configured to expect as a default input format the most
368usual format on each machine. \c
369.I input-format\c
370\& is a text string, the
371name of a particular format supported by the BFD libraries.
372\c
373.B \-format \c
374.I input-format\c
375\&\c
376\& has the same effect, as does the script command
377.BR TARGET .
378
379You may want to use this option if you are linking files with an unusual
380binary format. You can also use \c
381.B \-b\c
382\& to switch formats explicitly (when
383linking object files of different formats), by including
384\c
385.B \-b \c
386.I input-format\c
387\&\c
388\& before each group of object files in a
389particular format.
390
391The default format is taken from the environment variable
392.B GNUTARGET\c
393\&. You can also define the input
394format from a script, using the command \c
395.B TARGET\c
396\&.
397
398.TP
399.B \-Bstatic
400Do not link against shared libraries. This is only meaningful on
401platforms for which shared libraries are supported.
402
403.TP
404.B \-Bdynamic
405Link against dynamic libraries. This is only meaningful on platforms
406for which shared libraries are supported. This option is normally the
407default on such platforms.
408
409.TP
410.B \-Bsymbolic
411When creating a shared library, bind references to global symbols to
412the definition within the shared library, if any. Normally, it is
413possible for a program linked against a shared library to override the
414definition within the shared library. This option is only meaningful
415on ELF platforms which support shared libraries.
416
417.TP
418.BI "\-c " "commandfile"
419Directs \c
420.B ld\c
421\& to read link commands from the file
422\c
423.I commandfile\c
424\&. These commands will completely override \c
425.B ld\c
426\&'s
427default link format (rather than adding to it); \c
428.I commandfile\c
429\& must
430specify everything necessary to describe the target format.
431
432
433You may also include a script of link commands directly in the command
434line by bracketing it between `\|\c
435.B {\c
436\|' and `\|\c
437.B }\c
438\|' characters.
439
440.TP
441.B \-\-cref
442Output a cross reference table. If a linker map file is being
443generated, the cross reference table is printed to the map file.
444Otherwise, it is printed on the standard output.
445
446.TP
447.B \-d
448.TP
449.B \-dc
450.TP
451.B \-dp
452These three options are equivalent; multiple forms are supported for
453compatibility with other linkers. Use any of them to make \c
454.B ld
455assign space to common symbols even if a relocatable output file is
456specified (\c
457.B \-r\c
458\&). The script command
459\c
460.B FORCE_COMMON_ALLOCATION\c
461\& has the same effect.
462
463.TP
176355da 464.BI "-defsym " "symbol" "\fR=\fP" expression
252b5132
RH
465Create a global symbol in the output file, containing the absolute
466address given by \c
467.I expression\c
468\&. You may use this option as many
469times as necessary to define multiple symbols in the command line. A
470limited form of arithmetic is supported for the \c
471.I expression\c
472\& in this
473context: you may give a hexadecimal constant or the name of an existing
474symbol, or use \c
475.B +\c
476\& and \c
477.B \-\c
478\& to add or subtract hexadecimal
479constants or symbols. If you need more elaborate expressions, consider
480using the linker command language from a script.
481
482.TP
483.B \-\-demangle
484.TP
485.B \-\-no\-demangle
486These options control whether to demangle symbol names in error
487messages and other output. When the linker is told to demangle, it
488tries to present symbol names in a readable fashion: it strips leading
489underscores if they are used by the object file format, and converts
490C++ mangled symbol names into user readable names. The linker will
491demangle by default unless the environment variable
492.B COLLECT_NO_DEMANGLE
493is set. These options may be used to override the default.
494
495.TP
496.BI "-e " "entry"\c
497\&
498Use \c
499.I entry\c
500\& as the explicit symbol for beginning execution of your
501program, rather than the default entry point. See the `\|\c
502.B ld\c
503\|' entry in `\|\c
504.B info\c
505\|' for a
506discussion of defaults and other ways of specifying the
507entry point.
508
509.TP
510.B \-embedded\-relocs
511This option is only meaningful when linking MIPS embedded PIC code,
512generated by the
513.B \-membedded\-pic
514option to the GNU compiler and assembler. It causes the linker to
515create a table which may be used at runtime to relocate any data which
516was statically initialized to pointer values. See the code in
517testsuite/ld-empic for details.
518
519.TP
520.B \-E
521.TP
522.B \-export\-dynamic
523When creating an ELF file, add all symbols to the dynamic symbol table.
524Normally, the dynamic symbol table contains only symbols which are used
525by a dynamic object. This option is needed for some uses of
526.I dlopen.
527
528.TP
529.BI "-f " "name"
530.TP
531.BI "--auxiliary " "name"
532When creating an ELF shared object, set the internal DT_AUXILIARY field
533to the specified name. This tells the dynamic linker that the symbol
534table of the shared object should be used as an auxiliary filter on the
535symbol table of the shared object
536.I name.
537
538.TP
539.BI "-F " "name"
540.TP
541.BI "--filter " "name"
542When creating an ELF shared object, set the internal DT_FILTER field to
543the specified name. This tells the dynamic linker that the symbol table
544of the shared object should be used as a filter on the symbol table of
545the shared object
546.I name.
547
548.TP
549.BI "\-format " "input\-format"
550Synonym for \c
551.B \-b\c
552\& \c
553.I input\-format\c
554\&.
555
556.TP
557.B \-g
558Accepted, but ignored; provided for compatibility with other tools.
559
560.TP
561.BI "\-G " "size"\c
562Set the maximum size of objects to be optimized using the GP register
563to
564.I size
565under MIPS ECOFF. Ignored for other object file formats.
566
567.TP
568.BI "-h " "name"
569.TP
570.BI "-soname " "name"
571When creating an ELF shared object, set the internal DT_SONAME field to
572the specified name. When an executable is linked with a shared object
573which has a DT_SONAME field, then when the executable is run the dynamic
574linker will attempt to load the shared object specified by the DT_SONAME
575field rather than the using the file name given to the linker.
576
577.TP
578.B \-\-help
579Print a summary of the command-line options on the standard output and exit.
580This option and
581.B \-\-version
582begin with two dashes instead of one
583for compatibility with other GNU programs. The other options start with
584only one dash for compatibility with other linkers.
585
586.TP
587.B \-i
588Perform an incremental link (same as option \c
589.B \-r\c
590\&).
591
592.TP
593.BI "\-l" "ar"\c
594\&
595Add an archive file \c
596.I ar\c
597\& to the list of files to link. This
598option may be used any number of times. \c
599.B ld\c
600\& will search its
601path-list for occurrences of \c
602.B lib\c
603.I ar\c
604\&.a\c
605\& for every \c
606.I ar
607specified.
608
609.TP
610.BI "\-L" "searchdir"
611This command adds path \c
612.I searchdir\c
613\& to the list of paths that
614\c
615.B ld\c
616\& will search for archive libraries. You may use this option
617any number of times.
618
619The default set of paths searched (without being specified with
620\c
621.B \-L\c
622\&) depends on what emulation mode \c
623.B ld\c
624\& is using, and in
625some cases also on how it was configured. The
626paths can also be specified in a link script with the \c
627.B SEARCH_DIR
628command.
629
630.TP
631.B \-M
632Print (to the standard output file) a link map\(em\&diagnostic information
633about where symbols are mapped by \c
634.B ld\c
635\&, and information on global
636common storage allocation.
637
638.TP
639.BI "\-Map " "mapfile"\c
640Print to the file
641.I mapfile
642a link map\(em\&diagnostic information
643about where symbols are mapped by \c
644.B ld\c
645\&, and information on global
646common storage allocation.
647
648.TP
649.BI "\-m " "emulation"\c
650Emulate the
651.I emulation
652linker. You can list the available emulations with the
653.I \-\-verbose
654or
655.I \-V
656options. This option overrides the compiled-in default, which is the
657system for which you configured
658.BR ld .
659
660.TP
661.B \-N
662specifies readable and writable \c
663.B text\c
664\& and \c
665.B data\c
666\& sections. If
667the output format supports Unix style magic numbers, the output is
668marked as \c
669.B OMAGIC\c
670\&.
671
672When you use the `\|\c
673.B \-N\c
674\&\|' option, the linker does not page-align the
675data segment.
676
677.TP
678.B \-n
679sets the text segment to be read only, and \c
680.B NMAGIC\c
681\& is written
682if possible.
683
684.TP
685.B \-noinhibit\-exec
686Normally, the linker will not produce an output file if it encounters
687errors during the link process. With this flag, you can specify that
688you wish the output file retained even after non-fatal errors.
689
690.TP
691.B \-no\-keep\-memory
692The linker normally optimizes for speed over memory usage by caching
693the symbol tables of input files in memory. This option tells the
694linker to instead optimize for memory usage, by rereading the symbol
695tables as necessary. This may be required if the linker runs out of
696memory space while linking a large executable.
697
698.TP
699.B \-no\-warn\-mismatch
700Normally the linker will give an error if you try to link together
701input files that are mismatched for some reason, perhaps because they
702have been compiled for different processors or for different
703endiannesses. This option tells the linker that it should silently
704permit such possible errors. This option should only be used with
705care, in cases when you have taken some special action that ensures
706that the linker errors are inappropriate.
707
708.TP
709.BI "\-o " "output"
710.I output\c
711\& is a name for the program produced by \c
712.B ld\c
713\&; if this
714option is not specified, the name `\|\c
715.B a.out\c
716\|' is used by default. The
717script command \c
718.B OUTPUT\c
719\& can also specify the output file name.
720
721.TP
722.BI "\-O" "level"
723Generate optimized output files. This might use significantly more
724time and therefore probably should be enabled only for generating the
725final binary.
726\c
727.I level\c
728\& is supposed to be a numeric value. Any value greater than zero enables
729the optimizations.
730
731.TP
0088edd2 732.BI "\--oformat " "output\-format"
252b5132
RH
733Specify the binary format for the output object file.
734You don't usually need to specify this, as
735\c
736.B ld\c
737\& is configured to produce as a default output format the most
738usual format on each machine. \c
739.I output-format\c
740\& is a text string, the
741name of a particular format supported by the BFD libraries.
742The script command
743.B OUTPUT_FORMAT
744can also specify the output format, but this option overrides it.
745
746.TP
747.BI "\-R " "filename"
748Read symbol names and their addresses from \c
749.I filename\c
750\&, but do not
751relocate it or include it in the output. This allows your output file
752to refer symbolically to absolute locations of memory defined in other
753programs.
754
755.TP
756.B \-relax
757An option with machine dependent effects. Currently this option is only
758supported on the H8/300.
759
760On some platforms, use this option to perform global optimizations that
761become possible when the linker resolves addressing in your program, such
762as relaxing address modes and synthesizing new instructions in the
763output object file.
764
765On platforms where this is not supported, `\|\c
766.B \-relax\c
767\&\|' is accepted, but has no effect.
768
769.TP
770.B \-r
771Generates relocatable output\(em\&i.e., generate an output file that can in
772turn serve as input to \c
773.B ld\c
774\&. This is often called \c
775.I partial
776linking\c
777\&. As a side effect, in environments that support standard Unix
778magic numbers, this option also sets the output file's magic number to
779\c
780.B OMAGIC\c
781\&.
782If this option is not specified, an absolute file is produced. When
783linking C++ programs, this option \c
784.I will not\c
785\& resolve references to
786constructors; \c
787.B \-Ur\c
788\& is an alternative.
789
790This option does the same as \c
791.B \-i\c
792\&.
793
794.TP
795.B \-rpath\ \fIdirectory
796Add a directory to the runtime library search path. This is used when
797linking an ELF executable with shared objects. All
798.B \-rpath
799arguments are concatenated and passed to the runtime linker, which uses
800them to locate shared objects at runtime. The
801.B \-rpath
802option is also used when locating shared objects which are needed by
803shared objects explicitly included in the link; see the description of
804the
805.B \-rpath\-link
806option. If
807.B \-rpath
808is not used when linking an ELF executable, the contents of the
809environment variable
810.B LD_RUN_PATH
811will be used if it is defined.
812
813The
814.B \-rpath
815option may also be used on SunOS. By default, on SunOS, the linker
816will form a runtime search path out of all the
817.B \-L
818options it is given. If a
819.B \-rpath
820option is used, the runtime search path will be formed exclusively
821using the
822.B \-rpath
823options, ignoring
824the
825.B \-L
826options. This can be useful when using gcc, which adds many
827.B \-L
828options which may be on NFS mounted filesystems.
829
830.TP
831.B \-rpath\-link\ \fIdirectory
832When using ELF or SunOS, one shared library may require another. This
833happens when an
834.B ld\ \-shared
835link includes a shared library as one of the input files.
836
837When the linker encounters such a dependency when doing a non-shared,
838non-relocateable link, it will automatically try to locate the required
839shared library and include it in the link, if it is not included
840explicitly. In such a case, the
841.B \-rpath\-link
842option specifies the first set of directories to search. The
843.B \-rpath\-link
844option may specify a sequence of directory names either by specifying
845a list of names separated by colons, or by appearing multiple times.
846
847If the required shared library is not found, the linker will issue a
848warning and continue with the link.
849
850.TP
851.B \-S
852Omits debugger symbol information (but not all symbols) from the output file.
853
854.TP
855.B \-s
856Omits all symbol information from the output file.
857
858.TP
859.B \-shared
860Create a shared library. This is currently only supported on ELF and
861SunOS platforms (on SunOS it is not required, as the linker will
862automatically create a shared library when there are undefined symbols
863and the
864.B \-e
865option is not used).
866
867.TP
868.B \-sort\-common
869Normally, when
870.B ld
871places the global common symbols in the appropriate output sections,
872it sorts them by size. First come all the one byte symbols, then all
873the two bytes, then all the four bytes, and then everything else.
874This is to prevent gaps between symbols due to
875alignment constraints. This option disables that sorting.
876
877.TP
878.B \-split\-by\-reloc\ \fIcount
879Trys to creates extra sections in the output file so that no single
880output section in the file contains more than
881.I count
882relocations.
883This is useful when generating huge relocatable for downloading into
884certain real time kernels with the COFF object file format; since COFF
885cannot represent more than 65535 relocations in a single section.
886Note that this will fail to work with object file formats which do not
887support arbitrary sections. The linker will not split up individual
888input sections for redistribution, so if a single input section
889contains more than
890.I count
891relocations one output section will contain that many relocations.
892
893.TP
894.B \-split\-by\-file
895Similar to
896.B \-split\-by\-reloc
897but creates a new output section for each input file.
898
176355da
NC
899.TP
900.BI "--section-start " "sectionname" "\fR=\fP"org
901Locate a section in the output file at the absolute
902address given by \c
903.I org\c
904\&. \c
905\c
906.I org\c
907\& must be a hexadecimal integer.
908You may use this option as many
909times as necessary to locate multiple sections in the command
910line. If you need more elaborate expressions, consider
911using the linker command language from a script.
912
252b5132
RH
913.TP
914.BI "\-Tbss " "org"\c
915.TP
916.BI "\-Tdata " "org"\c
917.TP
918.BI "\-Ttext " "org"\c
919Use \c
920.I org\c
921\& as the starting address for\(em\&respectively\(em\&the
922\c
923.B bss\c
924\&, \c
925.B data\c
926\&, or the \c
927.B text\c
928\& segment of the output file.
929\c
930.I org\c
931\& must be a hexadecimal integer.
932
933.TP
934.BI "\-T " "commandfile"
935Equivalent to \c
936.B \-c \c
937.I commandfile\c
938\&\c
939\&; supported for compatibility with
940other tools.
941
942.TP
943.B \-t
944Prints names of input files as \c
945.B ld\c
946\& processes them.
947
948.TP
949.BI "\-u " "sym"
950Forces \c
951.I sym\c
952\& to be entered in the output file as an undefined symbol.
953This may, for example, trigger linking of additional modules from
954standard libraries. \c
955.B \-u\c
956\& may be repeated with different option
957arguments to enter additional undefined symbols.
958
959.TP
960.B \-Ur
961For anything other than C++ programs, this option is equivalent to
962\c
963.B \-r\c
964\&: it generates relocatable output\(em\&i.e., an output file that can in
965turn serve as input to \c
966.B ld\c
967\&. When linking C++ programs, \c
968.B \-Ur
969.I will\c
970\& resolve references to constructors, unlike \c
971.B \-r\c
972\&.
973
974.TP
975.B \-\-verbose
976Display the version number for \c
977.B ld
978and list the supported emulations.
979Display which input files can and can not be opened.
980
981.TP
982.B \-v, \-V
983Display the version number for \c
984.B ld\c
985\&.
986The
987.B \-V
988option also lists the supported emulations.
989
990.TP
991.B \-\-version
992Display the version number for \c
993.B ld
994and exit.
995
996.TP
997.B \-warn\-common
998Warn when a common symbol is combined with another common symbol or with
999a symbol definition. Unix linkers allow this somewhat sloppy practice,
1000but linkers on some other operating systems do not. This option allows
1001you to find potential problems from combining global symbols.
1002
1003.TP
1004.B \-warn\-constructors
1005Warn if any global constructors are used. This is only useful for a
1006few object file formats. For formats like COFF or ELF, the linker can
1007not detect the use of global constructors.
1008
1009.TP
1010.B \-warn\-multiple\-gp
1011Warn if the output file requires multiple global-pointer values. This
1012option is only meaningful for certain processors, such as the Alpha.
1013
1014.TP
1015.B \-warn\-once
1016Only warn once for each undefined symbol, rather than once per module
1017which refers to it.
1018
1019.TP
1020.B \-warn\-section\-align
1021Warn if the address of an output section is changed because of
1022alignment. Typically, the alignment will be set by an input section.
1023The address will only be changed if it not explicitly specified; that
1024is, if the SECTIONS command does not specify a start address for the
1025section.
1026
1027.TP
1028.B \-\-whole\-archive
1029For each archive mentioned on the command line after the
1030.B \-\-whole\-archive
1031option, include every object file in the archive in the link, rather
1032than searching the archive for the required object files. This is
1033normally used to turn an archive file into a shared library, forcing
1034every object to be included in the resulting shared library.
1035
1036.TP
1037.B \-\-no\-whole\-archive
1038Turn off the effect of the
1039.B \-\-whole\-archive
1040option for archives which appear later on the command line.
1041
1042.TP
1043.BI "--wrap " "symbol"
1044Use a wrapper function for
1045.I symbol.
1046Any undefined reference to
1047.I symbol
1048will be resolved to
1049.BI "__wrap_" "symbol".
1050Any undefined reference to
1051.BI "__real_" "symbol"
1052will be resolved to
1053.I symbol.
1054
1055.TP
1056.B \-X
1057Delete all temporary local symbols. For most targets, this is all local
1058symbols whose names begin with `\|\c
1059.B L\c
1060\|'.
1061
1062.TP
1063.B \-x
1064Delete all local symbols.
1065
1066.PP
1067
1068.SH ENVIRONMENT
1069\c
1070You can change the behavior of
1071.B ld\c
1072\& with the environment variable \c
1073.B GNUTARGET\c
1074\&.
1075
1076\c
1077.B GNUTARGET\c
1078\& determines the input-file object format if you don't
1079use \c
1080.B \-b\c
1081\& (or its synonym \c
1082.B \-format\c
1083\&). Its value should be one
1084of the BFD names for an input format. If there is no
1085\c
1086.B GNUTARGET\c
1087\& in the environment, \c
1088.B ld\c
1089\& uses the natural format
1090of the host. If \c
1091.B GNUTARGET\c
1092\& is set to \c
1093.B default\c
1094\& then BFD attempts to discover the
1095input format by examining binary input files; this method often
1096succeeds, but there are potential ambiguities, since there is no method
1097of ensuring that the magic number used to flag object-file formats is
1098unique. However, the configuration procedure for BFD on each system
1099places the conventional format for that system first in the search-list,
1100so ambiguities are resolved in favor of convention.
1101
1102.PP
1103
1104.SH "SEE ALSO"
1105
1106.BR objdump ( 1 )
1107.br
1108.br
1109.RB "`\|" ld "\|' and `\|" binutils "\|'"
1110entries in
1111.B info\c
1112.br
1113.I
1114ld: the GNU linker\c
1115, Steve Chamberlain and Roland Pesch;
1116.I
1117The GNU Binary Utilities\c
1118, Roland H. Pesch.
1119
1120.SH COPYING
cf055d54
NC
1121Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 1998, 2000 Free Software Foundation, Inc.
1122.PP
1123This document is distributed under the terms of the GNU Free
e47b9e39
NC
1124Documentation License, version 1.1. That license is described in the
1125sources for this manual page, but it is not displayed here in order to
1126make this manual more consise. Copies of this license can also be
1127obtained from: http://www.gnu.org/copyleft/.
cf055d54 1128
e47b9e39
NC
1129\" .SH GNU Free Documentation License
1130\" Version 1.1, March 2000
cf055d54 1131
e47b9e39
NC
1132\" Copyright (C) 2000 Free Software Foundation, Inc.
1133\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
cf055d54 1134
e47b9e39
NC
1135\" Everyone is permitted to copy and distribute verbatim
1136\" copies of this license document, but changing it is
1137\" not allowed.
1138\" .PP
1139\" 0. PREAMBLE
1140\" .PP
1141\" The purpose of this License is to make a manual, textbook, or other
1142\" written document "free" in the sense of freedom: to assure everyone
1143\" the effective freedom to copy and redistribute it, with or without
1144\" modifying it, either commercially or noncommercially. Secondarily,
1145\" this License preserves for the author and publisher a way to get
1146\" credit for their work, while not being considered responsible for
1147\" modifications made by others.
1148\" .PP
1149\" This License is a kind of "copyleft", which means that derivative
1150\" works of the document must themselves be free in the same sense. It
1151\" complements the GNU General Public License, which is a copyleft
1152\" license designed for free software.
1153\" .PP
1154\" We have designed this License in order to use it for manuals for free
1155\" software, because free software needs free documentation: a free
1156\" program should come with manuals providing the same freedoms that the
1157\" software does. But this License is not limited to software manuals;
1158\" it can be used for any textual work, regardless of subject matter or
1159\" whether it is published as a printed book. We recommend this License
1160\" principally for works whose purpose is instruction or reference.
1161\" .PP
1162\" 1. APPLICABILITY AND DEFINITIONS
1163\" .PP
1164\" This License applies to any manual or other work that contains a
1165\" notice placed by the copyright holder saying it can be distributed
1166\" under the terms of this License. The "Document", below, refers to any
1167\" such manual or work. Any member of the public is a licensee, and is
1168\" addressed as "you".
1169\" .PP
1170\" A "Modified Version" of the Document means any work containing the
1171\" Document or a portion of it, either copied verbatim, or with
1172\" modifications and/or translated into another language.
1173\" .PP
1174\" A "Secondary Section" is a named appendix or a front-matter section of
1175\" the Document that deals exclusively with the relationship of the
1176\" publishers or authors of the Document to the Document's overall subject
1177\" (or to related matters) and contains nothing that could fall directly
1178\" within that overall subject. (For example, if the Document is in part a
1179\" textbook of mathematics, a Secondary Section may not explain any
1180\" mathematics.) The relationship could be a matter of historical
1181\" connection with the subject or with related matters, or of legal,
1182\" commercial, philosophical, ethical or political position regarding
1183\" them.
1184\" .PP
1185\" The "Invariant Sections" are certain Secondary Sections whose titles
1186\" are designated, as being those of Invariant Sections, in the notice
1187\" that says that the Document is released under this License.
1188\" .PP
1189\" The "Cover Texts" are certain short passages of text that are listed,
1190\" as Front-Cover Texts or Back-Cover Texts, in the notice that says that
1191\" the Document is released under this License.
1192\" .PP
1193\" A "Transparent" copy of the Document means a machine-readable copy,
1194\" represented in a format whose specification is available to the
1195\" general public, whose contents can be viewed and edited directly and
1196\" straightforwardly with generic text editors or (for images composed of
1197\" pixels) generic paint programs or (for drawings) some widely available
1198\" drawing editor, and that is suitable for input to text formatters or
1199\" for automatic translation to a variety of formats suitable for input
1200\" to text formatters. A copy made in an otherwise Transparent file
1201\" format whose markup has been designed to thwart or discourage
1202\" subsequent modification by readers is not Transparent. A copy that is
1203\" not "Transparent" is called "Opaque".
1204\" .PP
1205\" Examples of suitable formats for Transparent copies include plain
1206\" ASCII without markup, Texinfo input format, LaTeX input format, SGML
1207\" or XML using a publicly available DTD, and standard-conforming simple
1208\" HTML designed for human modification. Opaque formats include
1209\" PostScript, PDF, proprietary formats that can be read and edited only
1210\" by proprietary word processors, SGML or XML for which the DTD and/or
1211\" processing tools are not generally available, and the
1212\" machine-generated HTML produced by some word processors for output
1213\" purposes only.
1214\" .PP
1215\" The "Title Page" means, for a printed book, the title page itself,
1216\" plus such following pages as are needed to hold, legibly, the material
1217\" this License requires to appear in the title page. For works in
1218\" formats which do not have any title page as such, "Title Page" means
1219\" the text near the most prominent appearance of the work's title,
1220\" preceding the beginning of the body of the text.
1221\" .PP
1222\" 2. VERBATIM COPYING
1223\" .PP
1224\" You may copy and distribute the Document in any medium, either
1225\" commercially or noncommercially, provided that this License, the
1226\" copyright notices, and the license notice saying this License applies
1227\" to the Document are reproduced in all copies, and that you add no other
1228\" conditions whatsoever to those of this License. You may not use
1229\" technical measures to obstruct or control the reading or further
1230\" copying of the copies you make or distribute. However, you may accept
1231\" compensation in exchange for copies. If you distribute a large enough
1232\" number of copies you must also follow the conditions in section 3.
1233\" .PP
1234\" You may also lend copies, under the same conditions stated above, and
1235\" you may publicly display copies.
1236\" .PP
1237\" 3. COPYING IN QUANTITY
1238\" .PP
1239\" If you publish printed copies of the Document numbering more than 100,
1240\" and the Document's license notice requires Cover Texts, you must enclose
1241\" the copies in covers that carry, clearly and legibly, all these Cover
1242\" Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
1243\" the back cover. Both covers must also clearly and legibly identify
1244\" you as the publisher of these copies. The front cover must present
1245\" the full title with all words of the title equally prominent and
1246\" visible. You may add other material on the covers in addition.
1247\" Copying with changes limited to the covers, as long as they preserve
1248\" the title of the Document and satisfy these conditions, can be treated
1249\" as verbatim copying in other respects.
1250\" .PP
1251\" If the required texts for either cover are too voluminous to fit
1252\" legibly, you should put the first ones listed (as many as fit
1253\" reasonably) on the actual cover, and continue the rest onto adjacent
1254\" pages.
1255\" .PP
1256\" If you publish or distribute Opaque copies of the Document numbering
1257\" more than 100, you must either include a machine-readable Transparent
1258\" copy along with each Opaque copy, or state in or with each Opaque copy
1259\" a publicly-accessible computer-network location containing a complete
1260\" Transparent copy of the Document, free of added material, which the
1261\" general network-using public has access to download anonymously at no
1262\" charge using public-standard network protocols. If you use the latter
1263\" option, you must take reasonably prudent steps, when you begin
1264\" distribution of Opaque copies in quantity, to ensure that this
1265\" Transparent copy will remain thus accessible at the stated location
1266\" until at least one year after the last time you distribute an Opaque
1267\" copy (directly or through your agents or retailers) of that edition to
1268\" the public.
1269\" .PP
1270\" It is requested, but not required, that you contact the authors of the
1271\" Document well before redistributing any large number of copies, to give
1272\" them a chance to provide you with an updated version of the Document.
1273\" .PP
1274\" 4. MODIFICATIONS
1275\" .PP
1276\" You may copy and distribute a Modified Version of the Document under
1277\" the conditions of sections 2 and 3 above, provided that you release
1278\" the Modified Version under precisely this License, with the Modified
1279\" Version filling the role of the Document, thus licensing distribution
1280\" and modification of the Modified Version to whoever possesses a copy
1281\" of it. In addition, you must do these things in the Modified Version:
1282\" .PP
1283\" A. Use in the Title Page (and on the covers, if any) a title distinct
1284\" from that of the Document, and from those of previous versions
1285\" (which should, if there were any, be listed in the History section
1286\" of the Document). You may use the same title as a previous version
1287\" if the original publisher of that version gives permission.
1288\" .PP
1289\" B. List on the Title Page, as authors, one or more persons or entities
1290\" responsible for authorship of the modifications in the Modified
1291\" Version, together with at least five of the principal authors of the
1292\" Document (all of its principal authors, if it has less than five).
1293\" .PP
1294\" C. State on the Title page the name of the publisher of the
1295\" Modified Version, as the publisher.
1296\" .PP
1297\" D. Preserve all the copyright notices of the Document.
1298\" .PP
1299\" E. Add an appropriate copyright notice for your modifications
1300\" adjacent to the other copyright notices.
1301\" .PP
1302\" F. Include, immediately after the copyright notices, a license notice
1303\" giving the public permission to use the Modified Version under the
1304\" terms of this License, in the form shown in the Addendum below.
1305\" Preserve in that license notice the full lists of Invariant Sections
1306\" and required Cover Texts given in the Document's license notice.
1307\" .PP
1308\" H. Include an unaltered copy of this License.
1309\" .PP
1310\" I. Preserve the section entitled "History", and its title, and add to
1311\" it an item stating at least the title, year, new authors, and
1312\" publisher of the Modified Version as given on the Title Page. If
1313\" there is no section entitled "History" in the Document, create one
1314\" stating the title, year, authors, and publisher of the Document as
1315\" given on its Title Page, then add an item describing the Modified
1316\" Version as stated in the previous sentence.
1317\" .PP
1318\" J. Preserve the network location, if any, given in the Document for
1319\" public access to a Transparent copy of the Document, and likewise
1320\" the network locations given in the Document for previous versions
1321\" it was based on. These may be placed in the "History" section.
1322\" You may omit a network location for a work that was published at
1323\" least four years before the Document itself, or if the original
1324\" publisher of the version it refers to gives permission.
1325\" .PP
1326\" K. In any section entitled "Acknowledgements" or "Dedications",
1327\" preserve the section's title, and preserve in the section all the
1328\" substance and tone of each of the contributor acknowledgements
1329\" and/or dedications given therein.
1330\" .PP
1331\" L. Preserve all the Invariant Sections of the Document,
1332\" unaltered in their text and in their titles. Section numbers
1333\" or the equivalent are not considered part of the section titles.
1334\" .PP
1335\" M. Delete any section entitled "Endorsements". Such a section
1336\" may not be included in the Modified Version.
1337\" .PP
1338\" N. Do not retitle any existing section as "Endorsements"
1339\" or to conflict in title with any Invariant Section.
1340\" .PP
1341\" If the Modified Version includes new front-matter sections or
1342\" appendices that qualify as Secondary Sections and contain no material
1343\" copied from the Document, you may at your option designate some or all
1344\" of these sections as invariant. To do this, add their titles to the
1345\" list of Invariant Sections in the Modified Version's license notice.
1346\" These titles must be distinct from any other section titles.
1347\" .PP
1348\" You may add a section entitled "Endorsements", provided it contains
1349\" nothing but endorsements of your Modified Version by various
1350\" parties--for example, statements of peer review or that the text has
1351\" been approved by an organization as the authoritative definition of a
1352\" standard.
1353\" .PP
1354\" You may add a passage of up to five words as a Front-Cover Text, and a
1355\" passage of up to 25 words as a Back-Cover Text, to the end of the list
1356\" of Cover Texts in the Modified Version. Only one passage of
1357\" Front-Cover Text and one of Back-Cover Text may be added by (or
1358\" through arrangements made by) any one entity. If the Document already
1359\" includes a cover text for the same cover, previously added by you or
1360\" by arrangement made by the same entity you are acting on behalf of,
1361\" you may not add another; but you may replace the old one, on explicit
1362\" permission from the previous publisher that added the old one.
1363\" .PP
1364\" The author(s) and publisher(s) of the Document do not by this License
1365\" give permission to use their names for publicity for or to assert or
1366\" imply endorsement of any Modified Version.
1367\" .PP
1368
1369\" 5. COMBINING DOCUMENTS
1370\" .PP
1371\" You may combine the Document with other documents released under this
1372\" License, under the terms defined in section 4 above for modified
1373\" versions, provided that you include in the combination all of the
1374\" Invariant Sections of all of the original documents, unmodified, and
1375\" list them all as Invariant Sections of your combined work in its
1376\" license notice.
1377\" .PP
1378\" The combined work need only contain one copy of this License, and
1379\" multiple identical Invariant Sections may be replaced with a single
1380\" copy. If there are multiple Invariant Sections with the same name but
1381\" different contents, make the title of each such section unique by
1382\" adding at the end of it, in parentheses, the name of the original
1383\" author or publisher of that section if known, or else a unique number.
1384\" Make the same adjustment to the section titles in the list of
1385\" Invariant Sections in the license notice of the combined work.
1386\" .PP
1387\" In the combination, you must combine any sections entitled "History"
1388\" in the various original documents, forming one section entitled
1389\" "History"; likewise combine any sections entitled "Acknowledgements",
1390\" and any sections entitled "Dedications". You must delete all sections
1391\" entitled "Endorsements."
1392\" .PP
1393
1394\" 6. COLLECTIONS OF DOCUMENTS
1395\" .PP
1396\" You may make a collection consisting of the Document and other documents
1397\" released under this License, and replace the individual copies of this
1398\" License in the various documents with a single copy that is included in
1399\" the collection, provided that you follow the rules of this License for
1400\" verbatim copying of each of the documents in all other respects.
1401\" .PP
1402\" You may extract a single document from such a collection, and distribute
1403\" it individually under this License, provided you insert a copy of this
1404\" License into the extracted document, and follow this License in all
1405\" other respects regarding verbatim copying of that document.
1406\" .PP
1407
1408\" 7. AGGREGATION WITH INDEPENDENT WORKS
1409\" .PP
1410\" A compilation of the Document or its derivatives with other separate
1411\" and independent documents or works, in or on a volume of a storage or
1412\" distribution medium, does not as a whole count as a Modified Version
1413\" of the Document, provided no compilation copyright is claimed for the
1414\" compilation. Such a compilation is called an "aggregate", and this
1415\" License does not apply to the other self-contained works thus compiled
1416\" with the Document, on account of their being thus compiled, if they
1417\" are not themselves derivative works of the Document.
1418\" .PP
1419\" If the Cover Text requirement of section 3 is applicable to these
1420\" copies of the Document, then if the Document is less than one quarter
1421\" of the entire aggregate, the Document's Cover Texts may be placed on
1422\" covers that surround only the Document within the aggregate.
1423\" Otherwise they must appear on covers around the whole aggregate.
1424\" .PP
1425
1426\" 8. TRANSLATION
1427\" .PP
1428\" Translation is considered a kind of modification, so you may
1429\" distribute translations of the Document under the terms of section 4.
1430\" Replacing Invariant Sections with translations requires special
1431\" permission from their copyright holders, but you may include
1432\" translations of some or all Invariant Sections in addition to the
1433\" original versions of these Invariant Sections. You may include a
1434\" translation of this License provided that you also include the
1435\" original English version of this License. In case of a disagreement
1436\" between the translation and the original English version of this
1437\" License, the original English version will prevail.
1438\" .PP
1439
1440\" 9. TERMINATION
1441\" .PP
1442\" You may not copy, modify, sublicense, or distribute the Document except
1443\" as expressly provided for under this License. Any other attempt to
1444\" copy, modify, sublicense or distribute the Document is void, and will
1445\" automatically terminate your rights under this License. However,
1446\" parties who have received copies, or rights, from you under this
1447\" License will not have their licenses terminated so long as such
1448\" parties remain in full compliance.
1449\" .PP
1450
1451\" 10. FUTURE REVISIONS OF THIS LICENSE
1452\" .PP
1453\" The Free Software Foundation may publish new, revised versions
1454\" of the GNU Free Documentation License from time to time. Such new
1455\" versions will be similar in spirit to the present version, but may
1456\" differ in detail to address new problems or concerns. See
1457\" http://www.gnu.org/copyleft/.
1458\" .PP
1459\" Each version of the License is given a distinguishing version number.
1460\" If the Document specifies that a particular numbered version of this
1461\" License "or any later version" applies to it, you have the option of
1462\" following the terms and conditions either of that specified version or
1463\" of any later version that has been published (not as a draft) by the
1464\" Free Software Foundation. If the Document does not specify a version
1465\" number of this License, you may choose any version ever published (not
1466\" as a draft) by the Free Software Foundation.
1467\" .PP
1468
1469\" ADDENDUM: How to use this License for your documents
1470\" .PP
1471\" To use this License in a document you have written, include a copy of
1472\" the License in the document and put the following copyright and
1473\" license notices just after the title page:
1474\" .PP
1475\" Copyright (c) YEAR YOUR NAME.
1476\" Permission is granted to copy, distribute and/or
1477\" modify this document under the terms of the GNU
1478\" Free Documentation License, Version 1.1 or any later
1479\" version published by the Free Software Foundation;
1480\" with the Invariant Sections being LIST THEIR TITLES,
1481\" with the Front-Cover Texts being LIST, and with the
1482\" Back-Cover Texts being LIST. A copy of the license
1483\" is included in the section entitled "GNU Free
1484\" Documentation License".
1485\" .PP
1486\" If you have no Invariant Sections, write "with no Invariant Sections"
1487\" instead of saying which ones are invariant. If you have no
1488\" Front-Cover Texts, write "no Front-Cover Texts" instead of
1489\" "Front-Cover Texts being LIST"; likewise for Back-Cover Texts.
1490\" .PP
1491\" If your document contains nontrivial examples of program code, we
1492\" recommend releasing these examples in parallel under your choice of
1493\" free software license, such as the GNU General Public License,
1494\" to permit their use in free software.
This page took 0.160849 seconds and 4 git commands to generate.