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 "\|]"
83 .RB "[\|" \-sort\-common "\|]"
87 .RB "[\|" "\-Ttext\ "\c
90 .RB "[\|" "\-Tdata\ "\c
93 .RB "[\|" "\-Tbss\ "\c
102 .RB "[\|" \-\-version "\|]"
103 .RB "[\|" \-warn\-common "\|]"
111 \& combines a number of object and archive files, relocates
112 their data and ties up symbol references. Often the last step in
113 building a new compiled program to run is a call to \c
119 \& accepts Linker Command Language files
120 to provide explicit and total control over the linking process.
121 This man page does not describe the command language; see the `\|\c
128 \&, for full details on the command language and on other aspects of
133 \& uses the general purpose BFD libraries
134 to operate on object files. This allows \c
136 \& to read, combine, and
137 write object files in many different formats\(em\&for example, COFF or
140 \&. Different formats may be linked together to produce any
141 available kind of object file. You can use `\|\c
143 \|' to get a list of formats supported on various architectures; see
146 Aside from its flexibility, the GNU linker is more helpful than other
147 linkers in providing diagnostic information. Many linkers abandon
148 execution immediately upon encountering an error; whenever possible,
151 \& continues executing, allowing you to identify other errors
152 (or, in some cases, to get an output file in spite of the error).
156 \& is meant to cover a broad range of situations,
157 and to be as compatible as possible with other linkers. As a result,
158 you have many choices to control its behavior through the command line,
159 and through environment variables.
162 The plethora of command-line options may seem intimidating, but in
163 actual practice few of them are used in any particular context.
164 For instance, a frequent use of \c
166 \& is to link standard Unix
167 object files on a standard, supported Unix system. On such a system, to
173 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
178 \& to produce a file called \c
181 result of linking the file \c
188 \& which will come from the standard search
191 The command-line options to \c
193 \& may be specified in any order, and
194 may be repeated at will. For the most part, repeating an option with a
195 different argument will either have no further effect, or override prior
196 occurrences (those further to the left on the command line) of an
199 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
204 \& (or its synonym \c
219 The list of object files to be linked together, shown as \c
222 may follow, precede, or be mixed in with command-line options; save that
225 \& argument may not be placed between an option flag and
228 Usually the linker is invoked with at least one object file, but other
229 forms of binary input files can also be specified with \c
234 \&, and the script command language. If \c
237 files at all are specified, the linker does not produce any output, and
238 issues the message `\|\c
242 Option arguments must either follow the option letter without intervening
243 whitespace, or be given as separate arguments immediately following the
244 option that requires them.
247 .BI "-A" "architecture"\c
249 In the current release of \c
251 \&, this option is useful only for the
252 Intel 960 family of architectures. In that \c
254 \& configuration, the
257 \& argument is one of the two-letter names identifying
258 members of the 960 family; the option specifies the desired output
259 target, and warns of any incompatible instructions in the input files.
260 It also modifies the linker's search strategy for archive libraries, to
261 support the use of libraries specific to each particular
262 architecture, by including in the search loop names suffixed with the
263 string identifying the architecture.
265 For example, if your \c
267 \& command line included `\|\c
272 \|', the linker would look (in its built-in search
273 paths, and in any paths you specify with \c
275 \&) for a library with
289 The first two possibilities would be considered in any event; the last
290 two are due to the use of `\|\c
294 Future releases of \c
296 \& may support similar functionality for
297 other architecture families.
299 You can meaningfully use \c
301 \& more than once on a command line, if
302 an architecture family allows combination of target architectures; each
303 use will add another pair of name variants to search for when \c
309 .BI "\-b " "input-format"\c
311 Specify the binary format for input object files that follow this option
312 on the command line. You don't usually need to specify this, as
315 \& is configured to expect as a default input format the most
316 usual format on each machine. \c
318 \& is a text string, the
319 name of a particular format supported by the BFD libraries.
324 \& has the same effect, as does the script command
327 You may want to use this option if you are linking files with an unusual
328 binary format. You can also use \c
330 \& to switch formats explicitly (when
331 linking object files of different formats), by including
336 \& before each group of object files in a
339 The default format is taken from the environment variable
341 \&. You can also define the input
342 format from a script, using the command \c
348 This flag is accepted for command-line compatibility with the SunOS linker,
349 but has no effect on \c
354 .BI "\-c " "commandfile"\c
358 \& to read link commands from the file
361 \&. These commands will completely override \c
364 default link format (rather than adding to it); \c
367 specify everything necessary to describe the target format.
370 You may also include a script of link commands directly in the command
371 line by bracketing it between `\|\c
383 These three options are equivalent; multiple forms are supported for
384 compatibility with other linkers. Use any of them to make \c
387 assign space to common symbols even if a relocatable output file is
390 \&). The script command
392 .B FORCE_COMMON_ALLOCATION\c
393 \& has the same effect.
396 .BI "-defsym " "symbol"\c
400 Create a global symbol in the output file, containing the absolute
403 \&. You may use this option as many
404 times as necessary to define multiple symbols in the command line. A
405 limited form of arithmetic is supported for the \c
408 context: you may give a hexadecimal constant or the name of an existing
413 \& to add or subtract hexadecimal
414 constants or symbols. If you need more elaborate expressions, consider
415 using the linker command language from a script.
422 \& as the explicit symbol for beginning execution of your
423 program, rather than the default entry point. for a
424 discussion of defaults and other ways of specifying the
432 Some older linkers used this option throughout a compilation toolchain
433 for specifying object-file format for both input and output object
436 \&'s mechanisms (the \c
441 for input files, the \c
443 \& command in linker scripts for output
446 \& environment variable) are more flexible, but
447 but it accepts (and ignores) the \c
449 \& option flag for compatibility
450 with scripts written to call the old linker.
453 .BI "\-format " "input\-format"\c
463 Accepted, but ignored; provided for compatibility with other tools.
467 Set the maximum size of objects to be optimized using the GP register
470 under MIPS ECOFF. Ignored for other object file formats.
474 Print a summary of the command-line options on the standard output and exit.
477 begin with two dashes instead of one
478 for compatibility with other GNU programs. The other options start with
479 only one dash for compatibility with other linkers.
483 Perform an incremental link (same as option \c
490 Add an archive file \c
492 \& to the list of files to link. This
493 option may be used any number of times. \c
496 path-list for occurrences of \c
506 .BI "\-L" "searchdir"\c
508 This command adds path \c
510 \& to the list of paths that
513 \& will search for archive libraries. You may use this option
516 The default set of paths searched (without being specified with
519 \&) depends on what emulation mode \c
522 some cases also on how it was configured. The
523 paths can also be specified in a link script with the \c
530 Print (to the standard output file) a link map\(em\&diagnostic information
531 about where symbols are mapped by \c
533 \&, and information on global
534 common storage allocation.
537 .BI "\-Map " "mapfile"\c
540 a link map\(em\&diagnostic information
541 about where symbols are mapped by \c
543 \&, and information on global
544 common storage allocation.
547 .BI "\-m " "emulation"\c
550 linker. You can list the available emulations with the
552 option. This option overrides the compiled-in default, which is the
553 system for which you configured
558 specifies readable and writable \c
563 the output format supports Unix style magic numbers, the output is
568 When you use the `\|\c
570 \&\|' option, the linker does not page-align the
575 sets the text segment to be read only, and \c
582 Normally, the linker will not produce an output file if it encounters
583 errors during the link process. With this flag, you can specify that
584 you wish the output file retained even after non-fatal errors.
587 .BI "\-o " "output"\c
593 \& is a name for the program produced by \c
596 option is not specified, the name `\|\c
598 \|' is used by default. The
601 \& can also specify the output file name.
604 .BI "\-oformat " "output\-format"\c
606 Specify the binary format for the output object file.
607 You don't usually need to specify this, as
610 \& is configured to produce as a default output format the most
611 usual format on each machine. \c
613 \& is a text string, the
614 name of a particular format supported by the BFD libraries.
617 can also specify the output format, but this option overrides it.
620 .BI "\-R " "filename"\c
624 Read symbol names and their addresses from \c
627 relocate it or include it in the output. This allows your output file
628 to refer symbolically to absolute locations of memory defined in other
633 An option with machine dependent effects. Currently this option is only
634 supported on the H8/300.
636 On some platforms, use this option to perform global optimizations that
637 become possible when the linker resolves addressing in your program, such
638 as relaxing address modes and synthesizing new instructions in the
641 On platforms where this is not supported, `\|\c
643 \&\|' is accepted, but has no effect.
647 Generates relocatable output\(em\&i.e., generate an output file that can in
648 turn serve as input to \c
650 \&. This is often called \c
653 \&. As a side effect, in environments that support standard Unix
654 magic numbers, this option also sets the output file's magic number to
658 If this option is not specified, an absolute file is produced. When
659 linking C++ programs, this option \c
661 \& resolve references to
664 \& is an alternative.
666 This option does the same as \c
672 Omits debugger symbol information (but not all symbols) from the output file.
676 Omits all symbol information from the output file.
682 places the global common symbols in the appropriate output sections,
683 it sorts them by size. First come all the one byte symbols, then all
684 the two bytes, then all the four bytes, and then everything else.
685 This is to prevent gaps between symbols due to
686 alignment constraints. This option disables that sorting.
689 .BI "\-Tbss " "org"\c
691 .BI "\-Tdata " "org"\c
693 .BI "\-Ttext " "org"\c
696 \& as the starting address for\(em\&respectively\(em\&the
703 \& segment of the output file.
706 \& must be a hexadecimal integer.
709 .BI "\-T " "commandfile"\c
712 .BI "\-T" "commandfile"\c
717 \&; supported for compatibility with
722 Prints names of input files as \c
730 \& to be entered in the output file as an undefined symbol.
731 This may, for example, trigger linking of additional modules from
732 standard libraries. \c
734 \& may be repeated with different option
735 arguments to enter additional undefined symbols.
739 For anything other than C++ programs, this option is equivalent to
742 \&: it generates relocatable output\(em\&i.e., an output file that can in
743 turn serve as input to \c
745 \&. When linking C++ programs, \c
750 \& resolve references to constructors, unlike \c
756 Display the version number for \c
758 and list the supported emulations.
759 Display which input files can and can not be opened.
763 Display the version number for \c
769 Display the version number for \c
775 Warn when a common symbol is combined with another common symbol or with
776 a symbol definition. Unix linkers allow this somewhat sloppy practice,
777 but linkers on some other operating systems do not. This option allows
778 you to find potential problems from combining global symbols.
786 \& is also specified, delete only local symbols
797 \& is also specified, delete all local symbols,
798 not just those beginning with `\|\c
806 You can change the behavior of
808 \& with the environment variable \c
814 \& determines the input-file object format if you don't
817 \& (or its synonym \c
819 \&). Its value should be one
820 of the BFD names for an input format. If there is no
823 \& in the environment, \c
825 \& uses the natural format
830 \& then BFD attempts to discover the
831 input format by examining binary input files; this method often
832 succeeds, but there are potential ambiguities, since there is no method
833 of ensuring that the magic number used to flag object-file formats is
834 unique. However, the configuration procedure for BFD on each system
835 places the conventional format for that system first in the search-list,
836 so ambiguities are resolved in favor of convention.
845 .RB "`\|" ld "\|' and `\|" binutils "\|'"
851 , Steve Chamberlain and Roland Pesch;
853 The GNU Binary Utilities\c
857 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
859 Permission is granted to make and distribute verbatim copies of
860 this manual provided the copyright notice and this permission notice
861 are preserved on all copies.
863 Permission is granted to copy and distribute modified versions of this
864 manual under the conditions for verbatim copying, provided that the
865 entire resulting derived work is distributed under the terms of a
866 permission notice identical to this one.
868 Permission is granted to copy and distribute translations of this
869 manual into another language, under the above conditions for modified
870 versions, except that this permission notice may be included in
871 translations approved by the Free Software Foundation instead of in
872 the original English.