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 "[\|" \-\-verbose "\|]"
103 .RB "[\|" \-\-version "\|]"
104 .RB "[\|" \-warn\-common "\|]"
105 .RB "[\|" \-warn\-once "\|]"
113 \& combines a number of object and archive files, relocates
114 their data and ties up symbol references. Often the last step in
115 building a new compiled program to run is a call to \c
121 \& accepts Linker Command Language files
122 to provide explicit and total control over the linking process.
123 This man page does not describe the command language; see the `\|\c
130 \&, for full details on the command language and on other aspects of
135 \& uses the general purpose BFD libraries
136 to operate on object files. This allows \c
138 \& to read, combine, and
139 write object files in many different formats\(em\&for example, COFF or
142 \&. Different formats may be linked together to produce any
143 available kind of object file. You can use `\|\c
145 \|' to get a list of formats supported on various architectures; see
148 Aside from its flexibility, the GNU linker is more helpful than other
149 linkers in providing diagnostic information. Many linkers abandon
150 execution immediately upon encountering an error; whenever possible,
153 \& continues executing, allowing you to identify other errors
154 (or, in some cases, to get an output file in spite of the error).
158 \& is meant to cover a broad range of situations,
159 and to be as compatible as possible with other linkers. As a result,
160 you have many choices to control its behavior through the command line,
161 and through environment variables.
164 The plethora of command-line options may seem intimidating, but in
165 actual practice few of them are used in any particular context.
166 For instance, a frequent use of \c
168 \& is to link standard Unix
169 object files on a standard, supported Unix system. On such a system, to
175 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
180 \& to produce a file called \c
183 result of linking the file \c
190 \& which will come from the standard search
193 The command-line options to \c
195 \& may be specified in any order, and
196 may be repeated at will. For the most part, repeating an option with a
197 different argument will either have no further effect, or override prior
198 occurrences (those further to the left on the command line) of an
201 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
206 \& (or its synonym \c
221 The list of object files to be linked together, shown as \c
224 may follow, precede, or be mixed in with command-line options; save that
227 \& argument may not be placed between an option flag and
230 Usually the linker is invoked with at least one object file, but other
231 forms of binary input files can also be specified with \c
236 \&, and the script command language. If \c
239 files at all are specified, the linker does not produce any output, and
240 issues the message `\|\c
244 Option arguments must either follow the option letter without intervening
245 whitespace, or be given as separate arguments immediately following the
246 option that requires them.
249 .BI "-A" "architecture"\c
251 In the current release of \c
253 \&, this option is useful only for the
254 Intel 960 family of architectures. In that \c
256 \& configuration, the
259 \& argument is one of the two-letter names identifying
260 members of the 960 family; the option specifies the desired output
261 target, and warns of any incompatible instructions in the input files.
262 It also modifies the linker's search strategy for archive libraries, to
263 support the use of libraries specific to each particular
264 architecture, by including in the search loop names suffixed with the
265 string identifying the architecture.
267 For example, if your \c
269 \& command line included `\|\c
274 \|', the linker would look (in its built-in search
275 paths, and in any paths you specify with \c
277 \&) for a library with
291 The first two possibilities would be considered in any event; the last
292 two are due to the use of `\|\c
296 Future releases of \c
298 \& may support similar functionality for
299 other architecture families.
301 You can meaningfully use \c
303 \& more than once on a command line, if
304 an architecture family allows combination of target architectures; each
305 use will add another pair of name variants to search for when \c
311 .BI "\-b " "input-format"\c
313 Specify the binary format for input object files that follow this option
314 on the command line. You don't usually need to specify this, as
317 \& is configured to expect as a default input format the most
318 usual format on each machine. \c
320 \& is a text string, the
321 name of a particular format supported by the BFD libraries.
326 \& has the same effect, as does the script command
329 You may want to use this option if you are linking files with an unusual
330 binary format. You can also use \c
332 \& to switch formats explicitly (when
333 linking object files of different formats), by including
338 \& before each group of object files in a
341 The default format is taken from the environment variable
343 \&. You can also define the input
344 format from a script, using the command \c
350 This flag is accepted for command-line compatibility with the SunOS linker,
351 but has no effect on \c
356 .BI "\-c " "commandfile"\c
360 \& to read link commands from the file
363 \&. These commands will completely override \c
366 default link format (rather than adding to it); \c
369 specify everything necessary to describe the target format.
372 You may also include a script of link commands directly in the command
373 line by bracketing it between `\|\c
385 These three options are equivalent; multiple forms are supported for
386 compatibility with other linkers. Use any of them to make \c
389 assign space to common symbols even if a relocatable output file is
392 \&). The script command
394 .B FORCE_COMMON_ALLOCATION\c
395 \& has the same effect.
398 .BI "-defsym " "symbol"\c
402 Create a global symbol in the output file, containing the absolute
405 \&. You may use this option as many
406 times as necessary to define multiple symbols in the command line. A
407 limited form of arithmetic is supported for the \c
410 context: you may give a hexadecimal constant or the name of an existing
415 \& to add or subtract hexadecimal
416 constants or symbols. If you need more elaborate expressions, consider
417 using the linker command language from a script.
424 \& as the explicit symbol for beginning execution of your
425 program, rather than the default entry point. for a
426 discussion of defaults and other ways of specifying the
434 Some older linkers used this option throughout a compilation toolchain
435 for specifying object-file format for both input and output object
438 \&'s mechanisms (the \c
443 for input files, the \c
445 \& command in linker scripts for output
448 \& environment variable) are more flexible, but
449 but it accepts (and ignores) the \c
451 \& option flag for compatibility
452 with scripts written to call the old linker.
455 .BI "\-format " "input\-format"\c
465 Accepted, but ignored; provided for compatibility with other tools.
469 Set the maximum size of objects to be optimized using the GP register
472 under MIPS ECOFF. Ignored for other object file formats.
476 Print a summary of the command-line options on the standard output and exit.
479 begin with two dashes instead of one
480 for compatibility with other GNU programs. The other options start with
481 only one dash for compatibility with other linkers.
485 Perform an incremental link (same as option \c
492 Add an archive file \c
494 \& to the list of files to link. This
495 option may be used any number of times. \c
498 path-list for occurrences of \c
508 .BI "\-L" "searchdir"\c
510 This command adds path \c
512 \& to the list of paths that
515 \& will search for archive libraries. You may use this option
518 The default set of paths searched (without being specified with
521 \&) depends on what emulation mode \c
524 some cases also on how it was configured. The
525 paths can also be specified in a link script with the \c
532 Print (to the standard output file) a link map\(em\&diagnostic information
533 about where symbols are mapped by \c
535 \&, and information on global
536 common storage allocation.
539 .BI "\-Map " "mapfile"\c
542 a link map\(em\&diagnostic information
543 about where symbols are mapped by \c
545 \&, and information on global
546 common storage allocation.
549 .BI "\-m " "emulation"\c
552 linker. You can list the available emulations with the
554 option. This option overrides the compiled-in default, which is the
555 system for which you configured
560 specifies readable and writable \c
565 the output format supports Unix style magic numbers, the output is
570 When you use the `\|\c
572 \&\|' option, the linker does not page-align the
577 sets the text segment to be read only, and \c
584 Normally, the linker will not produce an output file if it encounters
585 errors during the link process. With this flag, you can specify that
586 you wish the output file retained even after non-fatal errors.
589 .BI "\-o " "output"\c
595 \& is a name for the program produced by \c
598 option is not specified, the name `\|\c
600 \|' is used by default. The
603 \& can also specify the output file name.
606 .BI "\-oformat " "output\-format"\c
608 Specify the binary format for the output object file.
609 You don't usually need to specify this, as
612 \& is configured to produce as a default output format the most
613 usual format on each machine. \c
615 \& is a text string, the
616 name of a particular format supported by the BFD libraries.
619 can also specify the output format, but this option overrides it.
622 .BI "\-R " "filename"\c
626 Read symbol names and their addresses from \c
629 relocate it or include it in the output. This allows your output file
630 to refer symbolically to absolute locations of memory defined in other
635 An option with machine dependent effects. Currently this option is only
636 supported on the H8/300.
638 On some platforms, use this option to perform global optimizations that
639 become possible when the linker resolves addressing in your program, such
640 as relaxing address modes and synthesizing new instructions in the
643 On platforms where this is not supported, `\|\c
645 \&\|' is accepted, but has no effect.
649 Generates relocatable output\(em\&i.e., generate an output file that can in
650 turn serve as input to \c
652 \&. This is often called \c
655 \&. As a side effect, in environments that support standard Unix
656 magic numbers, this option also sets the output file's magic number to
660 If this option is not specified, an absolute file is produced. When
661 linking C++ programs, this option \c
663 \& resolve references to
666 \& is an alternative.
668 This option does the same as \c
674 Omits debugger symbol information (but not all symbols) from the output file.
678 Omits all symbol information from the output file.
684 places the global common symbols in the appropriate output sections,
685 it sorts them by size. First come all the one byte symbols, then all
686 the two bytes, then all the four bytes, and then everything else.
687 This is to prevent gaps between symbols due to
688 alignment constraints. This option disables that sorting.
691 .BI "\-Tbss " "org"\c
693 .BI "\-Tdata " "org"\c
695 .BI "\-Ttext " "org"\c
698 \& as the starting address for\(em\&respectively\(em\&the
705 \& segment of the output file.
708 \& must be a hexadecimal integer.
711 .BI "\-T " "commandfile"\c
714 .BI "\-T" "commandfile"\c
719 \&; supported for compatibility with
724 Prints names of input files as \c
732 \& to be entered in the output file as an undefined symbol.
733 This may, for example, trigger linking of additional modules from
734 standard libraries. \c
736 \& may be repeated with different option
737 arguments to enter additional undefined symbols.
741 For anything other than C++ programs, this option is equivalent to
744 \&: it generates relocatable output\(em\&i.e., an output file that can in
745 turn serve as input to \c
747 \&. When linking C++ programs, \c
752 \& resolve references to constructors, unlike \c
758 Display the version number for \c
760 and list the supported emulations.
761 Display which input files can and can not be opened.
765 Display the version number for \c
771 Display the version number for \c
777 Warn when a common symbol is combined with another common symbol or with
778 a symbol definition. Unix linkers allow this somewhat sloppy practice,
779 but linkers on some other operating systems do not. This option allows
780 you to find potential problems from combining global symbols.
784 Only warn once for each undefined symbol, rather than once per module
793 \& is also specified, delete only local symbols
804 \& is also specified, delete all local symbols,
805 not just those beginning with `\|\c
813 You can change the behavior of
815 \& with the environment variable \c
821 \& determines the input-file object format if you don't
824 \& (or its synonym \c
826 \&). Its value should be one
827 of the BFD names for an input format. If there is no
830 \& in the environment, \c
832 \& uses the natural format
837 \& then BFD attempts to discover the
838 input format by examining binary input files; this method often
839 succeeds, but there are potential ambiguities, since there is no method
840 of ensuring that the magic number used to flag object-file formats is
841 unique. However, the configuration procedure for BFD on each system
842 places the conventional format for that system first in the search-list,
843 so ambiguities are resolved in favor of convention.
852 .RB "`\|" ld "\|' and `\|" binutils "\|'"
858 , Steve Chamberlain and Roland Pesch;
860 The GNU Binary Utilities\c
864 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
866 Permission is granted to make and distribute verbatim copies of
867 this manual provided the copyright notice and this permission notice
868 are preserved on all copies.
870 Permission is granted to copy and distribute modified versions of this
871 manual under the conditions for verbatim copying, provided that the
872 entire resulting derived work is distributed under the terms of a
873 permission notice identical to this one.
875 Permission is granted to copy and distribute translations of this
876 manual into another language, under the above conditions for modified
877 versions, except that this permission notice may be included in
878 translations approved by the Free Software Foundation instead of in
879 the original English.