1 .\" Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 1999 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
45 .RB "[\|" \-\-demangle "\|]"
46 .RB "[\|" \-\-no\-demangle "\|]"
50 .RB "[\|" \-embedded\-relocs "\|]"
52 .RB "[\|" \-export\-dynamic "\|]"
56 .RB "[\|" "\-\-auxiliary\ "\c
62 .RB "[\|" "\-\-filter\ "\c
65 .RB "[\|" "\-format\ "\c
75 .RB "[\|" "\-soname\ "\c
78 .RB "[\|" \-\-help "\|]"
93 .RB "[\|" \-n | \-N "\|]"
94 .RB "[\|" \-noinhibit-exec "\|]"
95 .RB "[\|" \-no\-keep\-memory "\|]"
96 .RB "[\|" \-no\-warn\-mismatch "\|]"
100 .RB "[\|" "\-oformat\ "\c
106 .RB "[\|" \-relax "\|]"
107 .RB "[\|" \-r | \-Ur "\|]"
108 .RB "[\|" "\-rpath\ "\c
111 .RB "[\|" "\-rpath\-link\ "\c
116 .RB "[\|" \-shared "\|]"
117 .RB "[\|" \-sort\-common "\|]"
118 .RB "[\|" "\-split\-by\-reloc\ "\c
121 .RB "[\|" \-split\-by\-file "\|]"
125 .RB "[\|" "\-Ttext\ "\c
128 .RB "[\|" "\-Tdata\ "\c
131 .RB "[\|" "\-Tbss\ "\c
140 .RB "[\|" \-\-verbose "\|]"
141 .RB "[\|" \-\-version "\|]"
142 .RB "[\|" \-warn\-common "\|]"
143 .RB "[\|" \-warn\-constructors "\|]"
144 .RB "[\|" \-warn\-multiple\-gp "\|]"
145 .RB "[\|" \-warn\-once "\|]"
146 .RB "[\|" \-warn\-section\-align "\|]"
147 .RB "[\|" \-\-whole\-archive "\|]"
148 .RB "[\|" \-\-no\-whole\-archive "\|]"
149 .RB "[\|" "\-\-wrap\ "\c
159 \& combines a number of object and archive files, relocates
160 their data and ties up symbol references. Often the last step in
161 building a new compiled program to run is a call to \c
167 \& accepts Linker Command Language files
168 to provide explicit and total control over the linking process.
169 This man page does not describe the command language; see the `\|\c
176 \&, for full details on the command language and on other aspects of
181 \& uses the general purpose BFD libraries
182 to operate on object files. This allows \c
184 \& to read, combine, and
185 write object files in many different formats\(em\&for example, COFF or
188 \&. Different formats may be linked together to produce any
189 available kind of object file. You can use `\|\c
191 \|' to get a list of formats supported on various architectures; see
194 Aside from its flexibility, the GNU linker is more helpful than other
195 linkers in providing diagnostic information. Many linkers abandon
196 execution immediately upon encountering an error; whenever possible,
199 \& continues executing, allowing you to identify other errors
200 (or, in some cases, to get an output file in spite of the error).
204 \& is meant to cover a broad range of situations,
205 and to be as compatible as possible with other linkers. As a result,
206 you have many choices to control its behavior through the command line,
207 and through environment variables.
210 The plethora of command-line options may seem intimidating, but in
211 actual practice few of them are used in any particular context.
212 For instance, a frequent use of \c
214 \& is to link standard Unix
215 object files on a standard, supported Unix system. On such a system, to
221 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
226 \& to produce a file called \c
229 result of linking the file \c
236 \& which will come from the standard search
239 The command-line options to \c
241 \& may be specified in any order, and
242 may be repeated at will. For the most part, repeating an option with a
243 different argument will either have no further effect, or override prior
244 occurrences (those further to the left on the command line) of an
247 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
252 \& (or its synonym \c
267 The list of object files to be linked together, shown as \c
270 may follow, precede, or be mixed in with command-line options; save that
273 \& argument may not be placed between an option flag and
276 Usually the linker is invoked with at least one object file, but other
277 forms of binary input files can also be specified with \c
282 \&, and the script command language. If \c
285 files at all are specified, the linker does not produce any output, and
286 issues the message `\|\c
290 Option arguments must either follow the option letter without intervening
291 whitespace, or be given as separate arguments immediately following the
292 option that requires them.
295 .BI "-A" "architecture"
296 In the current release of \c
298 \&, this option is useful only for the
299 Intel 960 family of architectures. In that \c
301 \& configuration, the
304 \& argument is one of the two-letter names identifying
305 members of the 960 family; the option specifies the desired output
306 target, and warns of any incompatible instructions in the input files.
307 It also modifies the linker's search strategy for archive libraries, to
308 support the use of libraries specific to each particular
309 architecture, by including in the search loop names suffixed with the
310 string identifying the architecture.
312 For example, if your \c
314 \& command line included `\|\c
319 \|', the linker would look (in its built-in search
320 paths, and in any paths you specify with \c
322 \&) for a library with
336 The first two possibilities would be considered in any event; the last
337 two are due to the use of `\|\c
341 Future releases of \c
343 \& may support similar functionality for
344 other architecture families.
346 You can meaningfully use \c
348 \& more than once on a command line, if
349 an architecture family allows combination of target architectures; each
350 use will add another pair of name variants to search for when \c
355 .BI "\-b " "input-format"
356 Specify the binary format for input object files that follow this option
357 on the command line. You don't usually need to specify this, as
360 \& is configured to expect as a default input format the most
361 usual format on each machine. \c
363 \& is a text string, the
364 name of a particular format supported by the BFD libraries.
369 \& has the same effect, as does the script command
372 You may want to use this option if you are linking files with an unusual
373 binary format. You can also use \c
375 \& to switch formats explicitly (when
376 linking object files of different formats), by including
381 \& before each group of object files in a
384 The default format is taken from the environment variable
386 \&. You can also define the input
387 format from a script, using the command \c
393 Do not link against shared libraries. This is only meaningful on
394 platforms for which shared libraries are supported.
398 Link against dynamic libraries. This is only meaningful on platforms
399 for which shared libraries are supported. This option is normally the
400 default on such platforms.
404 When creating a shared library, bind references to global symbols to
405 the definition within the shared library, if any. Normally, it is
406 possible for a program linked against a shared library to override the
407 definition within the shared library. This option is only meaningful
408 on ELF platforms which support shared libraries.
411 .BI "\-c " "commandfile"
414 \& to read link commands from the file
417 \&. These commands will completely override \c
420 default link format (rather than adding to it); \c
423 specify everything necessary to describe the target format.
426 You may also include a script of link commands directly in the command
427 line by bracketing it between `\|\c
435 Output a cross reference table. If a linker map file is being
436 generated, the cross reference table is printed to the map file.
437 Otherwise, it is printed on the standard output.
445 These three options are equivalent; multiple forms are supported for
446 compatibility with other linkers. Use any of them to make \c
448 assign space to common symbols even if a relocatable output file is
451 \&). The script command
453 .B FORCE_COMMON_ALLOCATION\c
454 \& has the same effect.
457 .BI "-defsym " "symbol" "\fR = \fP" expression
458 Create a global symbol in the output file, containing the absolute
461 \&. You may use this option as many
462 times as necessary to define multiple symbols in the command line. A
463 limited form of arithmetic is supported for the \c
466 context: you may give a hexadecimal constant or the name of an existing
471 \& to add or subtract hexadecimal
472 constants or symbols. If you need more elaborate expressions, consider
473 using the linker command language from a script.
479 These options control whether to demangle symbol names in error
480 messages and other output. When the linker is told to demangle, it
481 tries to present symbol names in a readable fashion: it strips leading
482 underscores if they are used by the object file format, and converts
483 C++ mangled symbol names into user readable names. The linker will
484 demangle by default unless the environment variable
485 .B COLLECT_NO_DEMANGLE
486 is set. These options may be used to override the default.
493 \& as the explicit symbol for beginning execution of your
494 program, rather than the default entry point. See the `\|\c
499 discussion of defaults and other ways of specifying the
503 .B \-embedded\-relocs
504 This option is only meaningful when linking MIPS embedded PIC code,
507 option to the GNU compiler and assembler. It causes the linker to
508 create a table which may be used at runtime to relocate any data which
509 was statically initialized to pointer values. See the code in
510 testsuite/ld-empic for details.
516 When creating an ELF file, add all symbols to the dynamic symbol table.
517 Normally, the dynamic symbol table contains only symbols which are used
518 by a dynamic object. This option is needed for some uses of
524 .BI "--auxiliary " "name"
525 When creating an ELF shared object, set the internal DT_AUXILIARY field
526 to the specified name. This tells the dynamic linker that the symbol
527 table of the shared object should be used as an auxiliary filter on the
528 symbol table of the shared object
534 .BI "--filter " "name"
535 When creating an ELF shared object, set the internal DT_FILTER field to
536 the specified name. This tells the dynamic linker that the symbol table
537 of the shared object should be used as a filter on the symbol table of
542 .BI "\-format " "input\-format"
551 Accepted, but ignored; provided for compatibility with other tools.
555 Set the maximum size of objects to be optimized using the GP register
558 under MIPS ECOFF. Ignored for other object file formats.
563 .BI "-soname " "name"
564 When creating an ELF shared object, set the internal DT_SONAME field to
565 the specified name. When an executable is linked with a shared object
566 which has a DT_SONAME field, then when the executable is run the dynamic
567 linker will attempt to load the shared object specified by the DT_SONAME
568 field rather than the using the file name given to the linker.
572 Print a summary of the command-line options on the standard output and exit.
575 begin with two dashes instead of one
576 for compatibility with other GNU programs. The other options start with
577 only one dash for compatibility with other linkers.
581 Perform an incremental link (same as option \c
588 Add an archive file \c
590 \& to the list of files to link. This
591 option may be used any number of times. \c
594 path-list for occurrences of \c
603 .BI "\-L" "searchdir"
604 This command adds path \c
606 \& to the list of paths that
609 \& will search for archive libraries. You may use this option
612 The default set of paths searched (without being specified with
615 \&) depends on what emulation mode \c
618 some cases also on how it was configured. The
619 paths can also be specified in a link script with the \c
625 Print (to the standard output file) a link map\(em\&diagnostic information
626 about where symbols are mapped by \c
628 \&, and information on global
629 common storage allocation.
632 .BI "\-Map " "mapfile"\c
635 a link map\(em\&diagnostic information
636 about where symbols are mapped by \c
638 \&, and information on global
639 common storage allocation.
642 .BI "\-m " "emulation"\c
645 linker. You can list the available emulations with the
649 options. This option overrides the compiled-in default, which is the
650 system for which you configured
655 specifies readable and writable \c
660 the output format supports Unix style magic numbers, the output is
665 When you use the `\|\c
667 \&\|' option, the linker does not page-align the
672 sets the text segment to be read only, and \c
679 Normally, the linker will not produce an output file if it encounters
680 errors during the link process. With this flag, you can specify that
681 you wish the output file retained even after non-fatal errors.
684 .B \-no\-keep\-memory
685 The linker normally optimizes for speed over memory usage by caching
686 the symbol tables of input files in memory. This option tells the
687 linker to instead optimize for memory usage, by rereading the symbol
688 tables as necessary. This may be required if the linker runs out of
689 memory space while linking a large executable.
692 .B \-no\-warn\-mismatch
693 Normally the linker will give an error if you try to link together
694 input files that are mismatched for some reason, perhaps because they
695 have been compiled for different processors or for different
696 endiannesses. This option tells the linker that it should silently
697 permit such possible errors. This option should only be used with
698 care, in cases when you have taken some special action that ensures
699 that the linker errors are inappropriate.
704 \& is a name for the program produced by \c
707 option is not specified, the name `\|\c
709 \|' is used by default. The
712 \& can also specify the output file name.
716 Generate optimized output files. This might use significantly more
717 time and therefore probably should be enabled only for generating the
721 \& is supposed to be a numeric value. Any value greater than zero enables
725 .BI "\-oformat " "output\-format"
726 Specify the binary format for the output object file.
727 You don't usually need to specify this, as
730 \& is configured to produce as a default output format the most
731 usual format on each machine. \c
733 \& is a text string, the
734 name of a particular format supported by the BFD libraries.
737 can also specify the output format, but this option overrides it.
740 .BI "\-R " "filename"
741 Read symbol names and their addresses from \c
744 relocate it or include it in the output. This allows your output file
745 to refer symbolically to absolute locations of memory defined in other
750 An option with machine dependent effects. Currently this option is only
751 supported on the H8/300.
753 On some platforms, use this option to perform global optimizations that
754 become possible when the linker resolves addressing in your program, such
755 as relaxing address modes and synthesizing new instructions in the
758 On platforms where this is not supported, `\|\c
760 \&\|' is accepted, but has no effect.
764 Generates relocatable output\(em\&i.e., generate an output file that can in
765 turn serve as input to \c
767 \&. This is often called \c
770 \&. As a side effect, in environments that support standard Unix
771 magic numbers, this option also sets the output file's magic number to
775 If this option is not specified, an absolute file is produced. When
776 linking C++ programs, this option \c
778 \& resolve references to
781 \& is an alternative.
783 This option does the same as \c
788 .B \-rpath\ \fIdirectory
789 Add a directory to the runtime library search path. This is used when
790 linking an ELF executable with shared objects. All
792 arguments are concatenated and passed to the runtime linker, which uses
793 them to locate shared objects at runtime. The
795 option is also used when locating shared objects which are needed by
796 shared objects explicitly included in the link; see the description of
801 is not used when linking an ELF executable, the contents of the
804 will be used if it is defined.
808 option may also be used on SunOS. By default, on SunOS, the linker
809 will form a runtime search path out of all the
811 options it is given. If a
813 option is used, the runtime search path will be formed exclusively
819 options. This can be useful when using gcc, which adds many
821 options which may be on NFS mounted filesystems.
824 .B \-rpath\-link\ \fIdirectory
825 When using ELF or SunOS, one shared library may require another. This
828 link includes a shared library as one of the input files.
830 When the linker encounters such a dependency when doing a non-shared,
831 non-relocateable link, it will automatically try to locate the required
832 shared library and include it in the link, if it is not included
833 explicitly. In such a case, the
835 option specifies the first set of directories to search. The
837 option may specify a sequence of directory names either by specifying
838 a list of names separated by colons, or by appearing multiple times.
840 If the required shared library is not found, the linker will issue a
841 warning and continue with the link.
845 Omits debugger symbol information (but not all symbols) from the output file.
849 Omits all symbol information from the output file.
853 Create a shared library. This is currently only supported on ELF and
854 SunOS platforms (on SunOS it is not required, as the linker will
855 automatically create a shared library when there are undefined symbols
864 places the global common symbols in the appropriate output sections,
865 it sorts them by size. First come all the one byte symbols, then all
866 the two bytes, then all the four bytes, and then everything else.
867 This is to prevent gaps between symbols due to
868 alignment constraints. This option disables that sorting.
871 .B \-split\-by\-reloc\ \fIcount
872 Trys to creates extra sections in the output file so that no single
873 output section in the file contains more than
876 This is useful when generating huge relocatable for downloading into
877 certain real time kernels with the COFF object file format; since COFF
878 cannot represent more than 65535 relocations in a single section.
879 Note that this will fail to work with object file formats which do not
880 support arbitrary sections. The linker will not split up individual
881 input sections for redistribution, so if a single input section
884 relocations one output section will contain that many relocations.
889 .B \-split\-by\-reloc
890 but creates a new output section for each input file.
893 .BI "\-Tbss " "org"\c
895 .BI "\-Tdata " "org"\c
897 .BI "\-Ttext " "org"\c
900 \& as the starting address for\(em\&respectively\(em\&the
907 \& segment of the output file.
910 \& must be a hexadecimal integer.
913 .BI "\-T " "commandfile"
918 \&; supported for compatibility with
923 Prints names of input files as \c
931 \& to be entered in the output file as an undefined symbol.
932 This may, for example, trigger linking of additional modules from
933 standard libraries. \c
935 \& may be repeated with different option
936 arguments to enter additional undefined symbols.
940 For anything other than C++ programs, this option is equivalent to
943 \&: it generates relocatable output\(em\&i.e., an output file that can in
944 turn serve as input to \c
946 \&. When linking C++ programs, \c
949 \& resolve references to constructors, unlike \c
955 Display the version number for \c
957 and list the supported emulations.
958 Display which input files can and can not be opened.
962 Display the version number for \c
967 option also lists the supported emulations.
971 Display the version number for \c
977 Warn when a common symbol is combined with another common symbol or with
978 a symbol definition. Unix linkers allow this somewhat sloppy practice,
979 but linkers on some other operating systems do not. This option allows
980 you to find potential problems from combining global symbols.
983 .B \-warn\-constructors
984 Warn if any global constructors are used. This is only useful for a
985 few object file formats. For formats like COFF or ELF, the linker can
986 not detect the use of global constructors.
989 .B \-warn\-multiple\-gp
990 Warn if the output file requires multiple global-pointer values. This
991 option is only meaningful for certain processors, such as the Alpha.
995 Only warn once for each undefined symbol, rather than once per module
999 .B \-warn\-section\-align
1000 Warn if the address of an output section is changed because of
1001 alignment. Typically, the alignment will be set by an input section.
1002 The address will only be changed if it not explicitly specified; that
1003 is, if the SECTIONS command does not specify a start address for the
1007 .B \-\-whole\-archive
1008 For each archive mentioned on the command line after the
1009 .B \-\-whole\-archive
1010 option, include every object file in the archive in the link, rather
1011 than searching the archive for the required object files. This is
1012 normally used to turn an archive file into a shared library, forcing
1013 every object to be included in the resulting shared library.
1016 .B \-\-no\-whole\-archive
1017 Turn off the effect of the
1018 .B \-\-whole\-archive
1019 option for archives which appear later on the command line.
1022 .BI "--wrap " "symbol"
1023 Use a wrapper function for
1025 Any undefined reference to
1028 .BI "__wrap_" "symbol".
1029 Any undefined reference to
1030 .BI "__real_" "symbol"
1036 Delete all temporary local symbols. For most targets, this is all local
1037 symbols whose names begin with `\|\c
1043 Delete all local symbols.
1049 You can change the behavior of
1051 \& with the environment variable \c
1057 \& determines the input-file object format if you don't
1060 \& (or its synonym \c
1062 \&). Its value should be one
1063 of the BFD names for an input format. If there is no
1066 \& in the environment, \c
1068 \& uses the natural format
1073 \& then BFD attempts to discover the
1074 input format by examining binary input files; this method often
1075 succeeds, but there are potential ambiguities, since there is no method
1076 of ensuring that the magic number used to flag object-file formats is
1077 unique. However, the configuration procedure for BFD on each system
1078 places the conventional format for that system first in the search-list,
1079 so ambiguities are resolved in favor of convention.
1088 .RB "`\|" ld "\|' and `\|" binutils "\|'"
1093 ld: the GNU linker\c
1094 , Steve Chamberlain and Roland Pesch;
1096 The GNU Binary Utilities\c
1100 Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
1102 Permission is granted to make and distribute verbatim copies of
1103 this manual provided the copyright notice and this permission notice
1104 are preserved on all copies.
1106 Permission is granted to copy and distribute modified versions of this
1107 manual under the conditions for verbatim copying, provided that the
1108 entire resulting derived work is distributed under the terms of a
1109 permission notice identical to this one.
1111 Permission is granted to copy and distribute translations of this
1112 manual into another language, under the above conditions for modified
1113 versions, except that this permission notice may be included in
1114 translations approved by the Free Software Foundation instead of in
1115 the original English.