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
45 .RB "[\|" \-embedded\-relocs "\|]"
50 .RB "[\|" "\-format\ "\c
57 .RB "[\|" \-\-help "\|]"
72 .RB "[\|" \-n | \-N "\|]"
73 .RB "[\|" \-noinhibit-exec "\|]"
74 .RB "[\|" "\-oformat\ "\c
80 .RB "[\|" \-relax "\|]"
81 .RB "[\|" \-r | \-Ur "\|]"
84 .RB "[\|" \-sort\-common "\|]"
88 .RB "[\|" "\-Ttext\ "\c
91 .RB "[\|" "\-Tdata\ "\c
94 .RB "[\|" "\-Tbss\ "\c
103 .RB "[\|" \-\-verbose "\|]"
104 .RB "[\|" \-\-version "\|]"
105 .RB "[\|" \-warn\-common "\|]"
106 .RB "[\|" \-warn\-once "\|]"
114 \& combines a number of object and archive files, relocates
115 their data and ties up symbol references. Often the last step in
116 building a new compiled program to run is a call to \c
122 \& accepts Linker Command Language files
123 to provide explicit and total control over the linking process.
124 This man page does not describe the command language; see the `\|\c
131 \&, for full details on the command language and on other aspects of
136 \& uses the general purpose BFD libraries
137 to operate on object files. This allows \c
139 \& to read, combine, and
140 write object files in many different formats\(em\&for example, COFF or
143 \&. Different formats may be linked together to produce any
144 available kind of object file. You can use `\|\c
146 \|' to get a list of formats supported on various architectures; see
149 Aside from its flexibility, the GNU linker is more helpful than other
150 linkers in providing diagnostic information. Many linkers abandon
151 execution immediately upon encountering an error; whenever possible,
154 \& continues executing, allowing you to identify other errors
155 (or, in some cases, to get an output file in spite of the error).
159 \& is meant to cover a broad range of situations,
160 and to be as compatible as possible with other linkers. As a result,
161 you have many choices to control its behavior through the command line,
162 and through environment variables.
165 The plethora of command-line options may seem intimidating, but in
166 actual practice few of them are used in any particular context.
167 For instance, a frequent use of \c
169 \& is to link standard Unix
170 object files on a standard, supported Unix system. On such a system, to
176 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
181 \& to produce a file called \c
184 result of linking the file \c
191 \& which will come from the standard search
194 The command-line options to \c
196 \& may be specified in any order, and
197 may be repeated at will. For the most part, repeating an option with a
198 different argument will either have no further effect, or override prior
199 occurrences (those further to the left on the command line) of an
202 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
207 \& (or its synonym \c
222 The list of object files to be linked together, shown as \c
225 may follow, precede, or be mixed in with command-line options; save that
228 \& argument may not be placed between an option flag and
231 Usually the linker is invoked with at least one object file, but other
232 forms of binary input files can also be specified with \c
237 \&, and the script command language. If \c
240 files at all are specified, the linker does not produce any output, and
241 issues the message `\|\c
245 Option arguments must either follow the option letter without intervening
246 whitespace, or be given as separate arguments immediately following the
247 option that requires them.
250 .BI "-A" "architecture"\c
252 In the current release of \c
254 \&, this option is useful only for the
255 Intel 960 family of architectures. In that \c
257 \& configuration, the
260 \& argument is one of the two-letter names identifying
261 members of the 960 family; the option specifies the desired output
262 target, and warns of any incompatible instructions in the input files.
263 It also modifies the linker's search strategy for archive libraries, to
264 support the use of libraries specific to each particular
265 architecture, by including in the search loop names suffixed with the
266 string identifying the architecture.
268 For example, if your \c
270 \& command line included `\|\c
275 \|', the linker would look (in its built-in search
276 paths, and in any paths you specify with \c
278 \&) for a library with
292 The first two possibilities would be considered in any event; the last
293 two are due to the use of `\|\c
297 Future releases of \c
299 \& may support similar functionality for
300 other architecture families.
302 You can meaningfully use \c
304 \& more than once on a command line, if
305 an architecture family allows combination of target architectures; each
306 use will add another pair of name variants to search for when \c
312 .BI "\-b " "input-format"\c
314 Specify the binary format for input object files that follow this option
315 on the command line. You don't usually need to specify this, as
318 \& is configured to expect as a default input format the most
319 usual format on each machine. \c
321 \& is a text string, the
322 name of a particular format supported by the BFD libraries.
327 \& has the same effect, as does the script command
330 You may want to use this option if you are linking files with an unusual
331 binary format. You can also use \c
333 \& to switch formats explicitly (when
334 linking object files of different formats), by including
339 \& before each group of object files in a
342 The default format is taken from the environment variable
344 \&. You can also define the input
345 format from a script, using the command \c
351 This flag is accepted for command-line compatibility with the SunOS linker,
352 but has no effect on \c
357 .BI "\-c " "commandfile"\c
361 \& to read link commands from the file
364 \&. These commands will completely override \c
367 default link format (rather than adding to it); \c
370 specify everything necessary to describe the target format.
373 You may also include a script of link commands directly in the command
374 line by bracketing it between `\|\c
386 These three options are equivalent; multiple forms are supported for
387 compatibility with other linkers. Use any of them to make \c
390 assign space to common symbols even if a relocatable output file is
393 \&). The script command
395 .B FORCE_COMMON_ALLOCATION\c
396 \& has the same effect.
399 .BI "-defsym " "symbol"\c
403 Create a global symbol in the output file, containing the absolute
406 \&. You may use this option as many
407 times as necessary to define multiple symbols in the command line. A
408 limited form of arithmetic is supported for the \c
411 context: you may give a hexadecimal constant or the name of an existing
416 \& to add or subtract hexadecimal
417 constants or symbols. If you need more elaborate expressions, consider
418 using the linker command language from a script.
425 \& as the explicit symbol for beginning execution of your
426 program, rather than the default entry point. for a
427 discussion of defaults and other ways of specifying the
431 .B \-embedded\-relocs
432 This option is only meaningful when linking MIPS embedded PIC code,
435 option to the GNU compiler and assembler. It causes the linker to
436 create a table which may be used at runtime to relocate any data which
437 was statically initialized to pointer values. See the code in
438 testsuite/ld-empic for details.
445 Some older linkers used this option throughout a compilation toolchain
446 for specifying object-file format for both input and output object
449 \&'s mechanisms (the \c
454 for input files, the \c
456 \& command in linker scripts for output
459 \& environment variable) are more flexible, but
460 but it accepts (and ignores) the \c
462 \& option flag for compatibility
463 with scripts written to call the old linker.
466 .BI "\-format " "input\-format"\c
476 Accepted, but ignored; provided for compatibility with other tools.
480 Set the maximum size of objects to be optimized using the GP register
483 under MIPS ECOFF. Ignored for other object file formats.
487 Print a summary of the command-line options on the standard output and exit.
490 begin with two dashes instead of one
491 for compatibility with other GNU programs. The other options start with
492 only one dash for compatibility with other linkers.
496 Perform an incremental link (same as option \c
503 Add an archive file \c
505 \& to the list of files to link. This
506 option may be used any number of times. \c
509 path-list for occurrences of \c
519 .BI "\-L" "searchdir"\c
521 This command adds path \c
523 \& to the list of paths that
526 \& will search for archive libraries. You may use this option
529 The default set of paths searched (without being specified with
532 \&) depends on what emulation mode \c
535 some cases also on how it was configured. The
536 paths can also be specified in a link script with the \c
543 Print (to the standard output file) a link map\(em\&diagnostic information
544 about where symbols are mapped by \c
546 \&, and information on global
547 common storage allocation.
550 .BI "\-Map " "mapfile"\c
553 a link map\(em\&diagnostic information
554 about where symbols are mapped by \c
556 \&, and information on global
557 common storage allocation.
560 .BI "\-m " "emulation"\c
563 linker. You can list the available emulations with the
567 options. This option overrides the compiled-in default, which is the
568 system for which you configured
573 specifies readable and writable \c
578 the output format supports Unix style magic numbers, the output is
583 When you use the `\|\c
585 \&\|' option, the linker does not page-align the
590 sets the text segment to be read only, and \c
597 Normally, the linker will not produce an output file if it encounters
598 errors during the link process. With this flag, you can specify that
599 you wish the output file retained even after non-fatal errors.
602 .BI "\-o " "output"\c
608 \& is a name for the program produced by \c
611 option is not specified, the name `\|\c
613 \|' is used by default. The
616 \& can also specify the output file name.
619 .BI "\-oformat " "output\-format"\c
621 Specify the binary format for the output object file.
622 You don't usually need to specify this, as
625 \& is configured to produce as a default output format the most
626 usual format on each machine. \c
628 \& is a text string, the
629 name of a particular format supported by the BFD libraries.
632 can also specify the output format, but this option overrides it.
635 .BI "\-R " "filename"\c
639 Read symbol names and their addresses from \c
642 relocate it or include it in the output. This allows your output file
643 to refer symbolically to absolute locations of memory defined in other
648 An option with machine dependent effects. Currently this option is only
649 supported on the H8/300.
651 On some platforms, use this option to perform global optimizations that
652 become possible when the linker resolves addressing in your program, such
653 as relaxing address modes and synthesizing new instructions in the
656 On platforms where this is not supported, `\|\c
658 \&\|' is accepted, but has no effect.
662 Generates relocatable output\(em\&i.e., generate an output file that can in
663 turn serve as input to \c
665 \&. This is often called \c
668 \&. As a side effect, in environments that support standard Unix
669 magic numbers, this option also sets the output file's magic number to
673 If this option is not specified, an absolute file is produced. When
674 linking C++ programs, this option \c
676 \& resolve references to
679 \& is an alternative.
681 This option does the same as \c
687 Omits debugger symbol information (but not all symbols) from the output file.
691 Omits all symbol information from the output file.
697 places the global common symbols in the appropriate output sections,
698 it sorts them by size. First come all the one byte symbols, then all
699 the two bytes, then all the four bytes, and then everything else.
700 This is to prevent gaps between symbols due to
701 alignment constraints. This option disables that sorting.
704 .BI "\-Tbss " "org"\c
706 .BI "\-Tdata " "org"\c
708 .BI "\-Ttext " "org"\c
711 \& as the starting address for\(em\&respectively\(em\&the
718 \& segment of the output file.
721 \& must be a hexadecimal integer.
724 .BI "\-T " "commandfile"\c
727 .BI "\-T" "commandfile"\c
732 \&; supported for compatibility with
737 Prints names of input files as \c
745 \& to be entered in the output file as an undefined symbol.
746 This may, for example, trigger linking of additional modules from
747 standard libraries. \c
749 \& may be repeated with different option
750 arguments to enter additional undefined symbols.
754 For anything other than C++ programs, this option is equivalent to
757 \&: it generates relocatable output\(em\&i.e., an output file that can in
758 turn serve as input to \c
760 \&. When linking C++ programs, \c
765 \& resolve references to constructors, unlike \c
771 Display the version number for \c
773 and list the supported emulations.
774 Display which input files can and can not be opened.
778 Display the version number for \c
783 option also lists the supported emulations.
787 Display the version number for \c
793 Warn when a common symbol is combined with another common symbol or with
794 a symbol definition. Unix linkers allow this somewhat sloppy practice,
795 but linkers on some other operating systems do not. This option allows
796 you to find potential problems from combining global symbols.
800 Only warn once for each undefined symbol, rather than once per module
805 Delete all temporary local symbols. For most targets, this is all local
806 symbols whose names begin with `\|\c
812 Delete all local symbols.
818 You can change the behavior of
820 \& with the environment variable \c
826 \& determines the input-file object format if you don't
829 \& (or its synonym \c
831 \&). Its value should be one
832 of the BFD names for an input format. If there is no
835 \& in the environment, \c
837 \& uses the natural format
842 \& then BFD attempts to discover the
843 input format by examining binary input files; this method often
844 succeeds, but there are potential ambiguities, since there is no method
845 of ensuring that the magic number used to flag object-file formats is
846 unique. However, the configuration procedure for BFD on each system
847 places the conventional format for that system first in the search-list,
848 so ambiguities are resolved in favor of convention.
857 .RB "`\|" ld "\|' and `\|" binutils "\|'"
863 , Steve Chamberlain and Roland Pesch;
865 The GNU Binary Utilities\c
869 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
871 Permission is granted to make and distribute verbatim copies of
872 this manual provided the copyright notice and this permission notice
873 are preserved on all copies.
875 Permission is granted to copy and distribute modified versions of this
876 manual under the conditions for verbatim copying, provided that the
877 entire resulting derived work is distributed under the terms of a
878 permission notice identical to this one.
880 Permission is granted to copy and distribute translations of this
881 manual into another language, under the above conditions for modified
882 versions, except that this permission notice may be included in
883 translations approved by the Free Software Foundation instead of in
884 the original English.