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 "\|]"
86 .RB "[\|" "\-Ttext\ "\c
89 .RB "[\|" "\-Tdata\ "\c
92 .RB "[\|" "\-Tbss\ "\c
101 .RB "[\|" \-\-version "\|]"
109 \& combines a number of object and archive files, relocates
110 their data and ties up symbol references. Often the last step in
111 building a new compiled program to run is a call to \c
117 \& accepts Linker Command Language files
118 to provide explicit and total control over the linking process.
119 This man page does not describe the command language; see the `\|\c
126 \&, for full details on the command language and on other aspects of
131 \& uses the general purpose BFD libraries
132 to operate on object files. This allows \c
134 \& to read, combine, and
135 write object files in many different formats\(em\&for example, COFF or
138 \&. Different formats may be linked together to produce any
139 available kind of object file. You can use `\|\c
141 \|' to get a list of formats supported on various architectures; see
144 Aside from its flexibility, the GNU linker is more helpful than other
145 linkers in providing diagnostic information. Many linkers abandon
146 execution immediately upon encountering an error; whenever possible,
149 \& continues executing, allowing you to identify other errors
150 (or, in some cases, to get an output file in spite of the error).
154 \& is meant to cover a broad range of situations,
155 and to be as compatible as possible with other linkers. As a result,
156 you have many choices to control its behavior through the command line,
157 and through environment variables.
160 The plethora of command-line options may seem intimidating, but in
161 actual practice few of them are used in any particular context.
162 For instance, a frequent use of \c
164 \& is to link standard Unix
165 object files on a standard, supported Unix system. On such a system, to
171 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
176 \& to produce a file called \c
179 result of linking the file \c
186 \& which will come from the standard search
189 The command-line options to \c
191 \& may be specified in any order, and
192 may be repeated at will. For the most part, repeating an option with a
193 different argument will either have no further effect, or override prior
194 occurrences (those further to the left on the command line) of an
197 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
202 \& (or its synonym \c
217 The list of object files to be linked together, shown as \c
220 may follow, precede, or be mixed in with command-line options; save that
223 \& argument may not be placed between an option flag and
226 Usually the linker is invoked with at least one object file, but other
227 forms of binary input files can also be specified with \c
232 \&, and the script command language. If \c
235 files at all are specified, the linker does not produce any output, and
236 issues the message `\|\c
240 Option arguments must either follow the option letter without intervening
241 whitespace, or be given as separate arguments immediately following the
242 option that requires them.
245 .BI "-A" "architecture"\c
247 In the current release of \c
249 \&, this option is useful only for the
250 Intel 960 family of architectures. In that \c
252 \& configuration, the
255 \& argument is one of the two-letter names identifying
256 members of the 960 family; the option specifies the desired output
257 target, and warns of any incompatible instructions in the input files.
258 It also modifies the linker's search strategy for archive libraries, to
259 support the use of libraries specific to each particular
260 architecture, by including in the search loop names suffixed with the
261 string identifying the architecture.
263 For example, if your \c
265 \& command line included `\|\c
270 \|', the linker would look (in its built-in search
271 paths, and in any paths you specify with \c
273 \&) for a library with
287 The first two possibilities would be considered in any event; the last
288 two are due to the use of `\|\c
292 Future releases of \c
294 \& may support similar functionality for
295 other architecture families.
297 You can meaningfully use \c
299 \& more than once on a command line, if
300 an architecture family allows combination of target architectures; each
301 use will add another pair of name variants to search for when \c
307 .BI "-b " "input-format"\c
309 Specify the binary format for input object files that follow this option
310 on the command line. You don't usually need to specify this, as
313 \& is configured to expect as a default input format the most
314 usual format on each machine. \c
316 \& is a text string, the
317 name of a particular format supported by the BFD libraries.
322 \& has the same effect, as does the script command
325 You may want to use this option if you are linking files with an unusual
326 binary format. You can also use \c
328 \& to switch formats explicitly (when
329 linking object files of different formats), by including
334 \& before each group of object files in a
337 The default format is taken from the environment variable
339 \&. You can also define the input
340 format from a script, using the command \c
346 This flag is accepted for command-line compatibility with the SunOS linker,
347 but has no effect on \c
352 .BI "-c " "commandfile"\c
356 \& to read link commands from the file
359 \&. These commands will completely override \c
362 default link format (rather than adding to it); \c
365 specify everything necessary to describe the target format.
368 You may also include a script of link commands directly in the command
369 line by bracketing it between `\|\c
381 These three options are equivalent; multiple forms are supported for
382 compatibility with other linkers. Use any of them to make \c
385 assign space to common symbols even if a relocatable output file is
388 \&). The script command
390 .B FORCE_COMMON_ALLOCATION\c
391 \& has the same effect.
394 .BI "-defsym " "symbol"\c
398 Create a global symbol in the output file, containing the absolute
401 \&. You may use this option as many
402 times as necessary to define multiple symbols in the command line. A
403 limited form of arithmetic is supported for the \c
406 context: you may give a hexadecimal constant or the name of an existing
411 \& to add or subtract hexadecimal
412 constants or symbols. If you need more elaborate expressions, consider
413 using the linker command language from a script.
420 \& as the explicit symbol for beginning execution of your
421 program, rather than the default entry point. for a
422 discussion of defaults and other ways of specifying the
430 Some older linkers used this option throughout a compilation toolchain
431 for specifying object-file format for both input and output object
434 \&'s mechanisms (the \c
439 for input files, the \c
441 \& command in linker scripts for output
444 \& environment variable) are more flexible, but
445 but it accepts (and ignores) the \c
447 \& option flag for compatibility
448 with scripts written to call the old linker.
451 .BI "-format " "input-format"\c
461 Accepted, but ignored; provided for compatibility with other tools.
465 Set the maximum size of objects to be optimized using the GP register
468 under MIPS ECOFF. Ignored for other object file formats.
472 Print a summary of the command-line options on the standard output and exit.
475 begin with two dashes instead of one
476 for compatibility with other GNU programs. The other options start with
477 only one dash for compatibility with other linkers.
481 Perform an incremental link (same as option \c
488 Add an archive file \c
490 \& to the list of files to link. This
491 option may be used any number of times. \c
494 path-list for occurrences of \c
504 .BI "-L" "searchdir"\c
506 This command adds path \c
508 \& to the list of paths that
511 \& will search for archive libraries. You may use this option
514 The default set of paths searched (without being specified with
517 \&) depends on what emulation mode \c
520 some cases also on how it was configured. The
521 paths can also be specified in a link script with the \c
528 Print (to the standard output file) a link map\(em\&diagnostic information
529 about where symbols are mapped by \c
531 \&, and information on global
532 common storage allocation.
535 .BI "\-Map " "mapfile"\c
538 a link map\(em\&diagnostic information
539 about where symbols are mapped by \c
541 \&, and information on global
542 common storage allocation.
545 .BI "\-m " "emulation"\c
548 linker. You can list the available emulations with the
550 option. This option overrides the compiled-in default, which is the
551 system for which you configured
556 specifies readable and writable \c
561 the output format supports Unix style magic numbers, the output is
566 When you use the `\|\c
568 \&\|' option, the linker does not page-align the
573 sets the text segment to be read only, and \c
580 Normally, the linker will not produce an output file if it encounters
581 errors during the link process. With this flag, you can specify that
582 you wish the output file retained even after non-fatal errors.
591 \& is a name for the program produced by \c
594 option is not specified, the name `\|\c
596 \|' is used by default. The
599 \& can also specify the output file name.
602 .BI "-oformat " "output-format"\c
604 Specify the binary format for the output object file.
605 You don't usually need to specify this, as
608 \& is configured to produce as a default output format the most
609 usual format on each machine. \c
611 \& is a text string, the
612 name of a particular format supported by the BFD libraries.
615 can also specify the output format, but this option overrides it.
618 .BI "-R " "filename"\c
622 Read symbol names and their addresses from \c
625 relocate it or include it in the output. This allows your output file
626 to refer symbolically to absolute locations of memory defined in other
631 An option with machine dependent effects. Currently this option is only
632 supported on the H8/300.
634 On some platforms, use this option to perform global optimizations that
635 become possible when the linker resolves addressing in your program, such
636 as relaxing address modes and synthesizing new instructions in the
639 On platforms where this is not supported, `\|\c
641 \&\|' is accepted, but has no effect.
645 Generates relocatable output\(em\&i.e., generate an output file that can in
646 turn serve as input to \c
648 \&. This is often called \c
651 \&. As a side effect, in environments that support standard Unix
652 magic numbers, this option also sets the output file's magic number to
656 If this option is not specified, an absolute file is produced. When
657 linking C++ programs, this option \c
659 \& resolve references to
662 \& is an alternative.
664 This option does the same as \c
670 Omits debugger symbol information (but not all symbols) from the output file.
674 Omits all symbol information from the output file.
679 .BI "-Tdata " "org"\c
681 .BI "-Ttext " "org"\c
684 \& as the starting address for\(em\&respectively\(em\&the
691 \& segment of the output file.
694 \& must be a hexadecimal integer.
697 .BI "-T " "commandfile"\c
700 .BI "-T" "commandfile"\c
705 \&; supported for compatibility with
710 Prints names of input files as \c
718 \& to be entered in the output file as an undefined symbol.
719 This may, for example, trigger linking of additional modules from
720 standard libraries. \c
722 \& may be repeated with different option
723 arguments to enter additional undefined symbols.
727 For anything other than C++ programs, this option is equivalent to
730 \&: it generates relocatable output\(em\&i.e., an output file that can in
731 turn serve as input to \c
733 \&. When linking C++ programs, \c
738 \& resolve references to constructors, unlike \c
744 Display the version number for \c
746 and list the supported emulations.
747 Display which input files can and can not be opened.
751 Display the version number for \c
757 Display the version number for \c
767 \& is also specified, delete only local symbols
778 \& is also specified, delete all local symbols,
779 not just those beginning with `\|\c
787 You can change the behavior of
789 \& with the environment variable \c
795 \& determines the input-file object format if you don't
798 \& (or its synonym \c
800 \&). Its value should be one
801 of the BFD names for an input format. If there is no
804 \& in the environment, \c
806 \& uses the natural format
811 \& then BFD attempts to discover the
812 input format by examining binary input files; this method often
813 succeeds, but there are potential ambiguities, since there is no method
814 of ensuring that the magic number used to flag object-file formats is
815 unique. However, the configuration procedure for BFD on each system
816 places the conventional format for that system first in the search-list,
817 so ambiguities are resolved in favor of convention.
826 .RB "`\|" ld "\|' and `\|" binutils "\|'"
832 , Steve Chamberlain and Roland Pesch;
834 The GNU Binary Utilities\c
838 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
840 Permission is granted to make and distribute verbatim copies of
841 this manual provided the copyright notice and this permission notice
842 are preserved on all copies.
844 Permission is granted to copy and distribute modified versions of this
845 manual under the conditions for verbatim copying, provided that the
846 entire resulting derived work is distributed under the terms of a
847 permission notice identical to this one.
849 Permission is granted to copy and distribute translations of this
850 manual into another language, under the above conditions for modified
851 versions, except that this permission notice may be included in
852 translations approved by the Free Software Foundation instead of in
853 the original English.