1 .\" Copyright (c) 1991, 1992 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
3 .TH ld 1 "17 August 1992" "cygnus support" "GNU Development Tools"
30 .RB "[\|" \-Bstatic "\|]"
34 .RB "[\|" \-d | \-dc | \-dp\c
37 .RB "[\|" "\-defsym\ "\c
45 .RB "[\|" \-embedded\-relocs "\|]"
50 .RB "[\|" "\-format\ "\c
57 .RB "[\|" \-\-help "\|]"
72 .RB "[\|" \-n | \-N "\|]"
73 .RB "[\|" \-noinhibit-exec "\|]"
74 .RB "[\|" "\-oformat\ "\c
80 .RB "[\|" \-relax "\|]"
81 .RB "[\|" \-r | \-Ur "\|]"
84 .RB "[\|" \-sort\-common "\|]"
85 .RB "[\|" \-split\-by\-reloc\ "\c
88 .RB "[\|" \-split\-by\-file "\|]"
92 .RB "[\|" "\-Ttext\ "\c
95 .RB "[\|" "\-Tdata\ "\c
98 .RB "[\|" "\-Tbss\ "\c
107 .RB "[\|" \-\-verbose "\|]"
108 .RB "[\|" \-\-version "\|]"
109 .RB "[\|" \-warn\-common "\|]"
110 .RB "[\|" \-warn\-once "\|]"
111 .RB "[\|" \-\-whole\-archive "\|]"
119 \& combines a number of object and archive files, relocates
120 their data and ties up symbol references. Often the last step in
121 building a new compiled program to run is a call to \c
127 \& accepts Linker Command Language files
128 to provide explicit and total control over the linking process.
129 This man page does not describe the command language; see the `\|\c
136 \&, for full details on the command language and on other aspects of
141 \& uses the general purpose BFD libraries
142 to operate on object files. This allows \c
144 \& to read, combine, and
145 write object files in many different formats\(em\&for example, COFF or
148 \&. Different formats may be linked together to produce any
149 available kind of object file. You can use `\|\c
151 \|' to get a list of formats supported on various architectures; see
154 Aside from its flexibility, the GNU linker is more helpful than other
155 linkers in providing diagnostic information. Many linkers abandon
156 execution immediately upon encountering an error; whenever possible,
159 \& continues executing, allowing you to identify other errors
160 (or, in some cases, to get an output file in spite of the error).
164 \& is meant to cover a broad range of situations,
165 and to be as compatible as possible with other linkers. As a result,
166 you have many choices to control its behavior through the command line,
167 and through environment variables.
170 The plethora of command-line options may seem intimidating, but in
171 actual practice few of them are used in any particular context.
172 For instance, a frequent use of \c
174 \& is to link standard Unix
175 object files on a standard, supported Unix system. On such a system, to
181 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
186 \& to produce a file called \c
189 result of linking the file \c
196 \& which will come from the standard search
199 The command-line options to \c
201 \& may be specified in any order, and
202 may be repeated at will. For the most part, repeating an option with a
203 different argument will either have no further effect, or override prior
204 occurrences (those further to the left on the command line) of an
207 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
212 \& (or its synonym \c
227 The list of object files to be linked together, shown as \c
230 may follow, precede, or be mixed in with command-line options; save that
233 \& argument may not be placed between an option flag and
236 Usually the linker is invoked with at least one object file, but other
237 forms of binary input files can also be specified with \c
242 \&, and the script command language. If \c
245 files at all are specified, the linker does not produce any output, and
246 issues the message `\|\c
250 Option arguments must either follow the option letter without intervening
251 whitespace, or be given as separate arguments immediately following the
252 option that requires them.
255 .BI "-A" "architecture"\c
257 In the current release of \c
259 \&, this option is useful only for the
260 Intel 960 family of architectures. In that \c
262 \& configuration, the
265 \& argument is one of the two-letter names identifying
266 members of the 960 family; the option specifies the desired output
267 target, and warns of any incompatible instructions in the input files.
268 It also modifies the linker's search strategy for archive libraries, to
269 support the use of libraries specific to each particular
270 architecture, by including in the search loop names suffixed with the
271 string identifying the architecture.
273 For example, if your \c
275 \& command line included `\|\c
280 \|', the linker would look (in its built-in search
281 paths, and in any paths you specify with \c
283 \&) for a library with
297 The first two possibilities would be considered in any event; the last
298 two are due to the use of `\|\c
302 Future releases of \c
304 \& may support similar functionality for
305 other architecture families.
307 You can meaningfully use \c
309 \& more than once on a command line, if
310 an architecture family allows combination of target architectures; each
311 use will add another pair of name variants to search for when \c
317 .BI "\-b " "input-format"\c
319 Specify the binary format for input object files that follow this option
320 on the command line. You don't usually need to specify this, as
323 \& is configured to expect as a default input format the most
324 usual format on each machine. \c
326 \& is a text string, the
327 name of a particular format supported by the BFD libraries.
332 \& has the same effect, as does the script command
335 You may want to use this option if you are linking files with an unusual
336 binary format. You can also use \c
338 \& to switch formats explicitly (when
339 linking object files of different formats), by including
344 \& before each group of object files in a
347 The default format is taken from the environment variable
349 \&. You can also define the input
350 format from a script, using the command \c
356 This flag is accepted for command-line compatibility with the SunOS linker,
357 but has no effect on \c
362 .BI "\-c " "commandfile"\c
366 \& to read link commands from the file
369 \&. These commands will completely override \c
372 default link format (rather than adding to it); \c
375 specify everything necessary to describe the target format.
378 You may also include a script of link commands directly in the command
379 line by bracketing it between `\|\c
391 These three options are equivalent; multiple forms are supported for
392 compatibility with other linkers. Use any of them to make \c
395 assign space to common symbols even if a relocatable output file is
398 \&). The script command
400 .B FORCE_COMMON_ALLOCATION\c
401 \& has the same effect.
404 .BI "-defsym " "symbol"\c
408 Create a global symbol in the output file, containing the absolute
411 \&. You may use this option as many
412 times as necessary to define multiple symbols in the command line. A
413 limited form of arithmetic is supported for the \c
416 context: you may give a hexadecimal constant or the name of an existing
421 \& to add or subtract hexadecimal
422 constants or symbols. If you need more elaborate expressions, consider
423 using the linker command language from a script.
430 \& as the explicit symbol for beginning execution of your
431 program, rather than the default entry point. for a
432 discussion of defaults and other ways of specifying the
436 .B \-embedded\-relocs
437 This option is only meaningful when linking MIPS embedded PIC code,
440 option to the GNU compiler and assembler. It causes the linker to
441 create a table which may be used at runtime to relocate any data which
442 was statically initialized to pointer values. See the code in
443 testsuite/ld-empic for details.
450 Some older linkers used this option throughout a compilation toolchain
451 for specifying object-file format for both input and output object
454 \&'s mechanisms (the \c
459 for input files, the \c
461 \& command in linker scripts for output
464 \& environment variable) are more flexible, but
465 but it accepts (and ignores) the \c
467 \& option flag for compatibility
468 with scripts written to call the old linker.
471 .BI "\-format " "input\-format"\c
481 Accepted, but ignored; provided for compatibility with other tools.
485 Set the maximum size of objects to be optimized using the GP register
488 under MIPS ECOFF. Ignored for other object file formats.
492 Print a summary of the command-line options on the standard output and exit.
495 begin with two dashes instead of one
496 for compatibility with other GNU programs. The other options start with
497 only one dash for compatibility with other linkers.
501 Perform an incremental link (same as option \c
508 Add an archive file \c
510 \& to the list of files to link. This
511 option may be used any number of times. \c
514 path-list for occurrences of \c
524 .BI "\-L" "searchdir"\c
526 This command adds path \c
528 \& to the list of paths that
531 \& will search for archive libraries. You may use this option
534 The default set of paths searched (without being specified with
537 \&) depends on what emulation mode \c
540 some cases also on how it was configured. The
541 paths can also be specified in a link script with the \c
548 Print (to the standard output file) a link map\(em\&diagnostic information
549 about where symbols are mapped by \c
551 \&, and information on global
552 common storage allocation.
555 .BI "\-Map " "mapfile"\c
558 a link map\(em\&diagnostic information
559 about where symbols are mapped by \c
561 \&, and information on global
562 common storage allocation.
565 .BI "\-m " "emulation"\c
568 linker. You can list the available emulations with the
572 options. This option overrides the compiled-in default, which is the
573 system for which you configured
578 specifies readable and writable \c
583 the output format supports Unix style magic numbers, the output is
588 When you use the `\|\c
590 \&\|' option, the linker does not page-align the
595 sets the text segment to be read only, and \c
602 Normally, the linker will not produce an output file if it encounters
603 errors during the link process. With this flag, you can specify that
604 you wish the output file retained even after non-fatal errors.
607 .BI "\-o " "output"\c
613 \& is a name for the program produced by \c
616 option is not specified, the name `\|\c
618 \|' is used by default. The
621 \& can also specify the output file name.
624 .BI "\-oformat " "output\-format"\c
626 Specify the binary format for the output object file.
627 You don't usually need to specify this, as
630 \& is configured to produce as a default output format the most
631 usual format on each machine. \c
633 \& is a text string, the
634 name of a particular format supported by the BFD libraries.
637 can also specify the output format, but this option overrides it.
640 .BI "\-R " "filename"\c
644 Read symbol names and their addresses from \c
647 relocate it or include it in the output. This allows your output file
648 to refer symbolically to absolute locations of memory defined in other
653 An option with machine dependent effects. Currently this option is only
654 supported on the H8/300.
656 On some platforms, use this option to perform global optimizations that
657 become possible when the linker resolves addressing in your program, such
658 as relaxing address modes and synthesizing new instructions in the
661 On platforms where this is not supported, `\|\c
663 \&\|' is accepted, but has no effect.
667 Generates relocatable output\(em\&i.e., generate an output file that can in
668 turn serve as input to \c
670 \&. This is often called \c
673 \&. As a side effect, in environments that support standard Unix
674 magic numbers, this option also sets the output file's magic number to
678 If this option is not specified, an absolute file is produced. When
679 linking C++ programs, this option \c
681 \& resolve references to
684 \& is an alternative.
686 This option does the same as \c
692 Omits debugger symbol information (but not all symbols) from the output file.
696 Omits all symbol information from the output file.
702 places the global common symbols in the appropriate output sections,
703 it sorts them by size. First come all the one byte symbols, then all
704 the two bytes, then all the four bytes, and then everything else.
705 This is to prevent gaps between symbols due to
706 alignment constraints. This option disables that sorting.
709 .B \-split\-by\-reloc\ \fIcount
710 Trys to creates extra sections in the output file so that no single
711 output section in the file contains more than
714 This is useful when generating huge relocatable for downloading into
715 certain real time kernels with the COFF object file format; since COFF
716 cannot represent more than 65535 relocations in a single section.
717 Note that this will fail to work with object file formats which do not
718 support arbitrary sections. The linker will not split up individual
719 input sections for redistribution, so if a single input section
722 relocations one output section will contain that many relocations.
727 .B \-split\-by\-reloc
728 but creates a new output section for each input file.
731 .BI "\-Tbss " "org"\c
733 .BI "\-Tdata " "org"\c
735 .BI "\-Ttext " "org"\c
738 \& as the starting address for\(em\&respectively\(em\&the
745 \& segment of the output file.
748 \& must be a hexadecimal integer.
751 .BI "\-T " "commandfile"\c
754 .BI "\-T" "commandfile"\c
759 \&; supported for compatibility with
764 Prints names of input files as \c
772 \& to be entered in the output file as an undefined symbol.
773 This may, for example, trigger linking of additional modules from
774 standard libraries. \c
776 \& may be repeated with different option
777 arguments to enter additional undefined symbols.
781 For anything other than C++ programs, this option is equivalent to
784 \&: it generates relocatable output\(em\&i.e., an output file that can in
785 turn serve as input to \c
787 \&. When linking C++ programs, \c
792 \& resolve references to constructors, unlike \c
798 Display the version number for \c
800 and list the supported emulations.
801 Display which input files can and can not be opened.
805 Display the version number for \c
810 option also lists the supported emulations.
814 Display the version number for \c
820 Warn when a common symbol is combined with another common symbol or with
821 a symbol definition. Unix linkers allow this somewhat sloppy practice,
822 but linkers on some other operating systems do not. This option allows
823 you to find potential problems from combining global symbols.
827 Only warn once for each undefined symbol, rather than once per module
831 .B \-\-whole\-archive
832 For each archive mentioned on the command line, include every object
833 file in the archive in the link, rather than searching the archive for
834 the required object files. This is normally used to turn an archive
835 file into a shared library, forcing every object to be included in the
836 resulting shared library.
840 Delete all temporary local symbols. For most targets, this is all local
841 symbols whose names begin with `\|\c
847 Delete all local symbols.
853 You can change the behavior of
855 \& with the environment variable \c
861 \& determines the input-file object format if you don't
864 \& (or its synonym \c
866 \&). Its value should be one
867 of the BFD names for an input format. If there is no
870 \& in the environment, \c
872 \& uses the natural format
877 \& then BFD attempts to discover the
878 input format by examining binary input files; this method often
879 succeeds, but there are potential ambiguities, since there is no method
880 of ensuring that the magic number used to flag object-file formats is
881 unique. However, the configuration procedure for BFD on each system
882 places the conventional format for that system first in the search-list,
883 so ambiguities are resolved in favor of convention.
892 .RB "`\|" ld "\|' and `\|" binutils "\|'"
898 , Steve Chamberlain and Roland Pesch;
900 The GNU Binary Utilities\c
904 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
906 Permission is granted to make and distribute verbatim copies of
907 this manual provided the copyright notice and this permission notice
908 are preserved on all copies.
910 Permission is granted to copy and distribute modified versions of this
911 manual under the conditions for verbatim copying, provided that the
912 entire resulting derived work is distributed under the terms of a
913 permission notice identical to this one.
915 Permission is granted to copy and distribute translations of this
916 manual into another language, under the above conditions for modified
917 versions, except that this permission notice may be included in
918 translations approved by the Free Software Foundation instead of in
919 the original English.