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 "\|]"
31 .RB "[\|" \-Bdynamic "\|]"
32 .RB "[\|" \-Bsymbolic "\|]"
36 .RB "[\|" \-d | \-dc | \-dp\c
39 .RB "[\|" "\-defsym\ "\c
47 .RB "[\|" \-embedded\-relocs "\|]"
52 .RB "[\|" "\-format\ "\c
59 .RB "[\|" \-\-help "\|]"
74 .RB "[\|" \-n | \-N "\|]"
75 .RB "[\|" \-noinhibit-exec "\|]"
76 .RB "[\|" \-no\-keep\-memory "\|]"
77 .RB "[\|" "\-oformat\ "\c
83 .RB "[\|" \-relax "\|]"
84 .RB "[\|" \-r | \-Ur "\|]"
87 .RB "[\|" \-shared "\|]"
88 .RB "[\|" \-sort\-common "\|]"
89 .RB "[\|" \-split\-by\-reloc\ "\c
92 .RB "[\|" \-split\-by\-file "\|]"
96 .RB "[\|" "\-Ttext\ "\c
99 .RB "[\|" "\-Tdata\ "\c
102 .RB "[\|" "\-Tbss\ "\c
111 .RB "[\|" \-\-verbose "\|]"
112 .RB "[\|" \-\-version "\|]"
113 .RB "[\|" \-warn\-common "\|]"
114 .RB "[\|" \-warn\-once "\|]"
115 .RB "[\|" \-\-whole\-archive "\|]"
123 \& combines a number of object and archive files, relocates
124 their data and ties up symbol references. Often the last step in
125 building a new compiled program to run is a call to \c
131 \& accepts Linker Command Language files
132 to provide explicit and total control over the linking process.
133 This man page does not describe the command language; see the `\|\c
140 \&, for full details on the command language and on other aspects of
145 \& uses the general purpose BFD libraries
146 to operate on object files. This allows \c
148 \& to read, combine, and
149 write object files in many different formats\(em\&for example, COFF or
152 \&. Different formats may be linked together to produce any
153 available kind of object file. You can use `\|\c
155 \|' to get a list of formats supported on various architectures; see
158 Aside from its flexibility, the GNU linker is more helpful than other
159 linkers in providing diagnostic information. Many linkers abandon
160 execution immediately upon encountering an error; whenever possible,
163 \& continues executing, allowing you to identify other errors
164 (or, in some cases, to get an output file in spite of the error).
168 \& is meant to cover a broad range of situations,
169 and to be as compatible as possible with other linkers. As a result,
170 you have many choices to control its behavior through the command line,
171 and through environment variables.
174 The plethora of command-line options may seem intimidating, but in
175 actual practice few of them are used in any particular context.
176 For instance, a frequent use of \c
178 \& is to link standard Unix
179 object files on a standard, supported Unix system. On such a system, to
185 $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc
190 \& to produce a file called \c
193 result of linking the file \c
200 \& which will come from the standard search
203 The command-line options to \c
205 \& may be specified in any order, and
206 may be repeated at will. For the most part, repeating an option with a
207 different argument will either have no further effect, or override prior
208 occurrences (those further to the left on the command line) of an
211 The exceptions\(em\&which may meaningfully be used more than once\(em\&are
216 \& (or its synonym \c
231 The list of object files to be linked together, shown as \c
234 may follow, precede, or be mixed in with command-line options; save that
237 \& argument may not be placed between an option flag and
240 Usually the linker is invoked with at least one object file, but other
241 forms of binary input files can also be specified with \c
246 \&, and the script command language. If \c
249 files at all are specified, the linker does not produce any output, and
250 issues the message `\|\c
254 Option arguments must either follow the option letter without intervening
255 whitespace, or be given as separate arguments immediately following the
256 option that requires them.
259 .BI "-A" "architecture"\c
261 In the current release of \c
263 \&, this option is useful only for the
264 Intel 960 family of architectures. In that \c
266 \& configuration, the
269 \& argument is one of the two-letter names identifying
270 members of the 960 family; the option specifies the desired output
271 target, and warns of any incompatible instructions in the input files.
272 It also modifies the linker's search strategy for archive libraries, to
273 support the use of libraries specific to each particular
274 architecture, by including in the search loop names suffixed with the
275 string identifying the architecture.
277 For example, if your \c
279 \& command line included `\|\c
284 \|', the linker would look (in its built-in search
285 paths, and in any paths you specify with \c
287 \&) for a library with
301 The first two possibilities would be considered in any event; the last
302 two are due to the use of `\|\c
306 Future releases of \c
308 \& may support similar functionality for
309 other architecture families.
311 You can meaningfully use \c
313 \& more than once on a command line, if
314 an architecture family allows combination of target architectures; each
315 use will add another pair of name variants to search for when \c
321 .BI "\-b " "input-format"\c
323 Specify the binary format for input object files that follow this option
324 on the command line. You don't usually need to specify this, as
327 \& is configured to expect as a default input format the most
328 usual format on each machine. \c
330 \& is a text string, the
331 name of a particular format supported by the BFD libraries.
336 \& has the same effect, as does the script command
339 You may want to use this option if you are linking files with an unusual
340 binary format. You can also use \c
342 \& to switch formats explicitly (when
343 linking object files of different formats), by including
348 \& before each group of object files in a
351 The default format is taken from the environment variable
353 \&. You can also define the input
354 format from a script, using the command \c
360 Do not link against shared libraries. This is only meaningful on
361 platforms for which shared libraries are supported.
365 Link against dynamic libraries. This is only meaningful on platforms
366 for which shared libraries are supported. This option is normally the
367 default on such platforms.
371 When creating a shared library, bind references to global symbols to
372 the definition within the shared library, if any. Normally, it is
373 possible for a program linked against a shared library to override the
374 definition within the shared library. This option is only meaningful
375 on ELF platforms which support shared libraries.
378 .BI "\-c " "commandfile"\c
382 \& to read link commands from the file
385 \&. These commands will completely override \c
388 default link format (rather than adding to it); \c
391 specify everything necessary to describe the target format.
394 You may also include a script of link commands directly in the command
395 line by bracketing it between `\|\c
407 These three options are equivalent; multiple forms are supported for
408 compatibility with other linkers. Use any of them to make \c
411 assign space to common symbols even if a relocatable output file is
414 \&). The script command
416 .B FORCE_COMMON_ALLOCATION\c
417 \& has the same effect.
420 .BI "-defsym " "symbol"\c
424 Create a global symbol in the output file, containing the absolute
427 \&. You may use this option as many
428 times as necessary to define multiple symbols in the command line. A
429 limited form of arithmetic is supported for the \c
432 context: you may give a hexadecimal constant or the name of an existing
437 \& to add or subtract hexadecimal
438 constants or symbols. If you need more elaborate expressions, consider
439 using the linker command language from a script.
446 \& as the explicit symbol for beginning execution of your
447 program, rather than the default entry point. for a
448 discussion of defaults and other ways of specifying the
452 .B \-embedded\-relocs
453 This option is only meaningful when linking MIPS embedded PIC code,
456 option to the GNU compiler and assembler. It causes the linker to
457 create a table which may be used at runtime to relocate any data which
458 was statically initialized to pointer values. See the code in
459 testsuite/ld-empic for details.
466 Some older linkers used this option throughout a compilation toolchain
467 for specifying object-file format for both input and output object
470 \&'s mechanisms (the \c
475 for input files, the \c
477 \& command in linker scripts for output
480 \& environment variable) are more flexible, but
481 but it accepts (and ignores) the \c
483 \& option flag for compatibility
484 with scripts written to call the old linker.
487 .BI "\-format " "input\-format"\c
497 Accepted, but ignored; provided for compatibility with other tools.
501 Set the maximum size of objects to be optimized using the GP register
504 under MIPS ECOFF. Ignored for other object file formats.
508 Print a summary of the command-line options on the standard output and exit.
511 begin with two dashes instead of one
512 for compatibility with other GNU programs. The other options start with
513 only one dash for compatibility with other linkers.
517 Perform an incremental link (same as option \c
524 Add an archive file \c
526 \& to the list of files to link. This
527 option may be used any number of times. \c
530 path-list for occurrences of \c
540 .BI "\-L" "searchdir"\c
542 This command adds path \c
544 \& to the list of paths that
547 \& will search for archive libraries. You may use this option
550 The default set of paths searched (without being specified with
553 \&) depends on what emulation mode \c
556 some cases also on how it was configured. The
557 paths can also be specified in a link script with the \c
564 Print (to the standard output file) a link map\(em\&diagnostic information
565 about where symbols are mapped by \c
567 \&, and information on global
568 common storage allocation.
571 .BI "\-Map " "mapfile"\c
574 a link map\(em\&diagnostic information
575 about where symbols are mapped by \c
577 \&, and information on global
578 common storage allocation.
581 .BI "\-m " "emulation"\c
584 linker. You can list the available emulations with the
588 options. This option overrides the compiled-in default, which is the
589 system for which you configured
594 specifies readable and writable \c
599 the output format supports Unix style magic numbers, the output is
604 When you use the `\|\c
606 \&\|' option, the linker does not page-align the
611 sets the text segment to be read only, and \c
618 Normally, the linker will not produce an output file if it encounters
619 errors during the link process. With this flag, you can specify that
620 you wish the output file retained even after non-fatal errors.
623 .B \-no\-keep\-memory
624 The linker normally optimizes for speed over memory usage by caching
625 the symbol tables of input files in memory. This option tells the
626 linker to instead optimize for memory usage, by rereading the symbol
627 tables as necessary. This may be required if the linker runs out of
628 memory space while linking a large executable.
631 .BI "\-o " "output"\c
637 \& is a name for the program produced by \c
640 option is not specified, the name `\|\c
642 \|' is used by default. The
645 \& can also specify the output file name.
648 .BI "\-oformat " "output\-format"\c
650 Specify the binary format for the output object file.
651 You don't usually need to specify this, as
654 \& is configured to produce as a default output format the most
655 usual format on each machine. \c
657 \& is a text string, the
658 name of a particular format supported by the BFD libraries.
661 can also specify the output format, but this option overrides it.
664 .BI "\-R " "filename"\c
668 Read symbol names and their addresses from \c
671 relocate it or include it in the output. This allows your output file
672 to refer symbolically to absolute locations of memory defined in other
677 An option with machine dependent effects. Currently this option is only
678 supported on the H8/300.
680 On some platforms, use this option to perform global optimizations that
681 become possible when the linker resolves addressing in your program, such
682 as relaxing address modes and synthesizing new instructions in the
685 On platforms where this is not supported, `\|\c
687 \&\|' is accepted, but has no effect.
691 Generates relocatable output\(em\&i.e., generate an output file that can in
692 turn serve as input to \c
694 \&. This is often called \c
697 \&. As a side effect, in environments that support standard Unix
698 magic numbers, this option also sets the output file's magic number to
702 If this option is not specified, an absolute file is produced. When
703 linking C++ programs, this option \c
705 \& resolve references to
708 \& is an alternative.
710 This option does the same as \c
716 Omits debugger symbol information (but not all symbols) from the output file.
720 Omits all symbol information from the output file.
724 Create a shared library. This is currently only supported on ELF
731 places the global common symbols in the appropriate output sections,
732 it sorts them by size. First come all the one byte symbols, then all
733 the two bytes, then all the four bytes, and then everything else.
734 This is to prevent gaps between symbols due to
735 alignment constraints. This option disables that sorting.
738 .B \-split\-by\-reloc\ \fIcount
739 Trys to creates extra sections in the output file so that no single
740 output section in the file contains more than
743 This is useful when generating huge relocatable for downloading into
744 certain real time kernels with the COFF object file format; since COFF
745 cannot represent more than 65535 relocations in a single section.
746 Note that this will fail to work with object file formats which do not
747 support arbitrary sections. The linker will not split up individual
748 input sections for redistribution, so if a single input section
751 relocations one output section will contain that many relocations.
756 .B \-split\-by\-reloc
757 but creates a new output section for each input file.
760 .BI "\-Tbss " "org"\c
762 .BI "\-Tdata " "org"\c
764 .BI "\-Ttext " "org"\c
767 \& as the starting address for\(em\&respectively\(em\&the
774 \& segment of the output file.
777 \& must be a hexadecimal integer.
780 .BI "\-T " "commandfile"\c
783 .BI "\-T" "commandfile"\c
788 \&; supported for compatibility with
793 Prints names of input files as \c
801 \& to be entered in the output file as an undefined symbol.
802 This may, for example, trigger linking of additional modules from
803 standard libraries. \c
805 \& may be repeated with different option
806 arguments to enter additional undefined symbols.
810 For anything other than C++ programs, this option is equivalent to
813 \&: it generates relocatable output\(em\&i.e., an output file that can in
814 turn serve as input to \c
816 \&. When linking C++ programs, \c
821 \& resolve references to constructors, unlike \c
827 Display the version number for \c
829 and list the supported emulations.
830 Display which input files can and can not be opened.
834 Display the version number for \c
839 option also lists the supported emulations.
843 Display the version number for \c
849 Warn when a common symbol is combined with another common symbol or with
850 a symbol definition. Unix linkers allow this somewhat sloppy practice,
851 but linkers on some other operating systems do not. This option allows
852 you to find potential problems from combining global symbols.
856 Only warn once for each undefined symbol, rather than once per module
860 .B \-\-whole\-archive
861 For each archive mentioned on the command line, include every object
862 file in the archive in the link, rather than searching the archive for
863 the required object files. This is normally used to turn an archive
864 file into a shared library, forcing every object to be included in the
865 resulting shared library.
869 Delete all temporary local symbols. For most targets, this is all local
870 symbols whose names begin with `\|\c
876 Delete all local symbols.
882 You can change the behavior of
884 \& with the environment variable \c
890 \& determines the input-file object format if you don't
893 \& (or its synonym \c
895 \&). Its value should be one
896 of the BFD names for an input format. If there is no
899 \& in the environment, \c
901 \& uses the natural format
906 \& then BFD attempts to discover the
907 input format by examining binary input files; this method often
908 succeeds, but there are potential ambiguities, since there is no method
909 of ensuring that the magic number used to flag object-file formats is
910 unique. However, the configuration procedure for BFD on each system
911 places the conventional format for that system first in the search-list,
912 so ambiguities are resolved in favor of convention.
921 .RB "`\|" ld "\|' and `\|" binutils "\|'"
927 , Steve Chamberlain and Roland Pesch;
929 The GNU Binary Utilities\c
933 Copyright (c) 1991, 1992 Free Software Foundation, Inc.
935 Permission is granted to make and distribute verbatim copies of
936 this manual provided the copyright notice and this permission notice
937 are preserved on all copies.
939 Permission is granted to copy and distribute modified versions of this
940 manual under the conditions for verbatim copying, provided that the
941 entire resulting derived work is distributed under the terms of a
942 permission notice identical to this one.
944 Permission is granted to copy and distribute translations of this
945 manual into another language, under the above conditions for modified
946 versions, except that this permission notice may be included in
947 translations approved by the Free Software Foundation instead of in
948 the original English.