1 .\" Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 1998 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 "[\|" \-no\-warn\-mismatch "\|]"
98 .RB "[\|" "\-oformat\ "\c
104 .RB "[\|" \-relax "\|]"
105 .RB "[\|" \-r | \-Ur "\|]"
106 .RB "[\|" "\-rpath\ "\c
109 .RB "[\|" "\-rpath\-link\ "\c
114 .RB "[\|" \-shared "\|]"
115 .RB "[\|" \-sort\-common "\|]"
116 .RB "[\|" "\-split\-by\-reloc\ "\c
119 .RB "[\|" \-split\-by\-file "\|]"
123 .RB "[\|" "\-Ttext\ "\c
126 .RB "[\|" "\-Tdata\ "\c
129 .RB "[\|" "\-Tbss\ "\c
138 .RB "[\|" \-\-verbose "\|]"
139 .RB "[\|" \-\-version "\|]"
140 .RB "[\|" \-warn\-common "\|]"
141 .RB "[\|" \-warn\-constructors "\|]"
142 .RB "[\|" \-warn\-multiple\-gp "\|]"
143 .RB "[\|" \-warn\-once "\|]"
144 .RB "[\|" \-warn\-section\-align "\|]"
145 .RB "[\|" \-\-whole\-archive "\|]"
146 .RB "[\|" \-\-no\-whole\-archive "\|]"
147 .RB "[\|" "\-\-wrap\ "\c
157 \& combines a number of object and archive files, relocates
158 their data and ties up symbol references. Often the last step in
159 building a new compiled program to run is a call to \c
165 \& accepts Linker Command Language files
166 to provide explicit and total control over the linking process.
167 This man page does not describe the command language; see the `\|\c
174 \&, for full details on the command language and on other aspects of
179 \& uses the general purpose BFD libraries
180 to operate on object files. This allows \c
182 \& to read, combine, and
183 write object files in many different formats\(em\&for example, COFF or
186 \&. Different formats may be linked together to produce any
187 available kind of object file. You can use `\|\c
189 \|' to get a list of formats supported on various architectures; see
192 Aside from its flexibility, the GNU linker is more helpful than other
193 linkers in providing diagnostic information. Many linkers abandon
194 execution immediately upon encountering an error; whenever possible,
197 \& continues executing, allowing you to identify other errors
198 (or, in some cases, to get an output file in spite of the error).
202 \& is meant to cover a broad range of situations,
203 and to be as compatible as possible with other linkers. As a result,
204 you have many choices to control its behavior through the command line,
205 and through environment variables.
208 The plethora of command-line options may seem intimidating, but in
209 actual practice few of them are used in any particular context.
210 For instance, a frequent use of \c
212 \& is to link standard Unix
213 object files on a standard, supported Unix system. On such a system, to
219 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
224 \& to produce a file called \c
227 result of linking the file \c
234 \& which will come from the standard search
237 The command-line options to \c
239 \& may be specified in any order, and
240 may be repeated at will. For the most part, repeating an option with a
241 different argument will either have no further effect, or override prior
242 occurrences (those further to the left on the command line) of an
245 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
250 \& (or its synonym \c
265 The list of object files to be linked together, shown as \c
268 may follow, precede, or be mixed in with command-line options; save that
271 \& argument may not be placed between an option flag and
274 Usually the linker is invoked with at least one object file, but other
275 forms of binary input files can also be specified with \c
280 \&, and the script command language. If \c
283 files at all are specified, the linker does not produce any output, and
284 issues the message `\|\c
288 Option arguments must either follow the option letter without intervening
289 whitespace, or be given as separate arguments immediately following the
290 option that requires them.
293 .BI "-A" "architecture"
294 In the current release of \c
296 \&, this option is useful only for the
297 Intel 960 family of architectures. In that \c
299 \& configuration, the
302 \& argument is one of the two-letter names identifying
303 members of the 960 family; the option specifies the desired output
304 target, and warns of any incompatible instructions in the input files.
305 It also modifies the linker's search strategy for archive libraries, to
306 support the use of libraries specific to each particular
307 architecture, by including in the search loop names suffixed with the
308 string identifying the architecture.
310 For example, if your \c
312 \& command line included `\|\c
317 \|', the linker would look (in its built-in search
318 paths, and in any paths you specify with \c
320 \&) for a library with
334 The first two possibilities would be considered in any event; the last
335 two are due to the use of `\|\c
339 Future releases of \c
341 \& may support similar functionality for
342 other architecture families.
344 You can meaningfully use \c
346 \& more than once on a command line, if
347 an architecture family allows combination of target architectures; each
348 use will add another pair of name variants to search for when \c
353 .BI "\-b " "input-format"
354 Specify the binary format for input object files that follow this option
355 on the command line. You don't usually need to specify this, as
358 \& is configured to expect as a default input format the most
359 usual format on each machine. \c
361 \& is a text string, the
362 name of a particular format supported by the BFD libraries.
367 \& has the same effect, as does the script command
370 You may want to use this option if you are linking files with an unusual
371 binary format. You can also use \c
373 \& to switch formats explicitly (when
374 linking object files of different formats), by including
379 \& before each group of object files in a
382 The default format is taken from the environment variable
384 \&. You can also define the input
385 format from a script, using the command \c
391 Do not link against shared libraries. This is only meaningful on
392 platforms for which shared libraries are supported.
396 Link against dynamic libraries. This is only meaningful on platforms
397 for which shared libraries are supported. This option is normally the
398 default on such platforms.
402 When creating a shared library, bind references to global symbols to
403 the definition within the shared library, if any. Normally, it is
404 possible for a program linked against a shared library to override the
405 definition within the shared library. This option is only meaningful
406 on ELF platforms which support shared libraries.
409 .BI "\-c " "commandfile"
412 \& to read link commands from the file
415 \&. These commands will completely override \c
418 default link format (rather than adding to it); \c
421 specify everything necessary to describe the target format.
424 You may also include a script of link commands directly in the command
425 line by bracketing it between `\|\c
433 Output a cross reference table. If a linker map file is being
434 generated, the cross reference table is printed to the map file.
435 Otherwise, it is printed on the standard output.
443 These three options are equivalent; multiple forms are supported for
444 compatibility with other linkers. Use any of them to make \c
446 assign space to common symbols even if a relocatable output file is
449 \&). The script command
451 .B FORCE_COMMON_ALLOCATION\c
452 \& has the same effect.
455 .BI "-defsym " "symbol" "\fR = \fP" expression
456 Create a global symbol in the output file, containing the absolute
459 \&. You may use this option as many
460 times as necessary to define multiple symbols in the command line. A
461 limited form of arithmetic is supported for the \c
464 context: you may give a hexadecimal constant or the name of an existing
469 \& to add or subtract hexadecimal
470 constants or symbols. If you need more elaborate expressions, consider
471 using the linker command language from a script.
478 \& as the explicit symbol for beginning execution of your
479 program, rather than the default entry point. See the `\|\c
484 discussion of defaults and other ways of specifying the
488 .B \-embedded\-relocs
489 This option is only meaningful when linking MIPS embedded PIC code,
492 option to the GNU compiler and assembler. It causes the linker to
493 create a table which may be used at runtime to relocate any data which
494 was statically initialized to pointer values. See the code in
495 testsuite/ld-empic for details.
501 When creating an ELF file, add all symbols to the dynamic symbol table.
502 Normally, the dynamic symbol table contains only symbols which are used
503 by a dynamic object. This option is needed for some uses of
509 .BI "--auxiliary " "name"
510 When creating an ELF shared object, set the internal DT_AUXILIARY field
511 to the specified name. This tells the dynamic linker that the symbol
512 table of the shared object should be used as an auxiliary filter on the
513 symbol table of the shared object
519 .BI "--filter " "name"
520 When creating an ELF shared object, set the internal DT_FILTER field to
521 the specified name. This tells the dynamic linker that the symbol table
522 of the shared object should be used as a filter on the symbol table of
527 .BI "\-format " "input\-format"
536 Accepted, but ignored; provided for compatibility with other tools.
540 Set the maximum size of objects to be optimized using the GP register
543 under MIPS ECOFF. Ignored for other object file formats.
548 .BI "-soname " "name"
549 When creating an ELF shared object, set the internal DT_SONAME field to
550 the specified name. When an executable is linked with a shared object
551 which has a DT_SONAME field, then when the executable is run the dynamic
552 linker will attempt to load the shared object specified by the DT_SONAME
553 field rather than the using the file name given to the linker.
557 Print a summary of the command-line options on the standard output and exit.
560 begin with two dashes instead of one
561 for compatibility with other GNU programs. The other options start with
562 only one dash for compatibility with other linkers.
566 Perform an incremental link (same as option \c
573 Add an archive file \c
575 \& to the list of files to link. This
576 option may be used any number of times. \c
579 path-list for occurrences of \c
588 .BI "\-L" "searchdir"
589 This command adds path \c
591 \& to the list of paths that
594 \& will search for archive libraries. You may use this option
597 The default set of paths searched (without being specified with
600 \&) depends on what emulation mode \c
603 some cases also on how it was configured. The
604 paths can also be specified in a link script with the \c
610 Print (to the standard output file) a link map\(em\&diagnostic information
611 about where symbols are mapped by \c
613 \&, and information on global
614 common storage allocation.
617 .BI "\-Map " "mapfile"\c
620 a link map\(em\&diagnostic information
621 about where symbols are mapped by \c
623 \&, and information on global
624 common storage allocation.
627 .BI "\-m " "emulation"\c
630 linker. You can list the available emulations with the
634 options. This option overrides the compiled-in default, which is the
635 system for which you configured
640 specifies readable and writable \c
645 the output format supports Unix style magic numbers, the output is
650 When you use the `\|\c
652 \&\|' option, the linker does not page-align the
657 sets the text segment to be read only, and \c
664 Normally, the linker will not produce an output file if it encounters
665 errors during the link process. With this flag, you can specify that
666 you wish the output file retained even after non-fatal errors.
669 .B \-no\-keep\-memory
670 The linker normally optimizes for speed over memory usage by caching
671 the symbol tables of input files in memory. This option tells the
672 linker to instead optimize for memory usage, by rereading the symbol
673 tables as necessary. This may be required if the linker runs out of
674 memory space while linking a large executable.
677 .B \-no\-warn\-mismatch
678 Normally the linker will give an error if you try to link together
679 input files that are mismatched for some reason, perhaps because they
680 have been compiled for different processors or for different
681 endiannesses. This option tells the linker that it should silently
682 permit such possible errors. This option should only be used with
683 care, in cases when you have taken some special action that ensures
684 that the linker errors are inappropriate.
689 \& is a name for the program produced by \c
692 option is not specified, the name `\|\c
694 \|' is used by default. The
697 \& can also specify the output file name.
701 Generate optimized output files. This might use significantly more
702 time and therefore probably should be enabled only for generating the
706 \& is supposed to be a numeric value. Any value greater than zero enables
710 .BI "\-oformat " "output\-format"
711 Specify the binary format for the output object file.
712 You don't usually need to specify this, as
715 \& is configured to produce as a default output format the most
716 usual format on each machine. \c
718 \& is a text string, the
719 name of a particular format supported by the BFD libraries.
722 can also specify the output format, but this option overrides it.
725 .BI "\-R " "filename"
726 Read symbol names and their addresses from \c
729 relocate it or include it in the output. This allows your output file
730 to refer symbolically to absolute locations of memory defined in other
735 An option with machine dependent effects. Currently this option is only
736 supported on the H8/300.
738 On some platforms, use this option to perform global optimizations that
739 become possible when the linker resolves addressing in your program, such
740 as relaxing address modes and synthesizing new instructions in the
743 On platforms where this is not supported, `\|\c
745 \&\|' is accepted, but has no effect.
749 Generates relocatable output\(em\&i.e., generate an output file that can in
750 turn serve as input to \c
752 \&. This is often called \c
755 \&. As a side effect, in environments that support standard Unix
756 magic numbers, this option also sets the output file's magic number to
760 If this option is not specified, an absolute file is produced. When
761 linking C++ programs, this option \c
763 \& resolve references to
766 \& is an alternative.
768 This option does the same as \c
773 .B \-rpath\ \fIdirectory
774 Add a directory to the runtime library search path. This is used when
775 linking an ELF executable with shared objects. All
777 arguments are concatenated and passed to the runtime linker, which uses
778 them to locate shared objects at runtime. The
780 option is also used when locating shared objects which are needed by
781 shared objects explicitly included in the link; see the description of
786 is not used when linking an ELF executable, the contents of the
789 will be used if it is defined.
793 option may also be used on SunOS. By default, on SunOS, the linker
794 will form a runtime search path out of all the
796 options it is given. If a
798 option is used, the runtime search path will be formed exclusively
804 options. This can be useful when using gcc, which adds many
806 options which may be on NFS mounted filesystems.
809 .B \-rpath\-link\ \fIdirectory
810 When using ELF or SunOS, one shared library may require another. This
813 link includes a shared library as one of the input files.
815 When the linker encounters such a dependency when doing a non-shared,
816 non-relocateable link, it will automatically try to locate the required
817 shared library and include it in the link, if it is not included
818 explicitly. In such a case, the
820 option specifies the first set of directories to search. The
822 option may specify a sequence of directory names either by specifying
823 a list of names separated by colons, or by appearing multiple times.
825 If the required shared library is not found, the linker will issue a
826 warning and continue with the link.
830 Omits debugger symbol information (but not all symbols) from the output file.
834 Omits all symbol information from the output file.
838 Create a shared library. This is currently only supported on ELF and
839 SunOS platforms (on SunOS it is not required, as the linker will
840 automatically create a shared library when there are undefined symbols
849 places the global common symbols in the appropriate output sections,
850 it sorts them by size. First come all the one byte symbols, then all
851 the two bytes, then all the four bytes, and then everything else.
852 This is to prevent gaps between symbols due to
853 alignment constraints. This option disables that sorting.
856 .B \-split\-by\-reloc\ \fIcount
857 Trys to creates extra sections in the output file so that no single
858 output section in the file contains more than
861 This is useful when generating huge relocatable for downloading into
862 certain real time kernels with the COFF object file format; since COFF
863 cannot represent more than 65535 relocations in a single section.
864 Note that this will fail to work with object file formats which do not
865 support arbitrary sections. The linker will not split up individual
866 input sections for redistribution, so if a single input section
869 relocations one output section will contain that many relocations.
874 .B \-split\-by\-reloc
875 but creates a new output section for each input file.
878 .BI "\-Tbss " "org"\c
880 .BI "\-Tdata " "org"\c
882 .BI "\-Ttext " "org"\c
885 \& as the starting address for\(em\&respectively\(em\&the
892 \& segment of the output file.
895 \& must be a hexadecimal integer.
898 .BI "\-T " "commandfile"
903 \&; supported for compatibility with
908 Prints names of input files as \c
916 \& to be entered in the output file as an undefined symbol.
917 This may, for example, trigger linking of additional modules from
918 standard libraries. \c
920 \& may be repeated with different option
921 arguments to enter additional undefined symbols.
925 For anything other than C++ programs, this option is equivalent to
928 \&: it generates relocatable output\(em\&i.e., an output file that can in
929 turn serve as input to \c
931 \&. When linking C++ programs, \c
934 \& resolve references to constructors, unlike \c
940 Display the version number for \c
942 and list the supported emulations.
943 Display which input files can and can not be opened.
947 Display the version number for \c
952 option also lists the supported emulations.
956 Display the version number for \c
962 Warn when a common symbol is combined with another common symbol or with
963 a symbol definition. Unix linkers allow this somewhat sloppy practice,
964 but linkers on some other operating systems do not. This option allows
965 you to find potential problems from combining global symbols.
968 .B \-warn\-constructors
969 Warn if any global constructors are used. This is only useful for a
970 few object file formats. For formats like COFF or ELF, the linker can
971 not detect the use of global constructors.
974 .B \-warn\-multiple\-gp
975 Warn if the output file requires multiple global-pointer values. This
976 option is only meaningful for certain processors, such as the Alpha.
980 Only warn once for each undefined symbol, rather than once per module
984 .B \-warn\-section\-align
985 Warn if the address of an output section is changed because of
986 alignment. Typically, the alignment will be set by an input section.
987 The address will only be changed if it not explicitly specified; that
988 is, if the SECTIONS command does not specify a start address for the
992 .B \-\-whole\-archive
993 For each archive mentioned on the command line after the
994 .B \-\-whole\-archive
995 option, include every object file in the archive in the link, rather
996 than searching the archive for the required object files. This is
997 normally used to turn an archive file into a shared library, forcing
998 every object to be included in the resulting shared library.
1001 .B \-\-no\-whole\-archive
1002 Turn off the effect of the
1003 .B \-\-whole\-archive
1004 option for archives which appear later on the command line.
1007 .BI "--wrap " "symbol"
1008 Use a wrapper function for
1010 Any undefined reference to
1013 .BI "__wrap_" "symbol".
1014 Any undefined reference to
1015 .BI "__real_" "symbol"
1021 Delete all temporary local symbols. For most targets, this is all local
1022 symbols whose names begin with `\|\c
1028 Delete all local symbols.
1034 You can change the behavior of
1036 \& with the environment variable \c
1042 \& determines the input-file object format if you don't
1045 \& (or its synonym \c
1047 \&). Its value should be one
1048 of the BFD names for an input format. If there is no
1051 \& in the environment, \c
1053 \& uses the natural format
1058 \& then BFD attempts to discover the
1059 input format by examining binary input files; this method often
1060 succeeds, but there are potential ambiguities, since there is no method
1061 of ensuring that the magic number used to flag object-file formats is
1062 unique. However, the configuration procedure for BFD on each system
1063 places the conventional format for that system first in the search-list,
1064 so ambiguities are resolved in favor of convention.
1073 .RB "`\|" ld "\|' and `\|" binutils "\|'"
1078 ld: the GNU linker\c
1079 , Steve Chamberlain and Roland Pesch;
1081 The GNU Binary Utilities\c
1085 Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
1087 Permission is granted to make and distribute verbatim copies of
1088 this manual provided the copyright notice and this permission notice
1089 are preserved on all copies.
1091 Permission is granted to copy and distribute modified versions of this
1092 manual under the conditions for verbatim copying, provided that the
1093 entire resulting derived work is distributed under the terms of a
1094 permission notice identical to this one.
1096 Permission is granted to copy and distribute translations of this
1097 manual into another language, under the above conditions for modified
1098 versions, except that this permission notice may be included in
1099 translations approved by the Free Software Foundation instead of in
1100 the original English.