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
67 .RB "[\|" \-n | \-N "\|]"
68 .RB "[\|" \-noinhibit-exec "\|]"
72 .RB "[\|" \-relax "\|]"
73 .RB "[\|" \-r | \-Ur "\|]"
79 .RB "[\|" "\-Ttext\ "\c
82 .RB "[\|" "\-Tdata\ "\c
85 .RB "[\|" "\-Tbss\ "\c
104 \& combines a number of object and archive files, relocates
105 their data and ties up symbol references. Often the last step in
106 building a new compiled program to run is a call to \c
112 \& accepts Linker Command Language files
113 to provide explicit and total control over the linking process.
114 This man page does not describe the command language; see the `\|\c
121 \&, for full details on the command language and on other aspects of
126 \& uses the general purpose BFD libraries
127 to operate on object files. This allows \c
129 \& to read, combine, and
130 write object files in many different formats\(em\&for example, COFF or
133 \&. Different formats may be linked together to produce any
134 available kind of object file. You can use `\|\c
136 \|' to get a list of formats supported on various architectures; see
139 Aside from its flexibility, the GNU linker is more helpful than other
140 linkers in providing diagnostic information. Many linkers abandon
141 execution immediately upon encountering an error; whenever possible,
144 \& continues executing, allowing you to identify other errors
145 (or, in some cases, to get an output file in spite of the error).
149 \& is meant to cover a broad range of situations,
150 and to be as compatible as possible with other linkers. As a result,
151 you have many choices to control its behavior through the command line,
152 and through environment variables.
155 The plethora of command-line options may seem intimidating, but in
156 actual practice few of them are used in any particular context.
157 For instance, a frequent use of \c
159 \& is to link standard Unix
160 object files on a standard, supported Unix system. On such a system, to
166 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
171 \& to produce a file called \c
174 result of linking the file \c
181 \& which will come from the standard search
184 The command-line options to \c
186 \& may be specified in any order, and
187 may be repeated at will. For the most part, repeating an option with a
188 different argument will either have no further effect, or override prior
189 occurrences (those further to the left on the command line) of an
192 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
197 \& (or its synonym \c
212 The list of object files to be linked together, shown as \c
215 may follow, precede, or be mixed in with command-line options; save that
218 \& argument may not be placed between an option flag and
221 Usually the linker is invoked with at least one object file, but other
222 forms of binary input files can also be specified with \c
227 \&, and the script command language. If \c
230 files at all are specified, the linker does not produce any output, and
231 issues the message `\|\c
235 Option arguments must either follow the option letter without intervening
236 whitespace, or be given as separate arguments immediately following the
237 option that requires them.
240 .BI "-A" "architecture"\c
242 In the current release of \c
244 \&, this option is useful only for the
245 Intel 960 family of architectures. In that \c
247 \& configuration, the
250 \& argument is one of the two-letter names identifying
251 members of the 960 family; the option specifies the desired output
252 target, and warns of any incompatible instructions in the input files.
253 It also modifies the linker's search strategy for archive libraries, to
254 support the use of libraries specific to each particular
255 architecture, by including in the search loop names suffixed with the
256 string identifying the architecture.
258 For example, if your \c
260 \& command line included `\|\c
265 \|', the linker would look (in its built-in search
266 paths, and in any paths you specify with \c
268 \&) for a library with
282 The first two possibilities would be considered in any event; the last
283 two are due to the use of `\|\c
287 Future releases of \c
289 \& may support similar functionality for
290 other architecture families.
292 You can meaningfully use \c
294 \& more than once on a command line, if
295 an architecture family allows combination of target architectures; each
296 use will add another pair of name variants to search for when \c
302 .BI "-b " "input-format"\c
304 Specify the binary format for input object files that follow this option
305 on the command line. You don't usually need to specify this, as
308 \& is configured to expect as a default input format the most
309 usual format on each machine. \c
311 \& is a text string, the
312 name of a particular format supported by the BFD libraries.
317 \& has the same effect.
319 You may want to use this option if you are linking files with an unusual
320 binary format. You can also use \c
322 \& to switch formats explicitly (when
323 linking object files of different formats), by including
328 \& before each group of object files in a
331 The default format is taken from the environment variable
333 \&. You can also define the input
334 format from a script, using the command \c
340 This flag is accepted for command-line compatibility with the SunOS linker,
341 but has no effect on \c
346 .BI "-c " "commandfile"\c
350 \& to read link commands from the file
353 \&. These commands will completely override \c
356 default link format (rather than adding to it); \c
359 specify everything necessary to describe the target format.
362 You may also include a script of link commands directly in the command
363 line by bracketing it between `\|\c
375 These three options are equivalent; multiple forms are supported for
376 compatibility with other linkers. Use any of them to make \c
379 assign space to common symbols even if a relocatable output file is
382 \&). The script command
384 .B FORCE_COMMON_ALLOCATION\c
385 \& has the same effect.
388 .BI "-defsym " "symbol"\c
392 Create a global symbol in the output file, containing the absolute
395 \&. You may use this option as many
396 times as necessary to define multiple symbols in the command line. A
397 limited form of arithmetic is supported for the \c
400 context: you may give a hexadecimal constant or the name of an existing
405 \& to add or subtract hexadecimal
406 constants or symbols. If you need more elaborate expressions, consider
407 using the linker command language from a script.
414 \& as the explicit symbol for beginning execution of your
415 program, rather than the default entry point. for a
416 discussion of defaults and other ways of specifying the
424 Some older linkers used this option throughout a compilation toolchain
425 for specifying object-file format for both input and output object
428 \&'s mechanisms (the \c
433 for input files, the \c
435 \& command in linker scripts for output
438 \& environment variable) are more flexible, but
439 but it accepts (and ignores) the \c
441 \& option flag for compatibility
442 with scripts written to call the old linker.
445 .BI "-format " "input-format"\c
455 Accepted, but ignored; provided for compatibility with other tools.
459 Set the maximum size of objects to be optimized using the GP register
462 under MIPS ECOFF. Ignored for other object file formats.
466 Perform an incremental link (same as option \c
473 Add an archive file \c
475 \& to the list of files to link. This
476 option may be used any number of times. \c
479 path-list for occurrences of \c
489 .BI "-L" "searchdir"\c
491 This command adds path \c
493 \& to the list of paths that
496 \& will search for archive libraries. You may use this option
499 The default set of paths searched (without being specified with
502 \&) depends on what emulation mode \c
505 some cases also on how it was configured. The
506 paths can also be specified in a link script with the \c
513 Print (to the standard output file) a link map\(em\&diagnostic information
514 about where symbols are mapped by \c
516 \&, and information on global
517 common storage allocation.
520 .BI "\-m " "emulation"\c
523 linker. You can list the available emulations with the
525 option. This option overrides the compiled-in default, which is the
526 system for which you configured
531 specifies readable and writable \c
536 the output format supports Unix style magic numbers, the output is
541 When you use the `\|\c
543 \&\|' option, the linker does not page-align the
548 sets the text segment to be read only, and \c
555 Normally, the linker will not produce an output file if it encounters
556 errors during the link process. With this flag, you can specify that
557 you wish the output file retained even after non-fatal errors.
566 \& is a name for the program produced by \c
569 option is not specified, the name `\|\c
571 \|' is used by default. The
574 \& can also specify the output file name.
577 .BI "-R " "filename"\c
581 Read symbol names and their addresses from \c
584 relocate it or include it in the output. This allows your output file
585 to refer symbolically to absolute locations of memory defined in other
590 An option with machine dependent effects. Currently this option is only
591 supported on the H8/300.
593 On some platforms, use this option to perform global optimizations that
594 become possible when the linker resolves addressing in your program, such
595 as relaxing address modes and synthesizing new instructions in the
598 On platforms where this is not supported, `\|\c
600 \&\|' is accepted, but has no effect.
604 Generates relocatable output\(em\&i.e., generate an output file that can in
605 turn serve as input to \c
607 \&. This is often called \c
610 \&. As a side effect, in environments that support standard Unix
611 magic numbers, this option also sets the output file's magic number to
615 If this option is not specified, an absolute file is produced. When
616 linking C++ programs, this option \c
618 \& resolve references to
621 \& is an alternative.
623 This option does the same as \c
629 Omits debugger symbol information (but not all symbols) from the output file.
633 Omits all symbol information from the output file.
636 .BI "{ " "script" " }"
637 You can, if you wish, include a script of linker commands directly in
638 the command line instead of referring to it via an input file. When the
641 \|' occurs on the command line, the linker switches to
642 interpreting the command language until the end of the list of commands
643 is reached\(em\&flagged with a closing brace `\|\c
645 \|'. Other command-line
646 options will not be recognized while parsing the script.
654 \&, for a description of the command language.
659 .BI "-Tdata " "org"\c
661 .BI "-Ttext " "org"\c
664 \& as the starting address for\(em\&respectively\(em\&the
671 \& segment of the output file.
674 \& must be a hexadecimal integer.
677 .BI "-T " "commandfile"\c
680 .BI "-T" "commandfile"\c
685 \&; supported for compatibility with
690 Prints names of input files as \c
698 \& to be entered in the output file as an undefined symbol.
699 This may, for example, trigger linking of additional modules from
700 standard libraries. \c
702 \& may be repeated with different option
703 arguments to enter additional undefined symbols.
707 For anything other than C++ programs, this option is equivalent to
710 \&: it generates relocatable output\(em\&i.e., an output file that can in
711 turn serve as input to \c
713 \&. When linking C++ programs, \c
718 \& resolve references to constructors, unlike \c
724 Display the version number for \c
726 and list the supported emulations.
727 Print which input files can and can not be opened.
731 Display the version number for \c
734 Print which input files can and can not be opened.
742 \& is also specified, delete only local symbols
753 \& is also specified, delete all local symbols,
754 not just those beginning with `\|\c
762 You can change the behavior of
764 \& with the environment variable \c
770 \& determines the input-file object format if you don't
773 \& (or its synonym \c
775 \&). Its value should be one
776 of the BFD names for an input format. If there is no
779 \& in the environment, \c
781 \& uses the natural format
786 \& then BFD attempts to discover the
787 input format by examining binary input files; this method often
788 succeeds, but there are potential ambiguities, since there is no method
789 of ensuring that the magic number used to flag object-file formats is
790 unique. However, the configuration procedure for BFD on each system
791 places the conventional format for that system first in the search-list,
792 so ambiguities are resolved in favor of convention.
801 .RB "`\|" ld "\|' and `\|" binutils "\|'"
807 , Steve Chamberlain and Roland Pesch;
809 The GNU Binary Utilities\c
813 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
815 Permission is granted to make and distribute verbatim copies of
816 this manual provided the copyright notice and this permission notice
817 are preserved on all copies.
819 Permission is granted to copy and distribute modified versions of this
820 manual under the conditions for verbatim copying, provided that the
821 entire resulting derived work is distributed under the terms of a
822 permission notice identical to this one.
824 Permission is granted to copy and distribute translations of this
825 manual into another language, under the above conditions for modified
826 versions, except that this permission notice may be included in
827 translations approved by the Free Software Foundation instead of in
828 the original English.