1 .\" Copyright (c) 1991, 1992 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
3 .TH gld 1 "23 January 1992" "cygnus support" "GNU Development Tools"
30 .RB "[\|" \-Bstatic "\|]"
34 .RB "[\|" \-d | \-dc | \-dp\c
37 .RB "[\|" "\-defsym\ "\c
49 .RB "[\|" "\-format\ "\c
60 .RB "[\|" \-M | \-m "\|]"
61 .RB "[\|" \-n | \-N "\|]"
62 .RB "[\|" \-noinhibit-exec "\|]"
66 .RB "[\|" \-relax "\|]"
67 .RB "[\|" \-r | \-Ur "\|]"
73 .RB "[\|" "\-Ttext\ "\c
76 .RB "[\|" "\-Tdata\ "\c
79 .RB "[\|" "\-Tbss\ "\c
97 \& combines a number of object and archive files, relocates
98 their data and ties up symbol references. Often the last step in
99 building a new compiled program to run is a call to \c
105 \& accepts Linker Command Language files
106 to provide explicit and total control over the linking process.
107 This man page does not describe the command language; see the `\|\c
114 \&, for full details on the command language and on other aspects of
119 \& uses the general purpose BFD libraries
120 to operate on object files. This allows \c
122 \& to read, combine, and
123 write object files in many different formats\(em\&for example, COFF or
126 \&. Different formats may be linked together to produce any
127 available kind of object file. You can use `\|\c
129 \|' to get a list of formats supported on various architectures; see
132 Aside from its flexibility, the GNU linker is more helpful than other
133 linkers in providing diagnostic information. Many linkers abandon
134 execution immediately upon encountering an error; whenever possible,
137 \& continues executing, allowing you to identify other errors
138 (or, in some cases, to get an output file in spite of the error).
142 \& is meant to cover a broad range of situations,
143 and to be as compatible as possible with other linkers. As a result,
144 you have many choices to control its behavior through the command line,
145 and through environment variables.
148 The plethora of command-line options may seem intimidating, but in
149 actual practice few of them are used in any particular context.
150 For instance, a frequent use of \c
152 \& is to link standard Unix
153 object files on a standard, supported Unix system. On such a system, to
159 $\ gld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
164 \& to produce a file called \c
167 result of linking the file \c
174 \& which will come from the standard search
177 The command-line options to \c
179 \& may be specified in any order, and
180 may be repeated at will. For the most part, repeating an option with a
181 different argument will either have no further effect, or override prior
182 occurrences (those further to the left on the command line) of an
185 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
190 \& (or its synonym \c
205 The list of object files to be linked together, shown as \c
208 may follow, precede, or be mixed in with command-line options; save that
211 \& argument may not be placed between an option flag and
214 Usually the linker is invoked with at least one object file, but other
215 forms of binary input files can also be specified with \c
220 \&, and the script command language. If \c
223 files at all are specified, the linker does not produce any output, and
224 issues the message `\|\c
228 Option arguments must either follow the option letter without intervening
229 whitespace, or be given as separate arguments immediately following the
230 option that requires them.
233 .IR "objfiles" .\|.\|.
239 .BI "-A" "architecture"\c
241 In the current release of \c
243 \&, this option is useful only for the
244 Intel 960 family of architectures. In that \c
246 \& configuration, the
249 \& argument is one of the two-letter names identifying
250 members of the 960 family; the option specifies the desired output
251 target, and warns of any incompatible instructions in the input files.
252 It also modifies the linker's search strategy for archive libraries, to
253 support the use of libraries specific to each particular
254 architecture, by including in the search loop names suffixed with the
255 string identifying the architecture.
257 For example, if your \c
259 \& command line included `\|\c
264 \|', the linker would look (in its built-in search
265 paths, and in any paths you specify with \c
267 \&) for a library with
281 The first two possibilities would be considered in any event; the last
282 two are due to the use of `\|\c
286 Future releases of \c
288 \& may support similar functionality for
289 other architecture families.
291 You can meaningfully use \c
293 \& more than once on a command line, if
294 an architecture family allows combination of target architectures; each
295 use will add another pair of name variants to search for when \c
301 .BI "-b " "input-format"\c
303 Specify the binary format for input object files that follow this option
304 on the command line. You don't usually need to specify this, as
307 \& is configured to expect as a default input format the most
308 usual format on each machine. \c
310 \& is a text string, the
311 name of a particular format supported by the BFD libraries.
316 \& has the same effect.
318 You may want to use this option if you are linking files with an unusual
319 binary format. You can also use \c
321 \& to switch formats explicitly (when
322 linking object files of different formats), by including
327 \& before each group of object files in a
330 The default format is taken from the environment variable
332 \&. You can also define the input
333 format from a script, using the command \c
339 This flag is accepted for command-line compatibility with the SunOS linker,
340 but has no effect on \c
345 .BI "-c " "commandfile"\c
349 \& to read link commands from the file
352 \&. These commands will completely override \c
355 default link format (rather than adding to it); \c
358 specify everything necessary to describe the target format.
361 You may also include a script of link commands directly in the command
362 line by bracketing it between `\|\c
374 These three options are equivalent; multiple forms are supported for
375 compatibility with other linkers. Use any of them to make \c
378 assign space to common symbols even if a relocatable output file is
381 \&). The script command
383 .B FORCE_COMMON_ALLOCATION\c
384 \& has the same effect.
387 .BI "-defsym " "symbol"\c
391 Create a global symbol in the output file, containing the absolute
394 \&. You may use this option as many
395 times as necessary to define multiple symbols in the command line. A
396 limited form of arithmetic is supported for the \c
399 context: you may give a hexadecimal constant or the name of an existing
404 \& to add or subtract hexadecimal
405 constants or symbols. If you need more elaborate expressions, consider
406 using the linker command language from a script.
413 \& as the explicit symbol for beginning execution of your
414 program, rather than the default entry point. for a
415 discussion of defaults and other ways of specifying the
423 Some older linkers used this option throughout a compilation toolchain
424 for specifying object-file format for both input and output object
427 \&'s mechanisms (the \c
432 for input files, the \c
434 \& command in linker scripts for output
437 \& environment variable) are more flexible, but
438 but it accepts (and ignores) the \c
440 \& option flag for compatibility
441 with scripts written to call the old linker.
444 .BI "-format " "input-format"\c
454 Accepted, but ignored; provided for compatibility with other tools.
458 Perform an incremental link (same as option \c
465 Add an archive file \c
467 \& to the list of files to link. This
468 option may be used any number of times. \c
471 path-list for occurrences of \c
481 .BI "-L" "searchdir"\c
483 This command adds path \c
485 \& to the list of paths that
488 \& will search for archive libraries. You may use this option
491 The default set of paths searched (without being specified with
494 \&) depends on what emulation mode \c
497 some cases also on how it was configured. The
498 paths can also be specified in a link script with the \c
507 Print (to the standard output file) a link map\(em\&diagnostic information
508 about where symbols are mapped by \c
510 \&, and information on global
511 common storage allocation.
515 specifies readable and writable \c
520 the output format supports Unix style magic numbers, the output is
525 When you use the `\|\c
527 \&\|' option, the linker does not page-align the
532 sets the text segment to be read only, and \c
539 Normally, the linker will not produce an output file if it encounters
540 errors during the link process. With this flag, you can specify that
541 you wish the output file retained even after non-fatal errors.
550 \& is a name for the program produced by \c
553 option is not specified, the name `\|\c
555 \|' is used by default. The
558 \& can also specify the output file name.
561 .BI "-R " "filename"\c
565 Read symbol names and their addresses from \c
568 relocate it or include it in the output. This allows your output file
569 to refer symbolically to absolute locations of memory defined in other
574 An option with machine dependent effects. Currently this option is only
575 supported on the H8/300.
577 On some platforms, use this option to perform global optimizations that
578 become possible when the linker resolves addressing in your program, such
579 as relaxing address modes and synthesizing new instructions in the
582 On platforms where this is not supported, `\|\c
584 \&\|' is accepted, but has no effect.
588 Generates relocatable output\(em\&i.e., generate an output file that can in
589 turn serve as input to \c
591 \&. This is often called \c
594 \&. As a side effect, in environments that support standard Unix
595 magic numbers, this option also sets the output file's magic number to
599 If this option is not specified, an absolute file is produced. When
600 linking C++ programs, this option \c
602 \& resolve references to
605 \& is an alternative.
607 This option does the same as \c
613 Omits debugger symbol information (but not all symbols) from the output file.
617 Omits all symbol information from the output file.
620 .BI "{ " "script" " }"
621 You can, if you wish, include a script of linker commands directly in
622 the command line instead of referring to it via an input file. When the
625 \|' occurs on the command line, the linker switches to
626 interpreting the command language until the end of the list of commands
627 is reached\(em\&flagged with a closing brace `\|\c
629 \|'. Other command-line
630 options will not be recognized while parsing the script.
631 for a description of the command language.
636 .BI "-Tdata " "org"\c
638 .BI "-Ttext " "org"\c
641 \& as the starting address for\(em\&respectively\(em\&the
648 \& segment of the output file.
651 \& must be a hexadecimal integer.
654 .BI "-T " "commandfile"\c
657 .BI "-T" "commandfile"\c
662 \&; supported for compatibility with
667 Prints names of input files as \c
678 \& to be entered in the output file as an undefined symbol.
679 This may, for example, trigger linking of additional modules from
680 standard libraries. \c
682 \& may be repeated with different option
683 arguments to enter additional undefined symbols.
687 For anything other than C++ programs, this option is equivalent to
690 \&: it generates relocatable output\(em\&i.e., an output file that can in
691 turn serve as input to \c
693 \&. When linking C++ programs, \c
698 \& resolve references to constructors, unlike \c
704 Display the version number for \c
714 \& is also specified, delete only local symbols
725 \& is also specified, delete all local symbols,
726 not just those beginning with `\|\c
735 \& always consults two environment variables: \c
740 \&. Depending on the setting of the latter, other
741 environment variables may be used as well.
745 \& determines the input-file object format if you don't
748 \& (or its synonym \c
750 \&). Its value should be one
751 of the BFD names for an input format. If there is no
754 \& in the environment, \c
756 \& uses the natural format
761 \& then BFD attempts to discover the
762 input format by examining binary input files; this method often
763 succeeds, but there are potential ambiguities, since there is no method
764 of ensuring that the magic number used to flag object-file formats is
765 unique. However, the configuration procedure for BFD on each system
766 places the conventional format for that system first in the search-list,
767 so ambiguities are resolved in favor of convention.
771 \& controls some aspects of \c
774 personality. Although \c
776 \& is flexible enough to permit its use
777 in many contexts regardless of configuration, you can use this variable
778 to make it act more like one or another older linker by default.
780 In particular, the value of \c
782 \& controls what default
783 linker script is used (thereby controlling the default input and output
784 formats; ; what default paths are searched for
785 archive libraries; and in some cases whether additional linker script
786 commands are available.
788 Here is the current set of emulations available:
792 Emulate the older GNU linker. When this emulation is selected, the
793 default library search paths are
804 The default output format is set to \c
805 .B a.out-generic-big\c
807 default machine is the system's configured BFD default.
810 .B LDEMULATION=gld68k
813 \& emulation; only differs in specifically
814 setting the default BFD machine as \c
819 .B LDEMULATION=gld960
820 Emulate the Intel port of the older \c
823 architectures. The default library search paths are taken from two
824 other environment variables, \c
829 default architecture is \c
831 \&. The default output format is set
834 \&, and in fact the default output file name (if
837 \& is not specified) is \c
839 \&, to reflect this variant
840 format, for this emulation.
842 This emulation can behave slightly differently depending on the setting
845 \& compile-time switch \c
852 \& defined, then an additional environment
855 \&\(em\&is available; its value, if available,
856 specifies some other default output format than \c
861 .B LDEMULATION=gldm88kbcs
862 Sets the output format to \c
864 \& and the architecture to
867 \&. Default library search paths are
879 .B LDEMULATION=lnk960
880 Emulate the Intel linker \c
882 \&. The default output format is
885 \&. With this emulation, \c
888 supports the additional script commands \c
893 specification of library archives. This is the only emulation with
894 extensive support for the \c
896 \& (architecture) command-line option.
897 By default, the architecture \c
899 \& is assumed, but you can choose
900 additional features from the i960 architecture family by using one of
901 the following with \c
903 \& (or by using the \c
927 The default libraries are chosen with some attention to the architecture
928 selected; the core library `\|\c
930 \|' is always included, but the library
933 \& is also used if you've specified any of the architectures
944 \&, this emulation uses additional environment variables
945 to set the default library search paths. Also like \c
948 behavior of this emulation is slightly different depending on whether
951 \& itself was compiled with \c
957 \& was compiled with \c
959 \& defined, the default
960 paths are taken from all three of \c
967 \&. For the first two, paths you supply are automatically
970 \|'; for the last, your path is
971 automatically suffixed with `\|\c
982 the default paths are taken from \c
989 \& is undefined. In this case
992 \& is not used at all.
995 .B LDEMULATION=vanilla
996 This is the least specific setting for \c
1000 .B LDEMULATION=vanilla\c
1001 \& to disable emulation of other linkers. This
1004 \& take the default machine from the BFD
1005 configuration on your system; \c
1006 .B a.out-generic-big\c
1008 target. No other defaults are specified.
1017 .RB "`\|" ld "\|' and `\|" binutils "\|'"
1022 gld: the GNU linker\c
1023 , Steve Chamberlain and Roland Pesch;
1025 The GNU Binary Utilities\c
1029 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
1031 Permission is granted to make and distribute verbatim copies of
1032 this manual provided the copyright notice and this permission notice
1033 are preserved on all copies.
1035 Permission is granted to copy and distribute modified versions of this
1036 manual under the conditions for verbatim copying, provided that the
1037 entire resulting derived work is distributed under the terms of a
1038 permission notice identical to this one.
1040 Permission is granted to copy and distribute translations of this
1041 manual into another language, under the above conditions for modified
1042 versions, except that this permission notice may be included in
1043 translations approved by the Free Software Foundation instead of in
1044 the original English.