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
70 .RB "[\|" \-n | \-N "\|]"
71 .RB "[\|" \-noinhibit-exec "\|]"
75 .RB "[\|" \-relax "\|]"
76 .RB "[\|" \-r | \-Ur "\|]"
82 .RB "[\|" "\-Ttext\ "\c
85 .RB "[\|" "\-Tdata\ "\c
88 .RB "[\|" "\-Tbss\ "\c
107 \& combines a number of object and archive files, relocates
108 their data and ties up symbol references. Often the last step in
109 building a new compiled program to run is a call to \c
115 \& accepts Linker Command Language files
116 to provide explicit and total control over the linking process.
117 This man page does not describe the command language; see the `\|\c
124 \&, for full details on the command language and on other aspects of
129 \& uses the general purpose BFD libraries
130 to operate on object files. This allows \c
132 \& to read, combine, and
133 write object files in many different formats\(em\&for example, COFF or
136 \&. Different formats may be linked together to produce any
137 available kind of object file. You can use `\|\c
139 \|' to get a list of formats supported on various architectures; see
142 Aside from its flexibility, the GNU linker is more helpful than other
143 linkers in providing diagnostic information. Many linkers abandon
144 execution immediately upon encountering an error; whenever possible,
147 \& continues executing, allowing you to identify other errors
148 (or, in some cases, to get an output file in spite of the error).
152 \& is meant to cover a broad range of situations,
153 and to be as compatible as possible with other linkers. As a result,
154 you have many choices to control its behavior through the command line,
155 and through environment variables.
158 The plethora of command-line options may seem intimidating, but in
159 actual practice few of them are used in any particular context.
160 For instance, a frequent use of \c
162 \& is to link standard Unix
163 object files on a standard, supported Unix system. On such a system, to
169 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
174 \& to produce a file called \c
177 result of linking the file \c
184 \& which will come from the standard search
187 The command-line options to \c
189 \& may be specified in any order, and
190 may be repeated at will. For the most part, repeating an option with a
191 different argument will either have no further effect, or override prior
192 occurrences (those further to the left on the command line) of an
195 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
200 \& (or its synonym \c
215 The list of object files to be linked together, shown as \c
218 may follow, precede, or be mixed in with command-line options; save that
221 \& argument may not be placed between an option flag and
224 Usually the linker is invoked with at least one object file, but other
225 forms of binary input files can also be specified with \c
230 \&, and the script command language. If \c
233 files at all are specified, the linker does not produce any output, and
234 issues the message `\|\c
238 Option arguments must either follow the option letter without intervening
239 whitespace, or be given as separate arguments immediately following the
240 option that requires them.
243 .BI "-A" "architecture"\c
245 In the current release of \c
247 \&, this option is useful only for the
248 Intel 960 family of architectures. In that \c
250 \& configuration, the
253 \& argument is one of the two-letter names identifying
254 members of the 960 family; the option specifies the desired output
255 target, and warns of any incompatible instructions in the input files.
256 It also modifies the linker's search strategy for archive libraries, to
257 support the use of libraries specific to each particular
258 architecture, by including in the search loop names suffixed with the
259 string identifying the architecture.
261 For example, if your \c
263 \& command line included `\|\c
268 \|', the linker would look (in its built-in search
269 paths, and in any paths you specify with \c
271 \&) for a library with
285 The first two possibilities would be considered in any event; the last
286 two are due to the use of `\|\c
290 Future releases of \c
292 \& may support similar functionality for
293 other architecture families.
295 You can meaningfully use \c
297 \& more than once on a command line, if
298 an architecture family allows combination of target architectures; each
299 use will add another pair of name variants to search for when \c
305 .BI "-b " "input-format"\c
307 Specify the binary format for input object files that follow this option
308 on the command line. You don't usually need to specify this, as
311 \& is configured to expect as a default input format the most
312 usual format on each machine. \c
314 \& is a text string, the
315 name of a particular format supported by the BFD libraries.
320 \& has the same effect.
322 You may want to use this option if you are linking files with an unusual
323 binary format. You can also use \c
325 \& to switch formats explicitly (when
326 linking object files of different formats), by including
331 \& before each group of object files in a
334 The default format is taken from the environment variable
336 \&. You can also define the input
337 format from a script, using the command \c
343 This flag is accepted for command-line compatibility with the SunOS linker,
344 but has no effect on \c
349 .BI "-c " "commandfile"\c
353 \& to read link commands from the file
356 \&. These commands will completely override \c
359 default link format (rather than adding to it); \c
362 specify everything necessary to describe the target format.
365 You may also include a script of link commands directly in the command
366 line by bracketing it between `\|\c
378 These three options are equivalent; multiple forms are supported for
379 compatibility with other linkers. Use any of them to make \c
382 assign space to common symbols even if a relocatable output file is
385 \&). The script command
387 .B FORCE_COMMON_ALLOCATION\c
388 \& has the same effect.
391 .BI "-defsym " "symbol"\c
395 Create a global symbol in the output file, containing the absolute
398 \&. You may use this option as many
399 times as necessary to define multiple symbols in the command line. A
400 limited form of arithmetic is supported for the \c
403 context: you may give a hexadecimal constant or the name of an existing
408 \& to add or subtract hexadecimal
409 constants or symbols. If you need more elaborate expressions, consider
410 using the linker command language from a script.
417 \& as the explicit symbol for beginning execution of your
418 program, rather than the default entry point. for a
419 discussion of defaults and other ways of specifying the
427 Some older linkers used this option throughout a compilation toolchain
428 for specifying object-file format for both input and output object
431 \&'s mechanisms (the \c
436 for input files, the \c
438 \& command in linker scripts for output
441 \& environment variable) are more flexible, but
442 but it accepts (and ignores) the \c
444 \& option flag for compatibility
445 with scripts written to call the old linker.
448 .BI "-format " "input-format"\c
458 Accepted, but ignored; provided for compatibility with other tools.
462 Set the maximum size of objects to be optimized using the GP register
465 under MIPS ECOFF. Ignored for other object file formats.
469 Perform an incremental link (same as option \c
476 Add an archive file \c
478 \& to the list of files to link. This
479 option may be used any number of times. \c
482 path-list for occurrences of \c
492 .BI "-L" "searchdir"\c
494 This command adds path \c
496 \& to the list of paths that
499 \& will search for archive libraries. You may use this option
502 The default set of paths searched (without being specified with
505 \&) depends on what emulation mode \c
508 some cases also on how it was configured. The
509 paths can also be specified in a link script with the \c
516 Print (to the standard output file) a link map\(em\&diagnostic information
517 about where symbols are mapped by \c
519 \&, and information on global
520 common storage allocation.
523 .BI "\-Map " "mapfile"\c
526 a link map\(em\&diagnostic information
527 about where symbols are mapped by \c
529 \&, and information on global
530 common storage allocation.
533 .BI "\-m " "emulation"\c
536 linker. You can list the available emulations with the
538 option. This option overrides the compiled-in default, which is the
539 system for which you configured
544 specifies readable and writable \c
549 the output format supports Unix style magic numbers, the output is
554 When you use the `\|\c
556 \&\|' option, the linker does not page-align the
561 sets the text segment to be read only, and \c
568 Normally, the linker will not produce an output file if it encounters
569 errors during the link process. With this flag, you can specify that
570 you wish the output file retained even after non-fatal errors.
579 \& is a name for the program produced by \c
582 option is not specified, the name `\|\c
584 \|' is used by default. The
587 \& can also specify the output file name.
590 .BI "-R " "filename"\c
594 Read symbol names and their addresses from \c
597 relocate it or include it in the output. This allows your output file
598 to refer symbolically to absolute locations of memory defined in other
603 An option with machine dependent effects. Currently this option is only
604 supported on the H8/300.
606 On some platforms, use this option to perform global optimizations that
607 become possible when the linker resolves addressing in your program, such
608 as relaxing address modes and synthesizing new instructions in the
611 On platforms where this is not supported, `\|\c
613 \&\|' is accepted, but has no effect.
617 Generates relocatable output\(em\&i.e., generate an output file that can in
618 turn serve as input to \c
620 \&. This is often called \c
623 \&. As a side effect, in environments that support standard Unix
624 magic numbers, this option also sets the output file's magic number to
628 If this option is not specified, an absolute file is produced. When
629 linking C++ programs, this option \c
631 \& resolve references to
634 \& is an alternative.
636 This option does the same as \c
642 Omits debugger symbol information (but not all symbols) from the output file.
646 Omits all symbol information from the output file.
649 .BI "{ " "script" " }"
650 You can, if you wish, include a script of linker commands directly in
651 the command line instead of referring to it via an input file. When the
654 \|' occurs on the command line, the linker switches to
655 interpreting the command language until the end of the list of commands
656 is reached\(em\&flagged with a closing brace `\|\c
658 \|'. Other command-line
659 options will not be recognized while parsing the script.
667 \&, for a description of the command language.
672 .BI "-Tdata " "org"\c
674 .BI "-Ttext " "org"\c
677 \& as the starting address for\(em\&respectively\(em\&the
684 \& segment of the output file.
687 \& must be a hexadecimal integer.
690 .BI "-T " "commandfile"\c
693 .BI "-T" "commandfile"\c
698 \&; supported for compatibility with
703 Prints names of input files as \c
711 \& to be entered in the output file as an undefined symbol.
712 This may, for example, trigger linking of additional modules from
713 standard libraries. \c
715 \& may be repeated with different option
716 arguments to enter additional undefined symbols.
720 For anything other than C++ programs, this option is equivalent to
723 \&: it generates relocatable output\(em\&i.e., an output file that can in
724 turn serve as input to \c
726 \&. When linking C++ programs, \c
731 \& resolve references to constructors, unlike \c
737 Display the version number for \c
739 and list the supported emulations.
740 Print which input files can and can not be opened.
744 Display the version number for \c
747 Print which input files can and can not be opened.
755 \& is also specified, delete only local symbols
766 \& is also specified, delete all local symbols,
767 not just those beginning with `\|\c
775 You can change the behavior of
777 \& with the environment variable \c
783 \& determines the input-file object format if you don't
786 \& (or its synonym \c
788 \&). Its value should be one
789 of the BFD names for an input format. If there is no
792 \& in the environment, \c
794 \& uses the natural format
799 \& then BFD attempts to discover the
800 input format by examining binary input files; this method often
801 succeeds, but there are potential ambiguities, since there is no method
802 of ensuring that the magic number used to flag object-file formats is
803 unique. However, the configuration procedure for BFD on each system
804 places the conventional format for that system first in the search-list,
805 so ambiguities are resolved in favor of convention.
814 .RB "`\|" ld "\|' and `\|" binutils "\|'"
820 , Steve Chamberlain and Roland Pesch;
822 The GNU Binary Utilities\c
826 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
828 Permission is granted to make and distribute verbatim copies of
829 this manual provided the copyright notice and this permission notice
830 are preserved on all copies.
832 Permission is granted to copy and distribute modified versions of this
833 manual under the conditions for verbatim copying, provided that the
834 entire resulting derived work is distributed under the terms of a
835 permission notice identical to this one.
837 Permission is granted to copy and distribute translations of this
838 manual into another language, under the above conditions for modified
839 versions, except that this permission notice may be included in
840 translations approved by the Free Software Foundation instead of in
841 the original English.