1 .\" Copyright (c) 1991 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
4 .TH gld 1 "5 November 1991" "cygnus support" "GNU Development Tools"
31 .RB "[\|" \-Bstatic "\|]"
35 .RB "[\|" \-d | \-dc | \-dp\c
38 .RB "[\|" "\-defsym\ "\c
50 .RB "[\|" "\-format\ "\c
61 .RB "[\|" \-M | \-m "\|]"
63 .RB "[\|" \-noinhibit-exec "\|]"
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 sets the text segment to be read only, and \c
522 Normally, the linker will not produce an output file if it encounters
523 errors during the link process. With this flag, you can specify that
524 you wish the output file retained even after non-fatal errors.
533 \& is a name for the program produced by \c
536 option is not specified, the name `\|\c
538 \|' is used by default. The
541 \& can also specify the output file name.
544 .BI "-R " "filename"\c
548 Read symbol names and their addresses from \c
551 relocate it or include it in the output. This allows your output file
552 to refer symbolically to absolute locations of memory defined in other
557 Generates relocatable output\(em\&i.e., generate an output file that can in
558 turn serve as input to \c
560 \&. This is often called \c
563 \&. As a side effect, in environments that support standard Unix
564 magic numbers, this option also sets the output file's magic number to
568 If this option is not specified, an absolute file is produced. When
569 linking C++ programs, this option \c
571 \& resolve references to
574 \& is an alternative.
576 This option does the same as \c
582 Omits debugger symbol information (but not all symbols) from the output file.
586 Omits all symbol information from the output file.
589 .BI "{ " "script" " }"
590 You can, if you wish, include a script of linker commands directly in
591 the command line instead of referring to it via an input file. When the
594 \|' occurs on the command line, the linker switches to
595 interpreting the command language until the end of the list of commands
596 is reached\(em\&flagged with a closing brace `\|\c
598 \|'. Other command-line
599 options will not be recognized while parsing the script.
600 for a description of the command language.
605 .BI "-Tdata " "org"\c
607 .BI "-Ttext " "org"\c
610 \& as the starting address for\(em\&respectively\(em\&the
617 \& segment of the output file.
620 \& must be a hexadecimal integer.
623 .BI "-T " "commandfile"\c
626 .BI "-T" "commandfile"\c
631 \&; supported for compatibility with
636 Prints names of input files as \c
647 \& to be entered in the output file as an undefined symbol.
648 This may, for example, trigger linking of additional modules from
649 standard libraries. \c
651 \& may be repeated with different option
652 arguments to enter additional undefined symbols.
656 For anything other than C++ programs, this option is equivalent to
659 \&: it generates relocatable output\(em\&i.e., an output file that can in
660 turn serve as input to \c
662 \&. When linking C++ programs, \c
667 \& resolve references to constructors, unlike \c
673 Display the version number for \c
683 \& is also specified, delete only local symbols
694 \& is also specified, delete all local symbols,
695 not just those beginning with `\|\c
704 \& always consults two environment variables: \c
709 \&. Depending on the setting of the latter, other
710 environment variables may be used as well.
714 \& determines the input-file object format if you don't
717 \& (or its synonym \c
719 \&). Its value should be one
720 of the BFD names for an input format. If there is no
723 \& in the environment, \c
725 \& uses the natural format
730 \& then BFD attempts to discover the
731 input format by examining binary input files; this method often
732 succeeds, but there are potential ambiguities, since there is no method
733 of ensuring that the magic number used to flag object-file formats is
734 unique. However, the configuration procedure for BFD on each system
735 places the conventional format for that system first in the search-list,
736 so ambiguities are resolved in favor of convention.
740 \& controls some aspects of \c
743 personality. Although \c
745 \& is flexible enough to permit its use
746 in many contexts regardless of configuration, you can use this variable
747 to make it act more like one or another older linker by default.
749 In particular, the value of \c
751 \& controls what default
752 linker script is used (thereby controlling the default input and output
753 formats; ; what default paths are searched for
754 archive libraries; and in some cases whether additional linker script
755 commands are available.
757 Here is the current set of emulations available:
761 Emulate the older GNU linker. When this emulation is selected, the
762 default library search paths are
773 The default output format is set to \c
774 .B a.out-generic-big\c
776 default machine is the system's configured BFD default.
779 .B LDEMULATION=gld68k
782 \& emulation; only differs in specifically
783 setting the default BFD machine as \c
788 .B LDEMULATION=gld960
789 Emulate the Intel port of the older \c
792 architectures. The default library search paths are taken from two
793 other environment variables, \c
798 default architecture is \c
800 \&. The default output format is set
803 \&, and in fact the default output file name (if
806 \& is not specified) is \c
808 \&, to reflect this variant
809 format, for this emulation.
811 This emulation can behave slightly differently depending on the setting
814 \& compile-time switch \c
821 \& defined, then an additional environment
824 \&\(em\&is available; its value, if available,
825 specifies some other default output format than \c
830 .B LDEMULATION=gldm88kbcs
831 Sets the output format to \c
833 \& and the architecture to
836 \&. Default library search paths are
848 .B LDEMULATION=lnk960
849 Emulate the Intel linker \c
851 \&. The default output format is
854 \&. With this emulation, \c
857 supports the additional script commands \c
862 specification of library archives. This is the only emulation with
863 extensive support for the \c
865 \& (architecture) command-line option.
866 By default, the architecture \c
868 \& is assumed, but you can choose
869 additional features from the i960 architecture family by using one of
870 the following with \c
872 \& (or by using the \c
896 The default libraries are chosen with some attention to the architecture
897 selected; the core library `\|\c
899 \|' is always included, but the library
902 \& is also used if you've specified any of the architectures
913 \&, this emulation uses additional environment variables
914 to set the default library search paths. Also like \c
917 behavior of this emulation is slightly different depending on whether
920 \& itself was compiled with \c
926 \& was compiled with \c
928 \& defined, the default
929 paths are taken from all three of \c
936 \&. For the first two, paths you supply are automatically
939 \|'; for the last, your path is
940 automatically suffixed with `\|\c
951 the default paths are taken from \c
958 \& is undefined. In this case
961 \& is not used at all.
964 .B LDEMULATION=vanilla
965 This is the least specific setting for \c
969 .B LDEMULATION=vanilla\c
970 \& to disable emulation of other linkers. This
973 \& take the default machine from the BFD
974 configuration on your system; \c
975 .B a.out-generic-big\c
977 target. No other defaults are specified.
986 .RB "`\|" ld "\|' and `\|" binutils "\|'"
991 gld: the GNU linker\c
992 , Steve Chamberlain and Roland Pesch;
994 The GNU Binary Utilities\c
998 Copyright (c) 1991 Free Software Foundation, Inc.
1000 Permission is granted to make and distribute verbatim copies of
1001 this manual provided the copyright notice and this permission notice
1002 are preserved on all copies.
1004 Permission is granted to copy and distribute modified versions of this
1005 manual under the conditions for verbatim copying, provided that the
1006 entire resulting derived work is distributed under the terms of a
1007 permission notice identical to this one.
1009 Permission is granted to copy and distribute translations of this
1010 manual into another language, under the above conditions for modified
1011 versions, except that this permission notice may be included in
1012 translations approved by the Free Software Foundation instead of in
1013 the original English.