X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=ld%2Fld.1;h=60865717df687724a7ce9e5fe813ec23613f1e0b;hp=eb2604add267176f09991580a8912854ff6740de;hb=88750007d7869f178f0ba528f41efd3b74c424cf;hpb=6df9443a374e2b81278c61b8afc0a1eef7db280b diff --git a/ld/ld.1 b/ld/ld.1 index eb2604a..6086571 100644 --- a/ld/ld.1 +++ b/ld/ld.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 +.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== @@ -48,21 +48,25 @@ . ds R" '' 'br\} .\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. -.if \nF \{\ +.ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} -.\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 +.el \{\ +. de IX +.. +.\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -128,7 +132,11 @@ .\" ======================================================================== .\" .IX Title "LD 1" -.TH LD 1 "2007-08-28" "binutils-2.18" "GNU Development Tools" +.TH LD 1 "2009-10-16" "binutils-2.20" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh .SH "NAME" ld \- The GNU linker .SH "SYNOPSIS" @@ -152,7 +160,7 @@ This version of \fBld\fR uses the general purpose \s-1BFD\s0 libraries to operate on object files. This allows \fBld\fR to read, combine, and write object files in many different formats\-\-\-for example, \s-1COFF\s0 or \&\f(CW\*(C`a.out\*(C'\fR. Different formats may be linked together to produce any -available kind of object file. +available kind of object file. .PP Aside from its flexibility, the \s-1GNU\s0 linker is more helpful than other linkers in providing diagnostic information. Many linkers abandon @@ -207,9 +215,11 @@ augments the main linker script used for the link (either the default linker script or the one specified by using \fB\-T\fR). This feature permits the linker to link against a file which appears to be an object or an archive, but actually merely defines some symbol values, or uses -\&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Note that -specifying a script in this way merely augments the main linker script; -use the \fB\-T\fR option to replace the default linker script entirely. +\&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Specifying a +script in this way merely augments the main linker script, with the +extra commands placed after the main script; use the \fB\-T\fR option +to replace the default linker script entirely, but note the effect of +the \f(CW\*(C`INSERT\*(C'\fR command. .PP For options whose names are a single letter, option arguments must either follow the option letter without intervening @@ -238,11 +248,20 @@ prefixed by \fB\-Wl,\fR (or whatever is appropriate for the particular compiler driver) like this: .PP .Vb 1 -\& gcc \-Wl,\-\-startgroup foo.o bar.o \-Wl,\-\-endgroup +\& gcc \-Wl,\-\-start\-group foo.o bar.o \-Wl,\-\-end\-group .Ve .PP This is important, because otherwise the compiler driver program may -silently drop the linker options, resulting in a bad link. +silently drop the linker options, resulting in a bad link. Confusion +may also arise when passing options that require values through a +driver, as the use of a space between option and argument acts as +a separator, and causes the driver to pass only the option to the linker +and the argument to the compiler. In this case, it is simplest to use +the joined forms of both single\- and multiple-letter options, such as: +.PP +.Vb 1 +\& gcc foo.o bar.o \-Wl,\-eENTRY \-Wl,\-Map=a.map +.Ve .PP Here is a table of the generic command line switches accepted by the \s-1GNU\s0 linker: @@ -251,7 +270,7 @@ linker: Read command-line options from \fIfile\fR. The options read are inserted in place of the original @\fIfile\fR option. If \fIfile\fR does not exist, or cannot be read, then the option will be treated -literally, and not removed. +literally, and not removed. .Sp Options in \fIfile\fR are separated by whitespace. A whitespace character may be included in an option by surrounding the entire @@ -259,15 +278,15 @@ option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The \fIfile\fR may itself contain additional @\fIfile\fR options; any such options will be processed recursively. -.IP "\fB\-a\fR\fIkeyword\fR" 4 -.IX Item "-akeyword" +.IP "\fB\-a\fR \fIkeyword\fR" 4 +.IX Item "-a keyword" This option is supported for \s-1HP/UX\s0 compatibility. The \fIkeyword\fR argument must be one of the strings \fBarchive\fR, \fBshared\fR, or \&\fBdefault\fR. \fB\-aarchive\fR is functionally equivalent to \&\fB\-Bstatic\fR, and the other two keywords are functionally equivalent to \fB\-Bdynamic\fR. This option may be used any number of times. -.IP "\fB\-A\fR\fIarchitecture\fR" 4 -.IX Item "-Aarchitecture" +.IP "\fB\-A\fR \fIarchitecture\fR" 4 +.IX Item "-A architecture" .PD 0 .IP "\fB\-\-architecture=\fR\fIarchitecture\fR" 4 .IX Item "--architecture=architecture" @@ -276,7 +295,7 @@ In the current release of \fBld\fR, this option is useful only for the Intel 960 family of architectures. In that \fBld\fR configuration, the \&\fIarchitecture\fR argument identifies the particular architecture in the 960 family, enabling some safeguards and modifying the -archive-library search path. +archive-library search path. .Sp Future releases of \fBld\fR may support similar functionality for other architecture families. @@ -345,30 +364,46 @@ program, rather than the default entry point. If there is no symbol named \fIentry\fR, the linker will try to parse \fIentry\fR as a number, and use that as the entry address (the number will be interpreted in base 10; you may use a leading \fB0x\fR for base 16, or a leading -\&\fB0\fR for base 8). +\&\fB0\fR for base 8). .IP "\fB\-\-exclude\-libs\fR \fIlib\fR\fB,\fR\fIlib\fR\fB,...\fR" 4 .IX Item "--exclude-libs lib,lib,..." Specifies a list of archive libraries from which symbols should not be automatically -exported. The library names may be delimited by commas or colons. Specifying +exported. The library names may be delimited by commas or colons. Specifying \&\f(CW\*(C`\-\-exclude\-libs ALL\*(C'\fR excludes symbols in all archive libraries from automatic export. This option is available only for the i386 \s-1PE\s0 targeted port of the linker and for \s-1ELF\s0 targeted ports. For i386 \s-1PE\s0, symbols explicitly listed in a .def file are still exported, regardless of this option. For \s-1ELF\s0 targeted ports, symbols affected by this option will be treated as hidden. +.IP "\fB\-\-exclude\-modules\-for\-implib\fR \fImodule\fR\fB,\fR\fImodule\fR\fB,...\fR" 4 +.IX Item "--exclude-modules-for-implib module,module,..." +Specifies a list of object files or archive members, from which symbols +should not be automatically exported, but which should be copied wholesale +into the import library being generated during the link. The module names +may be delimited by commas or colons, and must match exactly the filenames +used by \fBld\fR to open the files; for archive members, this is simply +the member name, but for object files the name listed must include and +match precisely any path used to specify the input file on the linker's +command-line. This option is available only for the i386 \s-1PE\s0 targeted port +of the linker. Symbols explicitly listed in a .def file are still exported, +regardless of this option. .IP "\fB\-E\fR" 4 .IX Item "-E" .PD 0 .IP "\fB\-\-export\-dynamic\fR" 4 .IX Item "--export-dynamic" +.IP "\fB\-\-no\-export\-dynamic\fR" 4 +.IX Item "--no-export-dynamic" .PD -When creating a dynamically linked executable, add all symbols to the -dynamic symbol table. The dynamic symbol table is the set of symbols -which are visible from dynamic objects at run time. +When creating a dynamically linked executable, using the \fB\-E\fR +option or the \fB\-\-export\-dynamic\fR option causes the linker to add +all symbols to the dynamic symbol table. The dynamic symbol table is the +set of symbols which are visible from dynamic objects at run time. .Sp -If you do not use this option, the dynamic symbol table will normally -contain only those symbols which are referenced by some dynamic object -mentioned in the link. +If you do not use either of these options (or use the +\&\fB\-\-no\-export\-dynamic\fR option to restore the default behavior), the +dynamic symbol table will normally contain only those symbols which are +referenced by some dynamic object mentioned in the link. .Sp If you use \f(CW\*(C`dlopen\*(C'\fR to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other @@ -378,17 +413,21 @@ linking the program itself. You can also use the dynamic list to control what symbols should be added to the dynamic symbol table if the output format supports it. See the description of \fB\-\-dynamic\-list\fR. +.Sp +Note that this option is specific to \s-1ELF\s0 targeted ports. \s-1PE\s0 targets +support a similar function to export all symbols from a \s-1DLL\s0 or \s-1EXE\s0; see +the description of \fB\-\-export\-all\-symbols\fR below. .IP "\fB\-EB\fR" 4 .IX Item "-EB" Link big-endian objects. This affects the default output format. .IP "\fB\-EL\fR" 4 .IX Item "-EL" Link little-endian objects. This affects the default output format. -.IP "\fB\-f\fR" 4 -.IX Item "-f" +.IP "\fB\-f\fR \fIname\fR" 4 +.IX Item "-f name" .PD 0 -.IP "\fB\-\-auxiliary\fR \fIname\fR" 4 -.IX Item "--auxiliary name" +.IP "\fB\-\-auxiliary=\fR\fIname\fR" 4 +.IX Item "--auxiliary=name" .PD When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_AUXILIARY\s0 field to the specified name. This tells the dynamic linker that the symbol @@ -410,8 +449,8 @@ will be created in the order in which they appear on the command line. .IP "\fB\-F\fR \fIname\fR" 4 .IX Item "-F name" .PD 0 -.IP "\fB\-\-filter\fR \fIname\fR" 4 -.IX Item "--filter name" +.IP "\fB\-\-filter=\fR\fIname\fR" 4 +.IX Item "--filter=name" .PD When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_FILTER\s0 field to the specified name. This tells the dynamic linker that the symbol table @@ -435,8 +474,8 @@ The \s-1GNU\s0 linker uses other mechanisms for this purpose: the environment variable. The \s-1GNU\s0 linker will ignore the \fB\-F\fR option when not creating an \s-1ELF\s0 shared object. -.IP "\fB\-fini\fR \fIname\fR" 4 -.IX Item "-fini name" +.IP "\fB\-fini=\fR\fIname\fR" 4 +.IX Item "-fini=name" When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the executable or shared object is unloaded, by setting \s-1DT_FINI\s0 to the address of the function. By default, the linker uses \f(CW\*(C`_fini\*(C'\fR as @@ -444,8 +483,8 @@ the function to call. .IP "\fB\-g\fR" 4 .IX Item "-g" Ignored. Provided for compatibility with other tools. -.IP "\fB\-G\fR\fIvalue\fR" 4 -.IX Item "-Gvalue" +.IP "\fB\-G\fR \fIvalue\fR" 4 +.IX Item "-G value" .PD 0 .IP "\fB\-\-gpsize=\fR\fIvalue\fR" 4 .IX Item "--gpsize=value" @@ -454,8 +493,8 @@ Set the maximum size of objects to be optimized using the \s-1GP\s0 register to \&\fIsize\fR. This is only meaningful for object file formats such as \&\s-1MIPS\s0 \s-1ECOFF\s0 which supports putting large and small objects into different sections. This is ignored for other object file formats. -.IP "\fB\-h\fR\fIname\fR" 4 -.IX Item "-hname" +.IP "\fB\-h\fR \fIname\fR" 4 +.IX Item "-h name" .PD 0 .IP "\fB\-soname=\fR\fIname\fR" 4 .IX Item "-soname=name" @@ -468,14 +507,14 @@ field rather than the using the file name given to the linker. .IP "\fB\-i\fR" 4 .IX Item "-i" Perform an incremental link (same as option \fB\-r\fR). -.IP "\fB\-init\fR \fIname\fR" 4 -.IX Item "-init name" +.IP "\fB\-init=\fR\fIname\fR" 4 +.IX Item "-init=name" When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the executable or shared object is loaded, by setting \s-1DT_INIT\s0 to the address of the function. By default, the linker uses \f(CW\*(C`_init\*(C'\fR as the function to call. -.IP "\fB\-l\fR\fInamespec\fR" 4 -.IX Item "-lnamespec" +.IP "\fB\-l\fR \fInamespec\fR" 4 +.IX Item "-l namespec" .PD 0 .IP "\fB\-\-library=\fR\fInamespec\fR" 4 .IX Item "--library=namespec" @@ -483,7 +522,7 @@ function to call. Add the archive or object file specified by \fInamespec\fR to the list of files to link. This option may be used any number of times. If \fInamespec\fR is of the form \fI:\fIfilename\fI\fR, \fBld\fR -will search the library path for a file called \fIfilename\fR, otherise it +will search the library path for a file called \fIfilename\fR, otherwise it will search the library path for a file called \fIlib\fInamespec\fI.a\fR. .Sp On systems which support shared libraries, \fBld\fR may also search for @@ -510,8 +549,8 @@ You may list the same archive multiple times on the command line. This type of archive searching is standard for Unix linkers. However, if you are using \fBld\fR on \s-1AIX\s0, note that it is different from the behaviour of the \s-1AIX\s0 linker. -.IP "\fB\-L\fR\fIsearchdir\fR" 4 -.IX Item "-Lsearchdir" +.IP "\fB\-L\fR \fIsearchdir\fR" 4 +.IX Item "-L searchdir" .PD 0 .IP "\fB\-\-library\-path=\fR\fIsearchdir\fR" 4 .IX Item "--library-path=searchdir" @@ -522,20 +561,22 @@ option any number of times. The directories are searched in the order in which they are specified on the command line. Directories specified on the command line are searched before the default directories. All \&\fB\-L\fR options apply to all \fB\-l\fR options, regardless of the -order in which the options appear. +order in which the options appear. \fB\-L\fR options do not affect +how \fBld\fR searches for a linker script unless \fB\-T\fR +option is specified. .Sp If \fIsearchdir\fR begins with \f(CW\*(C`=\*(C'\fR, then the \f(CW\*(C`=\*(C'\fR will be replaced by the \fIsysroot prefix\fR, a path specified when the linker is configured. .Sp The default set of paths searched (without being specified with \&\fB\-L\fR) depends on which emulation mode \fBld\fR is using, and in -some cases also on how it was configured. +some cases also on how it was configured. .Sp The paths can also be specified in a link script with the \&\f(CW\*(C`SEARCH_DIR\*(C'\fR command. Directories specified this way are searched at the point in which the linker script appears in the command line. -.IP "\fB\-m\fR\fIemulation\fR" 4 -.IX Item "-memulation" +.IP "\fB\-m\fR \fIemulation\fR" 4 +.IX Item "-m emulation" Emulate the \fIemulation\fR linker. You can list the available emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. .Sp @@ -553,14 +594,14 @@ configured. Print a link map to the standard output. A link map provides information about the link, including the following: .RS 4 -.IP "*" 4 +.IP "\(bu" 4 Where object files are mapped into memory. -.IP "*" 4 +.IP "\(bu" 4 How common symbols are allocated. -.IP "*" 4 +.IP "\(bu" 4 All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in. -.IP "*" 4 +.IP "\(bu" 4 The values assigned to symbols. .Sp Note \- symbols whose values are computed by an expression which @@ -614,8 +655,8 @@ specification published by Microsoft. .IP "\fB\-\-no\-omagic\fR" 4 .IX Item "--no-omagic" This option negates most of the effects of the \fB\-N\fR option. It -sets the text section to be read\-only, and forces the data segment to -be page\-aligned. Note \- this option does not enable linking against +sets the text section to be read-only, and forces the data segment to +be page-aligned. Note \- this option does not enable linking against shared libraries. Use \fB\-Bdynamic\fR for this. .IP "\fB\-o\fR \fIoutput\fR" 4 .IX Item "-o output" @@ -727,7 +768,7 @@ options accumulate. .IP "\fB\-\-default\-script=\fR\fIscriptfile\fR" 4 .IX Item "--default-script=scriptfile" .PD -Use \fIscriptfile\fR as the default linker script. +Use \fIscriptfile\fR as the default linker script. .Sp This option is similar to the \fB\-\-script\fR option except that processing of the script is delayed until after the rest of the @@ -942,9 +983,11 @@ This option affects \s-1ELF\s0 \s-1DT_NEEDED\s0 tags for dynamic libraries menti on the command line after the \fB\-\-as\-needed\fR option. Normally, the linker will add a \s-1DT_NEEDED\s0 tag for each dynamic library mentioned on the command line, regardless of whether the library is actually -needed. \fB\-\-as\-needed\fR causes \s-1DT_NEEDED\s0 tags to only be emitted -for libraries that satisfy some symbol reference from regular objects -which is undefined at the point that the library was linked. +needed. \fB\-\-as\-needed\fR causes a \s-1DT_NEEDED\s0 tag to only be emitted +for a library that satisfies a symbol reference from regular objects +which is undefined at the point that the library was linked, or, if +the library is not found in the \s-1DT_NEEDED\s0 lists of other libraries +linked up to that point, a reference from another dynamic library. \&\fB\-\-no\-as\-needed\fR restores the default behaviour. .IP "\fB\-\-add\-needed\fR" 4 .IX Item "--add-needed" @@ -1050,6 +1093,9 @@ perform this check, and if it finds any overlaps it will produce suitable error messages. The linker does know about, and does make allowances for sections in overlays. The default behaviour can be restored by using the command line switch \fB\-\-check\-sections\fR. +Section overlap is not usually checked for relocatable links. You can +force checking in that case by using the \fB\-\-check\-sections\fR +option. .IP "\fB\-\-cref\fR" 4 .IX Item "--cref" Output a cross reference table. If a linker map file is being @@ -1076,8 +1122,8 @@ This eliminates the unused duplicate space in the shared library, and also prevents any possible confusion over resolving to the wrong duplicate when there are many dynamic modules with specialized search paths for runtime symbol resolution. -.IP "\fB\-\-defsym\fR \fIsymbol\fR\fB=\fR\fIexpression\fR" 4 -.IX Item "--defsym symbol=expression" +.IP "\fB\-\-defsym=\fR\fIsymbol\fR\fB=\fR\fIexpression\fR" 4 +.IX Item "--defsym=symbol=expression" Create a global symbol in the output file, containing the absolute address given by \fIexpression\fR. You may use this option as many times as necessary to define multiple symbols in the command line. A @@ -1103,15 +1149,24 @@ different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. The linker will demangle by default unless the environment variable \fB\s-1COLLECT_NO_DEMANGLE\s0\fR is set. These options may be used to override the default. -.IP "\fB\-\-dynamic\-linker\fR \fIfile\fR" 4 -.IX Item "--dynamic-linker file" +.IP "\fB\-I\fR\fIfile\fR" 4 +.IX Item "-Ifile" +.PD 0 +.IP "\fB\-\-dynamic\-linker=\fR\fIfile\fR" 4 +.IX Item "--dynamic-linker=file" +.PD Set the name of the dynamic linker. This is only meaningful when generating dynamically linked \s-1ELF\s0 executables. The default dynamic linker is normally correct; don't use this unless you know what you are doing. .IP "\fB\-\-fatal\-warnings\fR" 4 .IX Item "--fatal-warnings" -Treat all warnings as errors. +.PD 0 +.IP "\fB\-\-no\-fatal\-warnings\fR" 4 +.IX Item "--no-fatal-warnings" +.PD +Treat all warnings as errors. The default behaviour can be restored +with the option \fB\-\-no\-fatal\-warnings\fR. .IP "\fB\-\-force\-exe\-suffix\fR" 4 .IX Item "--force-exe-suffix" Make sure that an output file has a .exe suffix. @@ -1129,10 +1184,24 @@ it ends in a \f(CW\*(C`.exe\*(C'\fR suffix. .IX Item "--no-gc-sections" .PD Enable garbage collection of unused input sections. It is ignored on -targets that do not support this option. This option is not compatible -with \fB\-r\fR or \fB\-\-emit\-relocs\fR. The default behaviour (of not +targets that do not support this option. The default behaviour (of not performing this garbage collection) can be restored by specifying \&\fB\-\-no\-gc\-sections\fR on the command line. +.Sp +\&\fB\-\-gc\-sections\fR decides which input sections are used by +examining symbols and relocations. The section containing the entry +symbol and all sections containing symbols undefined on the +command-line will be kept, as will sections containing symbols +referenced by dynamic objects. Note that when building shared +libraries, the linker must assume that any visible symbol is +referenced. Once this initial set of sections has been determined, +the linker recursively marks as used any section referenced by their +relocations. See \fB\-\-entry\fR and \fB\-\-undefined\fR. +.Sp +This option can be set when doing a partial link (enabled with option +\&\fB\-r\fR). In this case the root of symbols kept must be explicitely +specified either by an \fB\-\-entry\fR or \fB\-\-undefined\fR option or by +a \f(CW\*(C`ENTRY\*(C'\fR command in the linker script. .IP "\fB\-\-print\-gc\-sections\fR" 4 .IX Item "--print-gc-sections" .PD 0 @@ -1151,8 +1220,8 @@ Print a summary of the command-line options on the standard output and exit. .IP "\fB\-\-target\-help\fR" 4 .IX Item "--target-help" Print a summary of all target specific options on the standard output and exit. -.IP "\fB\-Map\fR \fImapfile\fR" 4 -.IX Item "-Map mapfile" +.IP "\fB\-Map=\fR\fImapfile\fR" 4 +.IX Item "-Map=mapfile" Print a link map to the file \fImapfile\fR. See the description of the \&\fB\-M\fR option, above. .IP "\fB\-\-no\-keep\-memory\fR" 4 @@ -1188,21 +1257,35 @@ first definition will be used. .IP "\fB\-\-no\-allow\-shlib\-undefined\fR" 4 .IX Item "--no-allow-shlib-undefined" .PD -Allows (the default) or disallows undefined symbols in shared libraries. +Allows or disallows undefined symbols in shared libraries. This switch is similar to \fB\-\-no\-undefined\fR except that it determines the behaviour when the undefined symbols are in a shared library rather than a regular object file. It does not affect how undefined symbols in regular object files are handled. .Sp -The reason that \fB\-\-allow\-shlib\-undefined\fR is the default is that -the shared library being specified at link time may not be the same as -the one that is available at load time, so the symbols might actually be -resolvable at load time. Plus there are some systems, (eg BeOS) where -undefined symbols in shared libraries is normal. (The kernel patches -them at load time to select which function is most appropriate -for the current architecture. This is used for example to dynamically -select an appropriate memset function). Apparently it is also normal -for \s-1HPPA\s0 shared libraries to have undefined symbols. +The default behaviour is to report errors for any undefined symbols +referenced in shared libraries if the linker is being used to create +an executable, but to allow them if the linker is being used to create +a shared library. +.Sp +The reasons for allowing undefined symbol references in shared +libraries specified at link time are that: +.RS 4 +.IP "\(bu" 4 +A shared library specified at link time may not be the same as the one +that is available at load time, so the symbol might actually be +resolvable at load time. +.IP "\(bu" 4 +There are some operating systems, eg BeOS and \s-1HPPA\s0, where undefined +symbols in shared libraries are normal. +.Sp +The BeOS kernel for example patches shared libraries at load time to +select whichever function is most appropriate for the current +architecture. This is used, for example, to dynamically select an +appropriate memset function. +.RE +.RS 4 +.RE .IP "\fB\-\-no\-undefined\-version\fR" 4 .IX Item "--no-undefined-version" Normally when a symbol has an undefined version, the linker will ignore @@ -1244,8 +1327,8 @@ when it issues any error whatsoever. Only search library directories explicitly specified on the command line. Library directories specified in linker scripts (including linker scripts specified on the command line) are ignored. -.IP "\fB\-\-oformat\fR \fIoutput-format\fR" 4 -.IX Item "--oformat output-format" +.IP "\fB\-\-oformat=\fR\fIoutput-format\fR" 4 +.IX Item "--oformat=output-format" \&\fBld\fR may be configured to support more than one kind of object file. If your \fBld\fR is configured this way, you can use the \&\fB\-\-oformat\fR option to specify the binary format for the output @@ -1256,7 +1339,7 @@ usual format on each machine. \fIoutput-format\fR is a text string, the name of a particular format supported by the \s-1BFD\s0 libraries. (You can list the available binary formats with \fBobjdump \-i\fR.) The script command \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR can also specify the output format, but -this option overrides it. +this option overrides it. .IP "\fB\-pie\fR" 4 .IX Item "-pie" .PD 0 @@ -1292,8 +1375,8 @@ the case for the Matsushita \s-1MN10200\s0 and \s-1MN10300\s0 family of processo .Sp On platforms where this is not supported, \fB\-\-relax\fR is accepted, but ignored. -.IP "\fB\-\-retain\-symbols\-file\fR \fIfilename\fR" 4 -.IX Item "--retain-symbols-file filename" +.IP "\fB\-\-retain\-symbols\-file=\fR\fIfilename\fR" 4 +.IX Item "--retain-symbols-file=filename" Retain \fIonly\fR the symbols listed in the file \fIfilename\fR, discarding all others. \fIfilename\fR is simply a flat file, with one symbol name per line. This option is especially useful in environments @@ -1306,8 +1389,8 @@ or symbols needed for relocations. .Sp You may only specify \fB\-\-retain\-symbols\-file\fR once in the command line. It overrides \fB\-s\fR and \fB\-S\fR. -.IP "\fB\-rpath\fR \fIdir\fR" 4 -.IX Item "-rpath dir" +.IP "\fB\-rpath=\fR\fIdir\fR" 4 +.IX Item "-rpath=dir" Add a directory to the runtime library search path. This is used when linking an \s-1ELF\s0 executable with shared objects. All \fB\-rpath\fR arguments are concatenated and passed to the runtime linker, which uses @@ -1329,13 +1412,13 @@ file systems. For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is followed by a directory name, rather than a file name, it is treated as the \fB\-rpath\fR option. -.IP "\fB\-rpath\-link\fR \fI\s-1DIR\s0\fR" 4 -.IX Item "-rpath-link DIR" +.IP "\fB\-rpath\-link=\fR\fIdir\fR" 4 +.IX Item "-rpath-link=dir" When using \s-1ELF\s0 or SunOS, one shared library may require another. This happens when an \f(CW\*(C`ld \-shared\*(C'\fR link includes a shared library as one of the input files. .Sp -When the linker encounters such a dependency when doing a non\-shared, +When the linker encounters such a dependency when doing a non-shared, non-relocatable link, it will automatically try to locate the required shared library and include it in the link, if it is not included explicitly. In such a case, the \fB\-rpath\-link\fR option @@ -1363,15 +1446,15 @@ at link time. Searching \fB\-rpath\fR in this way is only supported by native linkers and cross linkers which have been configured with the \fB\-\-with\-sysroot\fR option. .IP "3." 4 -On an \s-1ELF\s0 system, if the \fB\-rpath\fR and \f(CW\*(C`rpath\-link\*(C'\fR options -were not used, search the contents of the environment variable -\&\f(CW\*(C`LD_RUN_PATH\*(C'\fR. It is for the native linker only. +On an \s-1ELF\s0 system, for native linkers, if the \fB\-rpath\fR and +\&\fB\-rpath\-link\fR options were not used, search the contents of the +environment variable \f(CW\*(C`LD_RUN_PATH\*(C'\fR. .IP "4." 4 On SunOS, if the \fB\-rpath\fR option was not used, search any directories specified using \fB\-L\fR options. .IP "5." 4 -For a native linker, the contents of the environment variable -\&\f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR. +For a native linker, the search the contents of the environment +variable \f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR. .IP "6." 4 For a native \s-1ELF\s0 linker, the directories in \f(CW\*(C`DT_RUNPATH\*(C'\fR or \&\f(CW\*(C`DT_RPATH\*(C'\fR of a shared library are searched for shared @@ -1400,26 +1483,33 @@ shared library if the \fB\-e\fR option is not used and there are undefined symbols in the link. .IP "\fB\-\-sort\-common\fR" 4 .IX Item "--sort-common" -This option tells \fBld\fR to sort the common symbols by size when it -places them in the appropriate output sections. First come all the one -byte symbols, then all the two byte, then all the four byte, and then -everything else. This is to prevent gaps between symbols due to -alignment constraints. -.IP "\fB\-\-sort\-section name\fR" 4 -.IX Item "--sort-section name" +.PD 0 +.IP "\fB\-\-sort\-common=ascending\fR" 4 +.IX Item "--sort-common=ascending" +.IP "\fB\-\-sort\-common=descending\fR" 4 +.IX Item "--sort-common=descending" +.PD +This option tells \fBld\fR to sort the common symbols by alignment in +ascending or descending order when it places them in the appropriate output +sections. The symbol alignments considered are sixteen-byte or larger, +eight-byte, four-byte, two-byte, and one-byte. This is to prevent gaps +between symbols due to alignment constraints. If no sorting order is +specified, then descending order is assumed. +.IP "\fB\-\-sort\-section=name\fR" 4 +.IX Item "--sort-section=name" This option will apply \f(CW\*(C`SORT_BY_NAME\*(C'\fR to all wildcard section patterns in the linker script. -.IP "\fB\-\-sort\-section alignment\fR" 4 -.IX Item "--sort-section alignment" +.IP "\fB\-\-sort\-section=alignment\fR" 4 +.IX Item "--sort-section=alignment" This option will apply \f(CW\*(C`SORT_BY_ALIGNMENT\*(C'\fR to all wildcard section patterns in the linker script. -.IP "\fB\-\-split\-by\-file [\fR\fIsize\fR\fB]\fR" 4 -.IX Item "--split-by-file [size]" +.IP "\fB\-\-split\-by\-file[=\fR\fIsize\fR\fB]\fR" 4 +.IX Item "--split-by-file[=size]" Similar to \fB\-\-split\-by\-reloc\fR but creates a new output section for each input file when \fIsize\fR is reached. \fIsize\fR defaults to a size of 1 if not given. -.IP "\fB\-\-split\-by\-reloc [\fR\fIcount\fR\fB]\fR" 4 -.IX Item "--split-by-reloc [count]" +.IP "\fB\-\-split\-by\-reloc[=\fR\fIcount\fR\fB]\fR" 4 +.IX Item "--split-by-reloc[=count]" Tries to creates extra sections in the output file so that no single output section in the file contains more than \fIcount\fR relocations. This is useful when generating huge relocatable files for downloading into @@ -1451,8 +1541,8 @@ full debugging information by over 30 percent. Unfortunately, the SunOS \&\f(CW\*(C`dbx\*(C'\fR program can not read the resulting program (\f(CW\*(C`gdb\*(C'\fR has no trouble). The \fB\-\-traditional\-format\fR switch tells \fBld\fR to not combine duplicate entries. -.IP "\fB\-\-section\-start\fR \fIsectionname\fR\fB=\fR\fIorg\fR" 4 -.IX Item "--section-start sectionname=org" +.IP "\fB\-\-section\-start=\fR\fIsectionname\fR\fB=\fR\fIorg\fR" 4 +.IX Item "--section-start=sectionname=org" Locate a section in the output file at the absolute address given by \fIorg\fR. You may use this option as many times as necessary to locate multiple sections in the command @@ -1462,16 +1552,20 @@ for compatibility with other linkers, you may omit the leading \&\fB0x\fR usually associated with hexadecimal values. \fINote:\fR there should be no white space between \fIsectionname\fR, the equals sign ("\fB=\fR"), and \fIorg\fR. -.IP "\fB\-Tbss\fR \fIorg\fR" 4 -.IX Item "-Tbss org" +.IP "\fB\-Tbss=\fR\fIorg\fR" 4 +.IX Item "-Tbss=org" .PD 0 -.IP "\fB\-Tdata\fR \fIorg\fR" 4 -.IX Item "-Tdata org" -.IP "\fB\-Ttext\fR \fIorg\fR" 4 -.IX Item "-Ttext org" +.IP "\fB\-Tdata=\fR\fIorg\fR" 4 +.IX Item "-Tdata=org" +.IP "\fB\-Ttext=\fR\fIorg\fR" 4 +.IX Item "-Ttext=org" .PD -Same as \-\-section\-start, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or +Same as \fB\-\-section\-start\fR, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or \&\f(CW\*(C`.text\*(C'\fR as the \fIsectionname\fR. +.IP "\fB\-Ttext\-segment=\fR\fIorg\fR" 4 +.IX Item "-Ttext-segment=org" +When creating an \s-1ELF\s0 executable or shared object, it will set the address +of the first byte of the text segment. .IP "\fB\-\-unresolved\-symbols=\fR\fImethod\fR" 4 .IX Item "--unresolved-symbols=method" Determine how to handle unresolved symbols. There are four possible @@ -1518,7 +1612,10 @@ the linker script being used by the linker. Specify the name of a version script to the linker. This is typically used when creating shared libraries to specify additional information about the version hierarchy for the library being created. This option -is only meaningful on \s-1ELF\s0 platforms which support shared libraries. +is only fully supported on \s-1ELF\s0 platforms which support shared libraries; +see \fB\s-1VERSION\s0\fR. It is partially supported on \s-1PE\s0 platforms, which can +use version scripts to filter symbol visibility in auto-export mode: any +symbols marked \fBlocal\fR in the version script will not be exported. .IP "\fB\-\-warn\-common\fR" 4 .IX Item "--warn-common" Warn when a common symbol is combined with another common symbol or with @@ -1560,7 +1657,7 @@ Turning a common symbol into a reference, because there is already a definition for the symbol. .Sp .Vb 3 -\& (
): warning: common of `' +\& (
): warning: common of \`\*(Aq \& overridden by definition \& (
): warning: defined here .Ve @@ -1570,7 +1667,7 @@ the symbol is encountered. This is the same as the previous case, except that the symbols are encountered in a different order. .Sp .Vb 3 -\& (
): warning: definition of `' +\& (
): warning: definition of \`\*(Aq \& overriding common \& (
): warning: common is here .Ve @@ -1579,14 +1676,14 @@ Merging a common symbol with a previous same-sized common symbol. .Sp .Vb 3 \& (
): warning: multiple common -\& of `' +\& of \`\*(Aq \& (
): warning: previous common is here .Ve .IP "4." 4 Merging a common symbol with a previous larger common symbol. .Sp .Vb 3 -\& (
): warning: common of `' +\& (
): warning: common of \`\*(Aq \& overridden by larger common \& (
): warning: larger common is here .Ve @@ -1596,7 +1693,7 @@ the same as the previous case, except that the symbols are encountered in a different order. .Sp .Vb 3 -\& (
): warning: common of `' +\& (
): warning: common of \`\*(Aq \& overriding smaller common \& (
): warning: smaller common is here .Ve @@ -1635,6 +1732,9 @@ the section. .IP "\fB\-\-warn\-shared\-textrel\fR" 4 .IX Item "--warn-shared-textrel" Warn if the linker adds a \s-1DT_TEXTREL\s0 to a shared object. +.IP "\fB\-\-warn\-alternate\-em\fR" 4 +.IX Item "--warn-alternate-em" +Warn if an object has alternate \s-1ELF\s0 machine code. .IP "\fB\-\-warn\-unresolved\-symbols\fR" 4 .IX Item "--warn-unresolved-symbols" If the linker is going to report an unresolved symbol (see the option @@ -1658,8 +1758,8 @@ about this option, so you have to use \fB\-Wl,\-whole\-archive\fR. Second, don't forget to use \fB\-Wl,\-no\-whole\-archive\fR after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well. -.IP "\fB\-\-wrap\fR \fIsymbol\fR" 4 -.IX Item "--wrap symbol" +.IP "\fB\-\-wrap=\fR\fIsymbol\fR" 4 +.IX Item "--wrap=symbol" Use a wrapper function for \fIsymbol\fR. Any undefined reference to \&\fIsymbol\fR will be resolved to \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. Any undefined reference to \f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR will be resolved to @@ -1674,10 +1774,10 @@ Here is a trivial example: .Sp .Vb 6 \& void * -\& __wrap_malloc (size_t c) +\& _\|_wrap_malloc (size_t c) \& { \& printf ("malloc called with %zu\en", c); -\& return __real_malloc (c); +\& return _\|_real_malloc (c); \& } .Ve .Sp @@ -1792,6 +1892,29 @@ Create a \s-1DLL\s0 instead of a regular executable. You may also use \&\fB\-shared\fR or specify a \f(CW\*(C`LIBRARY\*(C'\fR in a given \f(CW\*(C`.def\*(C'\fR file. [This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-enable\-long\-section\-names\fR" 4 +.IX Item "--enable-long-section-names" +.PD 0 +.IP "\fB\-\-disable\-long\-section\-names\fR" 4 +.IX Item "--disable-long-section-names" +.PD +The \s-1PE\s0 variants of the Coff object format add an extension that permits +the use of section names longer than eight characters, the normal limit +for Coff. By default, these names are only allowed in object files, as +fully-linked executable images do not carry the Coff string table required +to support the longer names. As a \s-1GNU\s0 extension, it is possible to +allow their use in executable images as well, or to (probably pointlessly!) +disallow it in object files, by using these two options. Executable images +generated with these long section names are slightly non-standard, carrying +as they do a string table, and may generate confusing output when examined +with non-GNU PE-aware tools, such as file viewers and dumpers. However, +\&\s-1GDB\s0 relies on the use of \s-1PE\s0 long section names to find Dwarf\-2 debug +information sections in an executable image at runtime, and so if neither +option is specified on the command-line, \fBld\fR will enable long +section names, overriding the default and technically correct behaviour, +when it finds the presence of debug information while linking an executable +image and not stripping symbols. +[This option is valid for all \s-1PE\s0 targeted ports of the linker] .IP "\fB\-\-enable\-stdcall\-fixup\fR" 4 .IX Item "--enable-stdcall-fixup" .PD 0 @@ -1823,7 +1946,7 @@ option is given. Note that the symbols \f(CW\*(C`DllMain@12\*(C'\fR, \&\f(CW\*(C`DllEntryPoint@0\*(C'\fR, \f(CW\*(C`DllMainCRTStartup@12\*(C'\fR, and \&\f(CW\*(C`impure_ptr\*(C'\fR will not be automatically exported. Also, symbols imported from other DLLs will not be -re\-exported, nor will symbols specifying the \s-1DLL\s0's internal layout +re-exported, nor will symbols specifying the \s-1DLL\s0's internal layout such as those beginning with \f(CW\*(C`_head_\*(C'\fR or ending with \&\f(CW\*(C`_iname\*(C'\fR. In addition, no symbols from \f(CW\*(C`libgcc\*(C'\fR, \&\f(CW\*(C`libstd++\*(C'\fR, \f(CW\*(C`libmingw32\*(C'\fR, or \f(CW\*(C`crtX.o\*(C'\fR will be exported. @@ -1953,10 +2076,16 @@ building the import libraries with those \s-1DATA\s0 exports. Note: Use of the to be made writable. This does not conform to the PE-COFF format specification published by Microsoft. .Sp +Note \- use of the 'auto\-import' extension will also cause read only +data which would normally be placed into the .rdata section to be +placed into the .data section instead. This is in order to work +around a problem with consts that is described here: +http://www.cygwin.com/ml/cygwin/2004\-09/msg01101.html +.Sp Using 'auto\-import' generally will 'just work' \*(-- but sometimes you may see this message: .Sp -"variable '' can't be auto\-imported. Please read the +"variable '' can't be auto-imported. Please read the documentation for ld's \f(CW\*(C`\-\-enable\-auto\-import\*(C'\fR for details." .Sp This message occurs when some (sub)expression accesses an address @@ -2049,12 +2178,12 @@ Solution 1: .Sp Solution 2: .Sp -.Vb 14 +.Vb 10 \& \-\-foo.h -\& /* Note: auto\-export is assumed (no __declspec(dllexport)) */ -\& #if (defined(_WIN32) || defined(__CYGWIN__)) && \e +\& /* Note: auto\-export is assumed (no _\|_declspec(dllexport)) */ +\& #if (defined(_WIN32) || defined(_\|_CYGWIN_\|_)) && \e \& !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) -\& #define FOO_IMPORT __declspec(dllimport) +\& #define FOO_IMPORT _\|_declspec(dllimport) \& #else \& #define FOO_IMPORT \& #endif @@ -2121,6 +2250,38 @@ legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C the subsystem version also. Numeric values are also accepted for \&\fIwhich\fR. [This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.Sp +The following options set flags in the \f(CW\*(C`DllCharacteristics\*(C'\fR field +of the \s-1PE\s0 file header: +[These options are specific to \s-1PE\s0 targeted ports of the linker] +.IP "\fB\-\-dynamicbase\fR" 4 +.IX Item "--dynamicbase" +The image base address may be relocated using address space layout +randomization (\s-1ASLR\s0). This feature was introduced with \s-1MS\s0 Windows +Vista for i386 \s-1PE\s0 targets. +.IP "\fB\-\-forceinteg\fR" 4 +.IX Item "--forceinteg" +Code integrity checks are enforced. +.IP "\fB\-\-nxcompat\fR" 4 +.IX Item "--nxcompat" +The image is compatible with the Data Execution Prevention. +This feature was introduced with \s-1MS\s0 Windows \s-1XP\s0 \s-1SP2\s0 for i386 \s-1PE\s0 targets. +.IP "\fB\-\-no\-isolation\fR" 4 +.IX Item "--no-isolation" +Although the image understands isolation, do not isolate the image. +.IP "\fB\-\-no\-seh\fR" 4 +.IX Item "--no-seh" +The image does not use \s-1SEH\s0. No \s-1SE\s0 handler may be called from +this image. +.IP "\fB\-\-no\-bind\fR" 4 +.IX Item "--no-bind" +Do not bind this image. +.IP "\fB\-\-wdmdriver\fR" 4 +.IX Item "--wdmdriver" +The driver uses the \s-1MS\s0 Windows Driver Model. +.IP "\fB\-\-tsaware\fR" 4 +.IX Item "--tsaware" +The image is Terminal Server aware. .PP The 68HC11 and 68HC12 linkers support specific options to control the memory bank switching mapping and trampoline code generation. @@ -2135,6 +2296,15 @@ This option indicates to the linker the name of the memory region in the \fB\s-1MEMORY\s0\fR specification that describes the memory bank window. The definition of such region is then used by the linker to compute paging and addresses within the memory window. +.PP +The following options are supported to control handling of \s-1GOT\s0 generation +when linking for 68K targets. +.IP "\fB\-\-got=\fR\fItype\fR" 4 +.IX Item "--got=type" +This option tells the linker which \s-1GOT\s0 generation scheme to use. +\&\fItype\fR should be one of \fBsingle\fR, \fBnegative\fR, +\&\fBmultigot\fR or \fBtarget\fR. For more information refer to the +Info entry for \fIld\fR. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" You can change the behaviour of \fBld\fR with the environment variables @@ -2151,7 +2321,7 @@ this method often succeeds, but there are potential ambiguities, since there is no method of ensuring that the magic number used to specify object-file formats is unique. However, the configuration procedure for \&\s-1BFD\s0 on each system places the conventional format for that system first -in the search\-list, so ambiguities are resolved in favor of convention. +in the search-list, so ambiguities are resolved in favor of convention. .PP \&\f(CW\*(C`LDEMULATION\*(C'\fR determines the default emulation if you don't use the \&\fB\-m\fR option. The emulation can affect various aspects of linker @@ -2175,10 +2345,10 @@ the Info entries for \fIbinutils\fR and .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. .PP Permission is granted to copy, distribute and/or modify this document -under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the