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 "[\|" \-no\-keep\-memory "\|]"
75 .RB "[\|" "\-oformat\ "\c
81 .RB "[\|" \-relax "\|]"
82 .RB "[\|" \-r | \-Ur "\|]"
85 .RB "[\|" \-sort\-common "\|]"
86 .RB "[\|" \-split\-by\-reloc\ "\c
89 .RB "[\|" \-split\-by\-file "\|]"
93 .RB "[\|" "\-Ttext\ "\c
96 .RB "[\|" "\-Tdata\ "\c
99 .RB "[\|" "\-Tbss\ "\c
108 .RB "[\|" \-\-verbose "\|]"
109 .RB "[\|" \-\-version "\|]"
110 .RB "[\|" \-warn\-common "\|]"
111 .RB "[\|" \-warn\-once "\|]"
112 .RB "[\|" \-\-whole\-archive "\|]"
120 \& combines a number of object and archive files, relocates
121 their data and ties up symbol references. Often the last step in
122 building a new compiled program to run is a call to \c
128 \& accepts Linker Command Language files
129 to provide explicit and total control over the linking process.
130 This man page does not describe the command language; see the `\|\c
137 \&, for full details on the command language and on other aspects of
142 \& uses the general purpose BFD libraries
143 to operate on object files. This allows \c
145 \& to read, combine, and
146 write object files in many different formats\(em\&for example, COFF or
149 \&. Different formats may be linked together to produce any
150 available kind of object file. You can use `\|\c
152 \|' to get a list of formats supported on various architectures; see
155 Aside from its flexibility, the GNU linker is more helpful than other
156 linkers in providing diagnostic information. Many linkers abandon
157 execution immediately upon encountering an error; whenever possible,
160 \& continues executing, allowing you to identify other errors
161 (or, in some cases, to get an output file in spite of the error).
165 \& is meant to cover a broad range of situations,
166 and to be as compatible as possible with other linkers. As a result,
167 you have many choices to control its behavior through the command line,
168 and through environment variables.
171 The plethora of command-line options may seem intimidating, but in
172 actual practice few of them are used in any particular context.
173 For instance, a frequent use of \c
175 \& is to link standard Unix
176 object files on a standard, supported Unix system. On such a system, to
182 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
187 \& to produce a file called \c
190 result of linking the file \c
197 \& which will come from the standard search
200 The command-line options to \c
202 \& may be specified in any order, and
203 may be repeated at will. For the most part, repeating an option with a
204 different argument will either have no further effect, or override prior
205 occurrences (those further to the left on the command line) of an
208 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
213 \& (or its synonym \c
228 The list of object files to be linked together, shown as \c
231 may follow, precede, or be mixed in with command-line options; save that
234 \& argument may not be placed between an option flag and
237 Usually the linker is invoked with at least one object file, but other
238 forms of binary input files can also be specified with \c
243 \&, and the script command language. If \c
246 files at all are specified, the linker does not produce any output, and
247 issues the message `\|\c
251 Option arguments must either follow the option letter without intervening
252 whitespace, or be given as separate arguments immediately following the
253 option that requires them.
256 .BI "-A" "architecture"\c
258 In the current release of \c
260 \&, this option is useful only for the
261 Intel 960 family of architectures. In that \c
263 \& configuration, the
266 \& argument is one of the two-letter names identifying
267 members of the 960 family; the option specifies the desired output
268 target, and warns of any incompatible instructions in the input files.
269 It also modifies the linker's search strategy for archive libraries, to
270 support the use of libraries specific to each particular
271 architecture, by including in the search loop names suffixed with the
272 string identifying the architecture.
274 For example, if your \c
276 \& command line included `\|\c
281 \|', the linker would look (in its built-in search
282 paths, and in any paths you specify with \c
284 \&) for a library with
298 The first two possibilities would be considered in any event; the last
299 two are due to the use of `\|\c
303 Future releases of \c
305 \& may support similar functionality for
306 other architecture families.
308 You can meaningfully use \c
310 \& more than once on a command line, if
311 an architecture family allows combination of target architectures; each
312 use will add another pair of name variants to search for when \c
318 .BI "\-b " "input-format"\c
320 Specify the binary format for input object files that follow this option
321 on the command line. You don't usually need to specify this, as
324 \& is configured to expect as a default input format the most
325 usual format on each machine. \c
327 \& is a text string, the
328 name of a particular format supported by the BFD libraries.
333 \& has the same effect, as does the script command
336 You may want to use this option if you are linking files with an unusual
337 binary format. You can also use \c
339 \& to switch formats explicitly (when
340 linking object files of different formats), by including
345 \& before each group of object files in a
348 The default format is taken from the environment variable
350 \&. You can also define the input
351 format from a script, using the command \c
357 This flag is accepted for command-line compatibility with the SunOS linker,
358 but has no effect on \c
363 .BI "\-c " "commandfile"\c
367 \& to read link commands from the file
370 \&. These commands will completely override \c
373 default link format (rather than adding to it); \c
376 specify everything necessary to describe the target format.
379 You may also include a script of link commands directly in the command
380 line by bracketing it between `\|\c
392 These three options are equivalent; multiple forms are supported for
393 compatibility with other linkers. Use any of them to make \c
396 assign space to common symbols even if a relocatable output file is
399 \&). The script command
401 .B FORCE_COMMON_ALLOCATION\c
402 \& has the same effect.
405 .BI "-defsym " "symbol"\c
409 Create a global symbol in the output file, containing the absolute
412 \&. You may use this option as many
413 times as necessary to define multiple symbols in the command line. A
414 limited form of arithmetic is supported for the \c
417 context: you may give a hexadecimal constant or the name of an existing
422 \& to add or subtract hexadecimal
423 constants or symbols. If you need more elaborate expressions, consider
424 using the linker command language from a script.
431 \& as the explicit symbol for beginning execution of your
432 program, rather than the default entry point. for a
433 discussion of defaults and other ways of specifying the
437 .B \-embedded\-relocs
438 This option is only meaningful when linking MIPS embedded PIC code,
441 option to the GNU compiler and assembler. It causes the linker to
442 create a table which may be used at runtime to relocate any data which
443 was statically initialized to pointer values. See the code in
444 testsuite/ld-empic for details.
451 Some older linkers used this option throughout a compilation toolchain
452 for specifying object-file format for both input and output object
455 \&'s mechanisms (the \c
460 for input files, the \c
462 \& command in linker scripts for output
465 \& environment variable) are more flexible, but
466 but it accepts (and ignores) the \c
468 \& option flag for compatibility
469 with scripts written to call the old linker.
472 .BI "\-format " "input\-format"\c
482 Accepted, but ignored; provided for compatibility with other tools.
486 Set the maximum size of objects to be optimized using the GP register
489 under MIPS ECOFF. Ignored for other object file formats.
493 Print a summary of the command-line options on the standard output and exit.
496 begin with two dashes instead of one
497 for compatibility with other GNU programs. The other options start with
498 only one dash for compatibility with other linkers.
502 Perform an incremental link (same as option \c
509 Add an archive file \c
511 \& to the list of files to link. This
512 option may be used any number of times. \c
515 path-list for occurrences of \c
525 .BI "\-L" "searchdir"\c
527 This command adds path \c
529 \& to the list of paths that
532 \& will search for archive libraries. You may use this option
535 The default set of paths searched (without being specified with
538 \&) depends on what emulation mode \c
541 some cases also on how it was configured. The
542 paths can also be specified in a link script with the \c
549 Print (to the standard output file) a link map\(em\&diagnostic information
550 about where symbols are mapped by \c
552 \&, and information on global
553 common storage allocation.
556 .BI "\-Map " "mapfile"\c
559 a link map\(em\&diagnostic information
560 about where symbols are mapped by \c
562 \&, and information on global
563 common storage allocation.
566 .BI "\-m " "emulation"\c
569 linker. You can list the available emulations with the
573 options. This option overrides the compiled-in default, which is the
574 system for which you configured
579 specifies readable and writable \c
584 the output format supports Unix style magic numbers, the output is
589 When you use the `\|\c
591 \&\|' option, the linker does not page-align the
596 sets the text segment to be read only, and \c
603 Normally, the linker will not produce an output file if it encounters
604 errors during the link process. With this flag, you can specify that
605 you wish the output file retained even after non-fatal errors.
608 .B \-no\-keep\-memory
609 The linker normally optimizes for speed over memory usage by caching
610 the symbol tables of input files in memory. This option tells the
611 linker to instead optimize for memory usage, by rereading the symbol
612 tables as necessary. This may be required if the linker runs out of
613 memory space while linking a large executable.
616 .BI "\-o " "output"\c
622 \& is a name for the program produced by \c
625 option is not specified, the name `\|\c
627 \|' is used by default. The
630 \& can also specify the output file name.
633 .BI "\-oformat " "output\-format"\c
635 Specify the binary format for the output object file.
636 You don't usually need to specify this, as
639 \& is configured to produce as a default output format the most
640 usual format on each machine. \c
642 \& is a text string, the
643 name of a particular format supported by the BFD libraries.
646 can also specify the output format, but this option overrides it.
649 .BI "\-R " "filename"\c
653 Read symbol names and their addresses from \c
656 relocate it or include it in the output. This allows your output file
657 to refer symbolically to absolute locations of memory defined in other
662 An option with machine dependent effects. Currently this option is only
663 supported on the H8/300.
665 On some platforms, use this option to perform global optimizations that
666 become possible when the linker resolves addressing in your program, such
667 as relaxing address modes and synthesizing new instructions in the
670 On platforms where this is not supported, `\|\c
672 \&\|' is accepted, but has no effect.
676 Generates relocatable output\(em\&i.e., generate an output file that can in
677 turn serve as input to \c
679 \&. This is often called \c
682 \&. As a side effect, in environments that support standard Unix
683 magic numbers, this option also sets the output file's magic number to
687 If this option is not specified, an absolute file is produced. When
688 linking C++ programs, this option \c
690 \& resolve references to
693 \& is an alternative.
695 This option does the same as \c
701 Omits debugger symbol information (but not all symbols) from the output file.
705 Omits all symbol information from the output file.
711 places the global common symbols in the appropriate output sections,
712 it sorts them by size. First come all the one byte symbols, then all
713 the two bytes, then all the four bytes, and then everything else.
714 This is to prevent gaps between symbols due to
715 alignment constraints. This option disables that sorting.
718 .B \-split\-by\-reloc\ \fIcount
719 Trys to creates extra sections in the output file so that no single
720 output section in the file contains more than
723 This is useful when generating huge relocatable for downloading into
724 certain real time kernels with the COFF object file format; since COFF
725 cannot represent more than 65535 relocations in a single section.
726 Note that this will fail to work with object file formats which do not
727 support arbitrary sections. The linker will not split up individual
728 input sections for redistribution, so if a single input section
731 relocations one output section will contain that many relocations.
736 .B \-split\-by\-reloc
737 but creates a new output section for each input file.
740 .BI "\-Tbss " "org"\c
742 .BI "\-Tdata " "org"\c
744 .BI "\-Ttext " "org"\c
747 \& as the starting address for\(em\&respectively\(em\&the
754 \& segment of the output file.
757 \& must be a hexadecimal integer.
760 .BI "\-T " "commandfile"\c
763 .BI "\-T" "commandfile"\c
768 \&; supported for compatibility with
773 Prints names of input files as \c
781 \& to be entered in the output file as an undefined symbol.
782 This may, for example, trigger linking of additional modules from
783 standard libraries. \c
785 \& may be repeated with different option
786 arguments to enter additional undefined symbols.
790 For anything other than C++ programs, this option is equivalent to
793 \&: it generates relocatable output\(em\&i.e., an output file that can in
794 turn serve as input to \c
796 \&. When linking C++ programs, \c
801 \& resolve references to constructors, unlike \c
807 Display the version number for \c
809 and list the supported emulations.
810 Display which input files can and can not be opened.
814 Display the version number for \c
819 option also lists the supported emulations.
823 Display the version number for \c
829 Warn when a common symbol is combined with another common symbol or with
830 a symbol definition. Unix linkers allow this somewhat sloppy practice,
831 but linkers on some other operating systems do not. This option allows
832 you to find potential problems from combining global symbols.
836 Only warn once for each undefined symbol, rather than once per module
840 .B \-\-whole\-archive
841 For each archive mentioned on the command line, include every object
842 file in the archive in the link, rather than searching the archive for
843 the required object files. This is normally used to turn an archive
844 file into a shared library, forcing every object to be included in the
845 resulting shared library.
849 Delete all temporary local symbols. For most targets, this is all local
850 symbols whose names begin with `\|\c
856 Delete all local symbols.
862 You can change the behavior of
864 \& with the environment variable \c
870 \& determines the input-file object format if you don't
873 \& (or its synonym \c
875 \&). Its value should be one
876 of the BFD names for an input format. If there is no
879 \& in the environment, \c
881 \& uses the natural format
886 \& then BFD attempts to discover the
887 input format by examining binary input files; this method often
888 succeeds, but there are potential ambiguities, since there is no method
889 of ensuring that the magic number used to flag object-file formats is
890 unique. However, the configuration procedure for BFD on each system
891 places the conventional format for that system first in the search-list,
892 so ambiguities are resolved in favor of convention.
901 .RB "`\|" ld "\|' and `\|" binutils "\|'"
907 , Steve Chamberlain and Roland Pesch;
909 The GNU Binary Utilities\c
913 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
915 Permission is granted to make and distribute verbatim copies of
916 this manual provided the copyright notice and this permission notice
917 are preserved on all copies.
919 Permission is granted to copy and distribute modified versions of this
920 manual under the conditions for verbatim copying, provided that the
921 entire resulting derived work is distributed under the terms of a
922 permission notice identical to this one.
924 Permission is granted to copy and distribute translations of this
925 manual into another language, under the above conditions for modified
926 versions, except that this permission notice may be included in
927 translations approved by the Free Software Foundation instead of in
928 the original English.