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
49 .RB "[\|" "\-format\ "\c
56 .RB "[\|" \-\-help "\|]"
71 .RB "[\|" \-n | \-N "\|]"
72 .RB "[\|" \-noinhibit-exec "\|]"
73 .RB "[\|" "\-oformat\ "\c
79 .RB "[\|" \-relax "\|]"
80 .RB "[\|" \-r | \-Ur "\|]"
83 .RB "[\|" \-sort\-common "\|]"
87 .RB "[\|" "\-Ttext\ "\c
90 .RB "[\|" "\-Tdata\ "\c
93 .RB "[\|" "\-Tbss\ "\c
102 .RB "[\|" \-\-version "\|]"
103 .RB "[\|" \-warn\-common "\|]"
104 .RB "[\|" \-warn\-once "\|]"
112 \& combines a number of object and archive files, relocates
113 their data and ties up symbol references. Often the last step in
114 building a new compiled program to run is a call to \c
120 \& accepts Linker Command Language files
121 to provide explicit and total control over the linking process.
122 This man page does not describe the command language; see the `\|\c
129 \&, for full details on the command language and on other aspects of
134 \& uses the general purpose BFD libraries
135 to operate on object files. This allows \c
137 \& to read, combine, and
138 write object files in many different formats\(em\&for example, COFF or
141 \&. Different formats may be linked together to produce any
142 available kind of object file. You can use `\|\c
144 \|' to get a list of formats supported on various architectures; see
147 Aside from its flexibility, the GNU linker is more helpful than other
148 linkers in providing diagnostic information. Many linkers abandon
149 execution immediately upon encountering an error; whenever possible,
152 \& continues executing, allowing you to identify other errors
153 (or, in some cases, to get an output file in spite of the error).
157 \& is meant to cover a broad range of situations,
158 and to be as compatible as possible with other linkers. As a result,
159 you have many choices to control its behavior through the command line,
160 and through environment variables.
163 The plethora of command-line options may seem intimidating, but in
164 actual practice few of them are used in any particular context.
165 For instance, a frequent use of \c
167 \& is to link standard Unix
168 object files on a standard, supported Unix system. On such a system, to
174 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
179 \& to produce a file called \c
182 result of linking the file \c
189 \& which will come from the standard search
192 The command-line options to \c
194 \& may be specified in any order, and
195 may be repeated at will. For the most part, repeating an option with a
196 different argument will either have no further effect, or override prior
197 occurrences (those further to the left on the command line) of an
200 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
205 \& (or its synonym \c
220 The list of object files to be linked together, shown as \c
223 may follow, precede, or be mixed in with command-line options; save that
226 \& argument may not be placed between an option flag and
229 Usually the linker is invoked with at least one object file, but other
230 forms of binary input files can also be specified with \c
235 \&, and the script command language. If \c
238 files at all are specified, the linker does not produce any output, and
239 issues the message `\|\c
243 Option arguments must either follow the option letter without intervening
244 whitespace, or be given as separate arguments immediately following the
245 option that requires them.
248 .BI "-A" "architecture"\c
250 In the current release of \c
252 \&, this option is useful only for the
253 Intel 960 family of architectures. In that \c
255 \& configuration, the
258 \& argument is one of the two-letter names identifying
259 members of the 960 family; the option specifies the desired output
260 target, and warns of any incompatible instructions in the input files.
261 It also modifies the linker's search strategy for archive libraries, to
262 support the use of libraries specific to each particular
263 architecture, by including in the search loop names suffixed with the
264 string identifying the architecture.
266 For example, if your \c
268 \& command line included `\|\c
273 \|', the linker would look (in its built-in search
274 paths, and in any paths you specify with \c
276 \&) for a library with
290 The first two possibilities would be considered in any event; the last
291 two are due to the use of `\|\c
295 Future releases of \c
297 \& may support similar functionality for
298 other architecture families.
300 You can meaningfully use \c
302 \& more than once on a command line, if
303 an architecture family allows combination of target architectures; each
304 use will add another pair of name variants to search for when \c
310 .BI "\-b " "input-format"\c
312 Specify the binary format for input object files that follow this option
313 on the command line. You don't usually need to specify this, as
316 \& is configured to expect as a default input format the most
317 usual format on each machine. \c
319 \& is a text string, the
320 name of a particular format supported by the BFD libraries.
325 \& has the same effect, as does the script command
328 You may want to use this option if you are linking files with an unusual
329 binary format. You can also use \c
331 \& to switch formats explicitly (when
332 linking object files of different formats), by including
337 \& before each group of object files in a
340 The default format is taken from the environment variable
342 \&. You can also define the input
343 format from a script, using the command \c
349 This flag is accepted for command-line compatibility with the SunOS linker,
350 but has no effect on \c
355 .BI "\-c " "commandfile"\c
359 \& to read link commands from the file
362 \&. These commands will completely override \c
365 default link format (rather than adding to it); \c
368 specify everything necessary to describe the target format.
371 You may also include a script of link commands directly in the command
372 line by bracketing it between `\|\c
384 These three options are equivalent; multiple forms are supported for
385 compatibility with other linkers. Use any of them to make \c
388 assign space to common symbols even if a relocatable output file is
391 \&). The script command
393 .B FORCE_COMMON_ALLOCATION\c
394 \& has the same effect.
397 .BI "-defsym " "symbol"\c
401 Create a global symbol in the output file, containing the absolute
404 \&. You may use this option as many
405 times as necessary to define multiple symbols in the command line. A
406 limited form of arithmetic is supported for the \c
409 context: you may give a hexadecimal constant or the name of an existing
414 \& to add or subtract hexadecimal
415 constants or symbols. If you need more elaborate expressions, consider
416 using the linker command language from a script.
423 \& as the explicit symbol for beginning execution of your
424 program, rather than the default entry point. for a
425 discussion of defaults and other ways of specifying the
433 Some older linkers used this option throughout a compilation toolchain
434 for specifying object-file format for both input and output object
437 \&'s mechanisms (the \c
442 for input files, the \c
444 \& command in linker scripts for output
447 \& environment variable) are more flexible, but
448 but it accepts (and ignores) the \c
450 \& option flag for compatibility
451 with scripts written to call the old linker.
454 .BI "\-format " "input\-format"\c
464 Accepted, but ignored; provided for compatibility with other tools.
468 Set the maximum size of objects to be optimized using the GP register
471 under MIPS ECOFF. Ignored for other object file formats.
475 Print a summary of the command-line options on the standard output and exit.
478 begin with two dashes instead of one
479 for compatibility with other GNU programs. The other options start with
480 only one dash for compatibility with other linkers.
484 Perform an incremental link (same as option \c
491 Add an archive file \c
493 \& to the list of files to link. This
494 option may be used any number of times. \c
497 path-list for occurrences of \c
507 .BI "\-L" "searchdir"\c
509 This command adds path \c
511 \& to the list of paths that
514 \& will search for archive libraries. You may use this option
517 The default set of paths searched (without being specified with
520 \&) depends on what emulation mode \c
523 some cases also on how it was configured. The
524 paths can also be specified in a link script with the \c
531 Print (to the standard output file) a link map\(em\&diagnostic information
532 about where symbols are mapped by \c
534 \&, and information on global
535 common storage allocation.
538 .BI "\-Map " "mapfile"\c
541 a link map\(em\&diagnostic information
542 about where symbols are mapped by \c
544 \&, and information on global
545 common storage allocation.
548 .BI "\-m " "emulation"\c
551 linker. You can list the available emulations with the
553 option. This option overrides the compiled-in default, which is the
554 system for which you configured
559 specifies readable and writable \c
564 the output format supports Unix style magic numbers, the output is
569 When you use the `\|\c
571 \&\|' option, the linker does not page-align the
576 sets the text segment to be read only, and \c
583 Normally, the linker will not produce an output file if it encounters
584 errors during the link process. With this flag, you can specify that
585 you wish the output file retained even after non-fatal errors.
588 .BI "\-o " "output"\c
594 \& is a name for the program produced by \c
597 option is not specified, the name `\|\c
599 \|' is used by default. The
602 \& can also specify the output file name.
605 .BI "\-oformat " "output\-format"\c
607 Specify the binary format for the output object file.
608 You don't usually need to specify this, as
611 \& is configured to produce as a default output format the most
612 usual format on each machine. \c
614 \& is a text string, the
615 name of a particular format supported by the BFD libraries.
618 can also specify the output format, but this option overrides it.
621 .BI "\-R " "filename"\c
625 Read symbol names and their addresses from \c
628 relocate it or include it in the output. This allows your output file
629 to refer symbolically to absolute locations of memory defined in other
634 An option with machine dependent effects. Currently this option is only
635 supported on the H8/300.
637 On some platforms, use this option to perform global optimizations that
638 become possible when the linker resolves addressing in your program, such
639 as relaxing address modes and synthesizing new instructions in the
642 On platforms where this is not supported, `\|\c
644 \&\|' is accepted, but has no effect.
648 Generates relocatable output\(em\&i.e., generate an output file that can in
649 turn serve as input to \c
651 \&. This is often called \c
654 \&. As a side effect, in environments that support standard Unix
655 magic numbers, this option also sets the output file's magic number to
659 If this option is not specified, an absolute file is produced. When
660 linking C++ programs, this option \c
662 \& resolve references to
665 \& is an alternative.
667 This option does the same as \c
673 Omits debugger symbol information (but not all symbols) from the output file.
677 Omits all symbol information from the output file.
683 places the global common symbols in the appropriate output sections,
684 it sorts them by size. First come all the one byte symbols, then all
685 the two bytes, then all the four bytes, and then everything else.
686 This is to prevent gaps between symbols due to
687 alignment constraints. This option disables that sorting.
690 .BI "\-Tbss " "org"\c
692 .BI "\-Tdata " "org"\c
694 .BI "\-Ttext " "org"\c
697 \& as the starting address for\(em\&respectively\(em\&the
704 \& segment of the output file.
707 \& must be a hexadecimal integer.
710 .BI "\-T " "commandfile"\c
713 .BI "\-T" "commandfile"\c
718 \&; supported for compatibility with
723 Prints names of input files as \c
731 \& to be entered in the output file as an undefined symbol.
732 This may, for example, trigger linking of additional modules from
733 standard libraries. \c
735 \& may be repeated with different option
736 arguments to enter additional undefined symbols.
740 For anything other than C++ programs, this option is equivalent to
743 \&: it generates relocatable output\(em\&i.e., an output file that can in
744 turn serve as input to \c
746 \&. When linking C++ programs, \c
751 \& resolve references to constructors, unlike \c
757 Display the version number for \c
759 and list the supported emulations.
760 Display which input files can and can not be opened.
764 Display the version number for \c
770 Display the version number for \c
776 Warn when a common symbol is combined with another common symbol or with
777 a symbol definition. Unix linkers allow this somewhat sloppy practice,
778 but linkers on some other operating systems do not. This option allows
779 you to find potential problems from combining global symbols.
783 Only warn once for each undefined symbol, rather than once per module
792 \& is also specified, delete only local symbols
803 \& is also specified, delete all local symbols,
804 not just those beginning with `\|\c
812 You can change the behavior of
814 \& with the environment variable \c
820 \& determines the input-file object format if you don't
823 \& (or its synonym \c
825 \&). Its value should be one
826 of the BFD names for an input format. If there is no
829 \& in the environment, \c
831 \& uses the natural format
836 \& then BFD attempts to discover the
837 input format by examining binary input files; this method often
838 succeeds, but there are potential ambiguities, since there is no method
839 of ensuring that the magic number used to flag object-file formats is
840 unique. However, the configuration procedure for BFD on each system
841 places the conventional format for that system first in the search-list,
842 so ambiguities are resolved in favor of convention.
851 .RB "`\|" ld "\|' and `\|" binutils "\|'"
857 , Steve Chamberlain and Roland Pesch;
859 The GNU Binary Utilities\c
863 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
865 Permission is granted to make and distribute verbatim copies of
866 this manual provided the copyright notice and this permission notice
867 are preserved on all copies.
869 Permission is granted to copy and distribute modified versions of this
870 manual under the conditions for verbatim copying, provided that the
871 entire resulting derived work is distributed under the terms of a
872 permission notice identical to this one.
874 Permission is granted to copy and distribute translations of this
875 manual into another language, under the above conditions for modified
876 versions, except that this permission notice may be included in
877 translations approved by the Free Software Foundation instead of in
878 the original English.