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