1 .\" Copyright (c) 1991, 92, 93, 94, 95, 1996 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 "\|]"
31 .RB "[\|" \-Bdynamic "\|]"
32 .RB "[\|" \-Bsymbolic "\|]"
36 .RB "[\|" \-\-cref "\|]"
37 .RB "[\|" \-d | \-dc | \-dp\c
40 .RB "[\|" "\-defsym\ "\c
48 .RB "[\|" \-embedded\-relocs "\|]"
50 .RB "[\|" \-export\-dynamic "\|]"
54 .RB "[\|" "\-\-auxiliary\ "\c
60 .RB "[\|" "\-\-filter\ "\c
63 .RB "[\|" "\-format\ "\c
73 .RB "[\|" "\-soname\ "\c
76 .RB "[\|" \-\-help "\|]"
91 .RB "[\|" \-n | \-N "\|]"
92 .RB "[\|" \-noinhibit-exec "\|]"
93 .RB "[\|" \-no\-keep\-memory "\|]"
94 .RB "[\|" "\-oformat\ "\c
100 .RB "[\|" \-relax "\|]"
101 .RB "[\|" \-r | \-Ur "\|]"
102 .RB "[\|" "\-rpath\ "\c
105 .RB "[\|" "\-rpath\-link\ "\c
110 .RB "[\|" \-shared "\|]"
111 .RB "[\|" \-sort\-common "\|]"
112 .RB "[\|" "\-split\-by\-reloc\ "\c
115 .RB "[\|" \-split\-by\-file "\|]"
119 .RB "[\|" "\-Ttext\ "\c
122 .RB "[\|" "\-Tdata\ "\c
125 .RB "[\|" "\-Tbss\ "\c
134 .RB "[\|" \-\-verbose "\|]"
135 .RB "[\|" \-\-version "\|]"
136 .RB "[\|" \-warn\-common "\|]"
137 .RB "[\|" \-warn\-constructors "\|]"
138 .RB "[\|" \-warn\-multiple\-gp "\|]"
139 .RB "[\|" \-warn\-once "\|]"
140 .RB "[\|" \-warn\-section\-align "\|]"
141 .RB "[\|" \-\-whole\-archive "\|]"
142 .RB "[\|" \-\-no\-whole\-archive "\|]"
143 .RB "[\|" "\-\-wrap\ "\c
153 \& combines a number of object and archive files, relocates
154 their data and ties up symbol references. Often the last step in
155 building a new compiled program to run is a call to \c
161 \& accepts Linker Command Language files
162 to provide explicit and total control over the linking process.
163 This man page does not describe the command language; see the `\|\c
170 \&, for full details on the command language and on other aspects of
175 \& uses the general purpose BFD libraries
176 to operate on object files. This allows \c
178 \& to read, combine, and
179 write object files in many different formats\(em\&for example, COFF or
182 \&. Different formats may be linked together to produce any
183 available kind of object file. You can use `\|\c
185 \|' to get a list of formats supported on various architectures; see
188 Aside from its flexibility, the GNU linker is more helpful than other
189 linkers in providing diagnostic information. Many linkers abandon
190 execution immediately upon encountering an error; whenever possible,
193 \& continues executing, allowing you to identify other errors
194 (or, in some cases, to get an output file in spite of the error).
198 \& is meant to cover a broad range of situations,
199 and to be as compatible as possible with other linkers. As a result,
200 you have many choices to control its behavior through the command line,
201 and through environment variables.
204 The plethora of command-line options may seem intimidating, but in
205 actual practice few of them are used in any particular context.
206 For instance, a frequent use of \c
208 \& is to link standard Unix
209 object files on a standard, supported Unix system. On such a system, to
215 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
220 \& to produce a file called \c
223 result of linking the file \c
230 \& which will come from the standard search
233 The command-line options to \c
235 \& may be specified in any order, and
236 may be repeated at will. For the most part, repeating an option with a
237 different argument will either have no further effect, or override prior
238 occurrences (those further to the left on the command line) of an
241 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
246 \& (or its synonym \c
261 The list of object files to be linked together, shown as \c
264 may follow, precede, or be mixed in with command-line options; save that
267 \& argument may not be placed between an option flag and
270 Usually the linker is invoked with at least one object file, but other
271 forms of binary input files can also be specified with \c
276 \&, and the script command language. If \c
279 files at all are specified, the linker does not produce any output, and
280 issues the message `\|\c
284 Option arguments must either follow the option letter without intervening
285 whitespace, or be given as separate arguments immediately following the
286 option that requires them.
289 .BI "-A" "architecture"
290 In the current release of \c
292 \&, this option is useful only for the
293 Intel 960 family of architectures. In that \c
295 \& configuration, the
298 \& argument is one of the two-letter names identifying
299 members of the 960 family; the option specifies the desired output
300 target, and warns of any incompatible instructions in the input files.
301 It also modifies the linker's search strategy for archive libraries, to
302 support the use of libraries specific to each particular
303 architecture, by including in the search loop names suffixed with the
304 string identifying the architecture.
306 For example, if your \c
308 \& command line included `\|\c
313 \|', the linker would look (in its built-in search
314 paths, and in any paths you specify with \c
316 \&) for a library with
330 The first two possibilities would be considered in any event; the last
331 two are due to the use of `\|\c
335 Future releases of \c
337 \& may support similar functionality for
338 other architecture families.
340 You can meaningfully use \c
342 \& more than once on a command line, if
343 an architecture family allows combination of target architectures; each
344 use will add another pair of name variants to search for when \c
349 .BI "\-b " "input-format"
350 Specify the binary format for input object files that follow this option
351 on the command line. You don't usually need to specify this, as
354 \& is configured to expect as a default input format the most
355 usual format on each machine. \c
357 \& is a text string, the
358 name of a particular format supported by the BFD libraries.
363 \& has the same effect, as does the script command
366 You may want to use this option if you are linking files with an unusual
367 binary format. You can also use \c
369 \& to switch formats explicitly (when
370 linking object files of different formats), by including
375 \& before each group of object files in a
378 The default format is taken from the environment variable
380 \&. You can also define the input
381 format from a script, using the command \c
387 Do not link against shared libraries. This is only meaningful on
388 platforms for which shared libraries are supported.
392 Link against dynamic libraries. This is only meaningful on platforms
393 for which shared libraries are supported. This option is normally the
394 default on such platforms.
398 When creating a shared library, bind references to global symbols to
399 the definition within the shared library, if any. Normally, it is
400 possible for a program linked against a shared library to override the
401 definition within the shared library. This option is only meaningful
402 on ELF platforms which support shared libraries.
405 .BI "\-c " "commandfile"
408 \& to read link commands from the file
411 \&. These commands will completely override \c
414 default link format (rather than adding to it); \c
417 specify everything necessary to describe the target format.
420 You may also include a script of link commands directly in the command
421 line by bracketing it between `\|\c
429 Output a cross reference table. If a linker map file is being
430 generated, the cross reference table is printed to the map file.
431 Otherwise, it is printed on the standard output.
439 These three options are equivalent; multiple forms are supported for
440 compatibility with other linkers. Use any of them to make \c
442 assign space to common symbols even if a relocatable output file is
445 \&). The script command
447 .B FORCE_COMMON_ALLOCATION\c
448 \& has the same effect.
451 .BI "-defsym " "symbol" "\fR = \fP" expression
452 Create a global symbol in the output file, containing the absolute
455 \&. You may use this option as many
456 times as necessary to define multiple symbols in the command line. A
457 limited form of arithmetic is supported for the \c
460 context: you may give a hexadecimal constant or the name of an existing
465 \& to add or subtract hexadecimal
466 constants or symbols. If you need more elaborate expressions, consider
467 using the linker command language from a script.
474 \& as the explicit symbol for beginning execution of your
475 program, rather than the default entry point. for a
476 discussion of defaults and other ways of specifying the
480 .B \-embedded\-relocs
481 This option is only meaningful when linking MIPS embedded PIC code,
484 option to the GNU compiler and assembler. It causes the linker to
485 create a table which may be used at runtime to relocate any data which
486 was statically initialized to pointer values. See the code in
487 testsuite/ld-empic for details.
493 When creating an ELF file, add all symbols to the dynamic symbol table.
494 Normally, the dynamic symbol table contains only symbols which are used
495 by a dynamic object. This option is needed for some uses of
501 .BI "--auxiliary " "name"
502 When creating an ELF shared object, set the internal DT_AUXILIARY field
503 to the specified name. This tells the dynamic linker that the symbol
504 table of the shared object should be used as an auxiliary filter on the
505 symbol table of the shared object
511 .BI "--filter " "name"
512 When creating an ELF shared object, set the internal DT_FILTER field to
513 the specified name. This tells the dynamic linker that the symbol table
514 of the shared object should be used as a filter on the symbol table of
519 .BI "\-format " "input\-format"
528 Accepted, but ignored; provided for compatibility with other tools.
532 Set the maximum size of objects to be optimized using the GP register
535 under MIPS ECOFF. Ignored for other object file formats.
540 .BI "-soname " "name"
541 When creating an ELF shared object, set the internal DT_SONAME field to
542 the specified name. When an executable is linked with a shared object
543 which has a DT_SONAME field, then when the executable is run the dynamic
544 linker will attempt to load the shared object specified by the DT_SONAME
545 field rather than the using the file name given to the linker.
549 Print a summary of the command-line options on the standard output and exit.
552 begin with two dashes instead of one
553 for compatibility with other GNU programs. The other options start with
554 only one dash for compatibility with other linkers.
558 Perform an incremental link (same as option \c
565 Add an archive file \c
567 \& to the list of files to link. This
568 option may be used any number of times. \c
571 path-list for occurrences of \c
580 .BI "\-L" "searchdir"
581 This command adds path \c
583 \& to the list of paths that
586 \& will search for archive libraries. You may use this option
589 The default set of paths searched (without being specified with
592 \&) depends on what emulation mode \c
595 some cases also on how it was configured. The
596 paths can also be specified in a link script with the \c
602 Print (to the standard output file) a link map\(em\&diagnostic information
603 about where symbols are mapped by \c
605 \&, and information on global
606 common storage allocation.
609 .BI "\-Map " "mapfile"\c
612 a link map\(em\&diagnostic information
613 about where symbols are mapped by \c
615 \&, and information on global
616 common storage allocation.
619 .BI "\-m " "emulation"\c
622 linker. You can list the available emulations with the
626 options. This option overrides the compiled-in default, which is the
627 system for which you configured
632 specifies readable and writable \c
637 the output format supports Unix style magic numbers, the output is
642 When you use the `\|\c
644 \&\|' option, the linker does not page-align the
649 sets the text segment to be read only, and \c
656 Normally, the linker will not produce an output file if it encounters
657 errors during the link process. With this flag, you can specify that
658 you wish the output file retained even after non-fatal errors.
661 .B \-no\-keep\-memory
662 The linker normally optimizes for speed over memory usage by caching
663 the symbol tables of input files in memory. This option tells the
664 linker to instead optimize for memory usage, by rereading the symbol
665 tables as necessary. This may be required if the linker runs out of
666 memory space while linking a large executable.
671 \& is a name for the program produced by \c
674 option is not specified, the name `\|\c
676 \|' is used by default. The
679 \& can also specify the output file name.
682 .BI "\-oformat " "output\-format"
683 Specify the binary format for the output object file.
684 You don't usually need to specify this, as
687 \& is configured to produce as a default output format the most
688 usual format on each machine. \c
690 \& is a text string, the
691 name of a particular format supported by the BFD libraries.
694 can also specify the output format, but this option overrides it.
697 .BI "\-R " "filename"
698 Read symbol names and their addresses from \c
701 relocate it or include it in the output. This allows your output file
702 to refer symbolically to absolute locations of memory defined in other
707 An option with machine dependent effects. Currently this option is only
708 supported on the H8/300.
710 On some platforms, use this option to perform global optimizations that
711 become possible when the linker resolves addressing in your program, such
712 as relaxing address modes and synthesizing new instructions in the
715 On platforms where this is not supported, `\|\c
717 \&\|' is accepted, but has no effect.
721 Generates relocatable output\(em\&i.e., generate an output file that can in
722 turn serve as input to \c
724 \&. This is often called \c
727 \&. As a side effect, in environments that support standard Unix
728 magic numbers, this option also sets the output file's magic number to
732 If this option is not specified, an absolute file is produced. When
733 linking C++ programs, this option \c
735 \& resolve references to
738 \& is an alternative.
740 This option does the same as \c
745 .B \-rpath\ \fIdirectory
746 Add a directory to the runtime library search path. This is used when
747 linking an ELF executable with shared objects. All
749 arguments are concatenated and passed to the runtime linker, which uses
750 them to locate shared objects at runtime. The
752 option is also used when locating shared objects which are needed by
753 shared objects explicitly included in the link; see the description of
758 is not used when linking an ELF executable, the contents of the
761 will be used if it is defined.
765 option may also be used on SunOS. By default, on SunOS, the linker
766 will form a runtime search patch out of all the
768 options it is given. If a
770 option is used, the runtime search path will be formed exclusively
776 options. This can be useful when using gcc, which adds many
778 options which may be on NFS mounted filesystems.
781 .B \-rpath\-link\ \fIdirectory
782 When using ELF or SunOS, one shared library may require another. This
785 link includes a shared library as one of the input files.
787 When the linker encounters such a dependency when doing a non-shared,
788 non-relocateable link, it will automatically try to locate the required
789 shared library and include it in the link, if it is not included
790 explicitly. In such a case, the
792 option specifies the first set of directories to search. The
794 option may specify a sequence of directory names either by specifying
795 a list of names separated by colons, or by appearing multiple times.
797 If the required shared library is not found, the linker will issue a
798 warning and continue with the link.
802 Omits debugger symbol information (but not all symbols) from the output file.
806 Omits all symbol information from the output file.
810 Create a shared library. This is currently only supported on ELF and
811 SunOS platforms (on SunOS it is not required, as the linker will
812 automatically create a shared library when there are undefined symbols
821 places the global common symbols in the appropriate output sections,
822 it sorts them by size. First come all the one byte symbols, then all
823 the two bytes, then all the four bytes, and then everything else.
824 This is to prevent gaps between symbols due to
825 alignment constraints. This option disables that sorting.
828 .B \-split\-by\-reloc\ \fIcount
829 Trys to creates extra sections in the output file so that no single
830 output section in the file contains more than
833 This is useful when generating huge relocatable for downloading into
834 certain real time kernels with the COFF object file format; since COFF
835 cannot represent more than 65535 relocations in a single section.
836 Note that this will fail to work with object file formats which do not
837 support arbitrary sections. The linker will not split up individual
838 input sections for redistribution, so if a single input section
841 relocations one output section will contain that many relocations.
846 .B \-split\-by\-reloc
847 but creates a new output section for each input file.
850 .BI "\-Tbss " "org"\c
852 .BI "\-Tdata " "org"\c
854 .BI "\-Ttext " "org"\c
857 \& as the starting address for\(em\&respectively\(em\&the
864 \& segment of the output file.
867 \& must be a hexadecimal integer.
870 .BI "\-T " "commandfile"
875 \&; supported for compatibility with
880 Prints names of input files as \c
888 \& to be entered in the output file as an undefined symbol.
889 This may, for example, trigger linking of additional modules from
890 standard libraries. \c
892 \& may be repeated with different option
893 arguments to enter additional undefined symbols.
897 For anything other than C++ programs, this option is equivalent to
900 \&: it generates relocatable output\(em\&i.e., an output file that can in
901 turn serve as input to \c
903 \&. When linking C++ programs, \c
906 \& resolve references to constructors, unlike \c
912 Display the version number for \c
914 and list the supported emulations.
915 Display which input files can and can not be opened.
919 Display the version number for \c
924 option also lists the supported emulations.
928 Display the version number for \c
934 Warn when a common symbol is combined with another common symbol or with
935 a symbol definition. Unix linkers allow this somewhat sloppy practice,
936 but linkers on some other operating systems do not. This option allows
937 you to find potential problems from combining global symbols.
940 .B \-warn\-constructors
941 Warn if any global constructors are used. This is only useful for a
942 few object file formats. For formats like COFF or ELF, the linker can
943 not detect the use of global constructors.
946 .B \-warn\-multiple\-gp
947 Warn if the output file requires multiple global-pointer values. This
948 option is only meaningful for certain processors, such as the Alpha.
952 Only warn once for each undefined symbol, rather than once per module
956 .B \-warn\-section\-align
957 Warn if the address of an output section is changed because of
958 alignment. Typically, the alignment will be set by an input section.
959 The address will only be changed if it not explicitly specified; that
960 is, if the SECTIONS command does not specify a start address for the
964 .B \-\-whole\-archive
965 For each archive mentioned on the command line after the
966 .B \-\-whole\-archive
967 option, include every object file in the archive in the link, rather
968 than searching the archive for the required object files. This is
969 normally used to turn an archive file into a shared library, forcing
970 every object to be included in the resulting shared library.
973 .B \-\-no\-whole\-archive
974 Turn off the effect of the
975 .B \-\-whole\-archive
976 option for archives which appear later on the command line.
979 .BI "--wrap " "symbol"
980 Use a wrapper function for
982 Any undefined reference to
985 .BI "__wrap_" "symbol".
986 Any undefined reference to
987 .BI "__real_" "symbol"
993 Delete all temporary local symbols. For most targets, this is all local
994 symbols whose names begin with `\|\c
1000 Delete all local symbols.
1006 You can change the behavior of
1008 \& with the environment variable \c
1014 \& determines the input-file object format if you don't
1017 \& (or its synonym \c
1019 \&). Its value should be one
1020 of the BFD names for an input format. If there is no
1023 \& in the environment, \c
1025 \& uses the natural format
1030 \& then BFD attempts to discover the
1031 input format by examining binary input files; this method often
1032 succeeds, but there are potential ambiguities, since there is no method
1033 of ensuring that the magic number used to flag object-file formats is
1034 unique. However, the configuration procedure for BFD on each system
1035 places the conventional format for that system first in the search-list,
1036 so ambiguities are resolved in favor of convention.
1045 .RB "`\|" ld "\|' and `\|" binutils "\|'"
1050 ld: the GNU linker\c
1051 , Steve Chamberlain and Roland Pesch;
1053 The GNU Binary Utilities\c
1057 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
1059 Permission is granted to make and distribute verbatim copies of
1060 this manual provided the copyright notice and this permission notice
1061 are preserved on all copies.
1063 Permission is granted to copy and distribute modified versions of this
1064 manual under the conditions for verbatim copying, provided that the
1065 entire resulting derived work is distributed under the terms of a
1066 permission notice identical to this one.
1068 Permission is granted to copy and distribute translations of this
1069 manual into another language, under the above conditions for modified
1070 versions, except that this permission notice may be included in
1071 translations approved by the Free Software Foundation instead of in
1072 the original English.