Changeset 729 for trunk/src/binutils/ld/ld.1
- Timestamp:
- Sep 25, 2003, 9:27:01 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/binutils/ld/ld.1
-
Property cvs2svn:cvs-rev
changed from
1.1.1.2
to1.2
r728 r729 1 .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.132 .\"3 .\" Standard preamble:4 .\" ========================================================================5 .de Sh \" Subsection heading6 .br7 .if t .Sp8 .ne 59 .PP10 \fB\\$1\fR11 .PP12 ..13 .de Sp \" Vertical space (when we can't use .PP)14 .if t .sp .5v15 .if n .sp16 ..17 .de Vb \" Begin verbatim text18 .ft CW19 .nf20 .ne \\$121 ..22 .de Ve \" End verbatim text23 .ft R24 .fi25 ..26 .\" Set up some character translations and predefined strings. \*(-- will27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left28 .\" double quote, and \*(R" will give a right double quote. | will give a29 .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to30 .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'31 .\" expand to `' in nroff, nothing in troff, for use with C<>.32 .tr \(*W-|\(bv\*(Tr33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'34 .ie n \{\35 . ds -- \(*W-36 . ds PI pi37 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch38 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch39 . ds L" ""40 . ds R" ""41 . ds C` ""42 . ds C' ""43 'br\}44 .el\{\45 . ds -- \|\(em\|46 . ds PI \(*p47 . ds L" ``48 . ds R" ''49 'br\}50 .\"51 .\" If the F register is turned on, we'll generate index entries on stderr for52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index53 .\" entries marked with X<> in POD. Of course, you'll have to process the54 .\" output yourself in some meaningful fashion.55 .if \nF \{\56 . de IX57 . tm Index:\\$1\t\\n%\t"\\$2"58 ..59 . nr % 060 . rr F61 .\}62 .\"63 .\" For nroff, turn off justification. Always turn off hyphenation; it makes64 .\" way too many mistakes in technical documents.65 .hy 066 .\"67 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).68 .\" Fear. Run. Save yourself. No user-serviceable parts.69 . \" fudge factors for nroff and troff70 .if n \{\71 . ds #H 072 . ds #V .8m73 . ds #F .3m74 . ds #[ \f175 . ds #] \fP76 .\}77 .if t \{\78 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)79 . ds #V .6m80 . ds #F 081 . ds #[ \&82 . ds #] \&83 .\}84 . \" simple accents for nroff and troff85 .if n \{\86 . ds ' \&87 . ds ` \&88 . ds ^ \&89 . ds , \&90 . ds ~ ~91 . ds /92 .\}93 .if t \{\94 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"95 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'96 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'97 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'98 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'99 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'100 .\}101 . \" troff and (daisy-wheel) nroff accents102 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'103 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'104 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]105 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'106 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'107 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]108 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]109 .ds ae a\h'-(\w'a'u*4/10)'e110 .ds Ae A\h'-(\w'A'u*4/10)'E111 . \" corrections for vroff112 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'113 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'114 . \" for low resolution devices (crt and lpr)115 .if \n(.H>23 .if \n(.V>19 \116 \{\117 . ds : e118 . ds 8 ss119 . ds o a120 . ds d- d\h'-1'\(ga121 . ds D- D\h'-1'\(hy122 . ds th \o'bp'123 . ds Th \o'LP'124 . ds ae ae125 . ds Ae AE126 .\}127 .rm #[ #] #H #V #F C128 .\" ========================================================================129 .\"130 .IX Title "LD 1"131 .TH LD 1 "2003-06-12" "binutils-2.14" "GNU Development Tools"132 .SH "NAME"133 ld \- Using LD, the GNU linker134 .SH "SYNOPSIS"135 .IX Header "SYNOPSIS"136 ld [\fBoptions\fR] \fIobjfile\fR ...137 .SH "DESCRIPTION"138 .IX Header "DESCRIPTION"139 \&\fBld\fR combines a number of object and archive files, relocates140 their data and ties up symbol references. Usually the last step in141 compiling a program is to run \fBld\fR.142 .PP143 \&\fBld\fR accepts Linker Command Language files written in144 a superset of \s-1AT&T\s0's Link Editor Command Language syntax,145 to provide explicit and total control over the linking process.146 .PP147 This man page does not describe the command language; see the148 \&\fBld\fR entry in \f(CW\*(C`info\*(C'\fR, or the manual149 ld: the \s-1GNU\s0 linker, for full details on the command language and150 on other aspects of the \s-1GNU\s0 linker.151 .PP152 This version of \fBld\fR uses the general purpose \s-1BFD\s0 libraries153 to operate on object files. This allows \fBld\fR to read, combine, and154 write object files in many different formats\-\-\-for example, \s-1COFF\s0 or155 \&\f(CW\*(C`a.out\*(C'\fR. Different formats may be linked together to produce any156 available kind of object file.157 .PP158 Aside from its flexibility, the \s-1GNU\s0 linker is more helpful than other159 linkers in providing diagnostic information. Many linkers abandon160 execution immediately upon encountering an error; whenever possible,161 \&\fBld\fR continues executing, allowing you to identify other errors162 (or, in some cases, to get an output file in spite of the error).163 .PP164 The \s-1GNU\s0 linker \fBld\fR is meant to cover a broad range of situations,165 and to be as compatible as possible with other linkers. As a result,166 you have many choices to control its behavior.167 .SH "OPTIONS"168 .IX Header "OPTIONS"169 The linker supports a plethora of command-line options, but in actual170 practice few of them are used in any particular context.171 For instance, a frequent use of \fBld\fR is to link standard Unix172 object files on a standard, supported Unix system. On such a system, to173 link a file \f(CW\*(C`hello.o\*(C'\fR:174 .PP175 .Vb 1176 \& ld -o <output> /lib/crt0.o hello.o -lc177 .Ve178 .PP179 This tells \fBld\fR to produce a file called \fIoutput\fR as the180 result of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR and181 the library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard search182 directories. (See the discussion of the \fB\-l\fR option below.)183 .PP184 Some of the command-line options to \fBld\fR may be specified at any185 point in the command line. However, options which refer to files, such186 as \fB\-l\fR or \fB\-T\fR, cause the file to be read at the point at187 which the option appears in the command line, relative to the object188 files and other file options. Repeating non-file options with a189 different argument will either have no further effect, or override prior190 occurrences (those further to the left on the command line) of that191 option. Options which may be meaningfully specified more than once are192 noted in the descriptions below.193 .PP194 Non-option arguments are object files or archives which are to be linked195 together. They may follow, precede, or be mixed in with command-line196 options, except that an object file argument may not be placed between197 an option and its argument.198 .PP199 Usually the linker is invoked with at least one object file, but you can200 specify other forms of binary input files using \fB\-l\fR, \fB\-R\fR,201 and the script command language. If \fIno\fR binary input files at all202 are specified, the linker does not produce any output, and issues the203 message \fBNo input files\fR.204 .PP205 If the linker cannot recognize the format of an object file, it will206 assume that it is a linker script. A script specified in this way207 augments the main linker script used for the link (either the default208 linker script or the one specified by using \fB\-T\fR). This feature209 permits the linker to link against a file which appears to be an object210 or an archive, but actually merely defines some symbol values, or uses211 \&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Note that212 specifying a script in this way merely augments the main linker script;213 use the \fB\-T\fR option to replace the default linker script entirely.214 .PP215 For options whose names are a single letter,216 option arguments must either follow the option letter without intervening217 whitespace, or be given as separate arguments immediately following the218 option that requires them.219 .PP220 For options whose names are multiple letters, either one dash or two can221 precede the option name; for example, \fB\-trace\-symbol\fR and222 \&\fB\-\-trace\-symbol\fR are equivalent. Note\-\-\-there is one exception to223 this rule. Multiple letter options that start with a lower case 'o' can224 only be preceeded by two dashes. This is to reduce confusion with the225 \&\fB\-o\fR option. So for example \fB\-omagic\fR sets the output file226 name to \fBmagic\fR whereas \fB\-\-omagic\fR sets the \s-1NMAGIC\s0 flag on the227 output.228 .PP229 Arguments to multiple-letter options must either be separated from the230 option name by an equals sign, or be given as separate arguments231 immediately following the option that requires them. For example,232 \&\fB\-\-trace\-symbol foo\fR and \fB\-\-trace\-symbol=foo\fR are equivalent.233 Unique abbreviations of the names of multiple-letter options are234 accepted.235 .PP236 Note\-\-\-if the linker is being invoked indirectly, via a compiler driver237 (e.g. \fBgcc\fR) then all the linker command line options should be238 prefixed by \fB\-Wl,\fR (or whatever is appropriate for the particular239 compiler driver) like this:240 .PP241 .Vb 1242 \& gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup243 .Ve244 .PP245 This is important, because otherwise the compiler driver program may246 silently drop the linker options, resulting in a bad link.247 .PP248 Here is a table of the generic command line switches accepted by the \s-1GNU\s0249 linker:250 .IP "\fB\-a\fR\fIkeyword\fR" 4251 .IX Item "-akeyword"252 This option is supported for \s-1HP/UX\s0 compatibility. The \fIkeyword\fR253 argument must be one of the strings \fBarchive\fR, \fBshared\fR, or254 \&\fBdefault\fR. \fB\-aarchive\fR is functionally equivalent to255 \&\fB\-Bstatic\fR, and the other two keywords are functionally equivalent256 to \fB\-Bdynamic\fR. This option may be used any number of times.257 .IP "\fB\-A\fR\fIarchitecture\fR" 4258 .IX Item "-Aarchitecture"259 .PD 0260 .IP "\fB\-\-architecture=\fR\fIarchitecture\fR" 4261 .IX Item "--architecture=architecture"262 .PD263 In the current release of \fBld\fR, this option is useful only for the264 Intel 960 family of architectures. In that \fBld\fR configuration, the265 \&\fIarchitecture\fR argument identifies the particular architecture in266 the 960 family, enabling some safeguards and modifying the267 archive-library search path.268 .Sp269 Future releases of \fBld\fR may support similar functionality for270 other architecture families.271 .IP "\fB\-b\fR \fIinput-format\fR" 4272 .IX Item "-b input-format"273 .PD 0274 .IP "\fB\-\-format=\fR\fIinput-format\fR" 4275 .IX Item "--format=input-format"276 .PD277 \&\fBld\fR may be configured to support more than one kind of object278 file. If your \fBld\fR is configured this way, you can use the279 \&\fB\-b\fR option to specify the binary format for input object files280 that follow this option on the command line. Even when \fBld\fR is281 configured to support alternative object formats, you don't usually need282 to specify this, as \fBld\fR should be configured to expect as a283 default input format the most usual format on each machine.284 \&\fIinput-format\fR is a text string, the name of a particular format285 supported by the \s-1BFD\s0 libraries. (You can list the available binary286 formats with \fBobjdump \-i\fR.)287 .Sp288 You may want to use this option if you are linking files with an unusual289 binary format. You can also use \fB\-b\fR to switch formats explicitly (when290 linking object files of different formats), by including291 \&\fB\-b\fR \fIinput-format\fR before each group of object files in a292 particular format.293 .Sp294 The default format is taken from the environment variable295 \&\f(CW\*(C`GNUTARGET\*(C'\fR.296 .Sp297 You can also define the input format from a script, using the command298 \&\f(CW\*(C`TARGET\*(C'\fR;299 .IP "\fB\-c\fR \fIMRI-commandfile\fR" 4300 .IX Item "-c MRI-commandfile"301 .PD 0302 .IP "\fB\-\-mri\-script=\fR\fIMRI-commandfile\fR" 4303 .IX Item "--mri-script=MRI-commandfile"304 .PD305 For compatibility with linkers produced by \s-1MRI\s0, \fBld\fR accepts script306 files written in an alternate, restricted command language, described in307 the \s-1MRI\s0 Compatible Script Files section of \s-1GNU\s0 ld documentation.308 Introduce \s-1MRI\s0 script files with309 the option \fB\-c\fR; use the \fB\-T\fR option to run linker310 scripts written in the general-purpose \fBld\fR scripting language.311 If \fIMRI-cmdfile\fR does not exist, \fBld\fR looks for it in the directories312 specified by any \fB\-L\fR options.313 .IP "\fB\-d\fR" 4314 .IX Item "-d"315 .PD 0316 .IP "\fB\-dc\fR" 4317 .IX Item "-dc"318 .IP "\fB\-dp\fR" 4319 .IX Item "-dp"320 .PD321 These three options are equivalent; multiple forms are supported for322 compatibility with other linkers. They assign space to common symbols323 even if a relocatable output file is specified (with \fB\-r\fR). The324 script command \f(CW\*(C`FORCE_COMMON_ALLOCATION\*(C'\fR has the same effect.325 .IP "\fB\-e\fR \fIentry\fR" 4326 .IX Item "-e entry"327 .PD 0328 .IP "\fB\-\-entry=\fR\fIentry\fR" 4329 .IX Item "--entry=entry"330 .PD331 Use \fIentry\fR as the explicit symbol for beginning execution of your332 program, rather than the default entry point. If there is no symbol333 named \fIentry\fR, the linker will try to parse \fIentry\fR as a number,334 and use that as the entry address (the number will be interpreted in335 base 10; you may use a leading \fB0x\fR for base 16, or a leading336 \&\fB0\fR for base 8).337 .IP "\fB\-E\fR" 4338 .IX Item "-E"339 .PD 0340 .IP "\fB\-\-export\-dynamic\fR" 4341 .IX Item "--export-dynamic"342 .PD343 When creating a dynamically linked executable, add all symbols to the344 dynamic symbol table. The dynamic symbol table is the set of symbols345 which are visible from dynamic objects at run time.346 .Sp347 If you do not use this option, the dynamic symbol table will normally348 contain only those symbols which are referenced by some dynamic object349 mentioned in the link.350 .Sp351 If you use \f(CW\*(C`dlopen\*(C'\fR to load a dynamic object which needs to refer352 back to the symbols defined by the program, rather than some other353 dynamic object, then you will probably need to use this option when354 linking the program itself.355 .Sp356 You can also use the version script to control what symbols should357 be added to the dynamic symbol table if the output format supports it.358 See the description of \fB\-\-version\-script\fR in \f(CW@ref\fR{\s-1VERSION\s0}.359 .IP "\fB\-EB\fR" 4360 .IX Item "-EB"361 Link big-endian objects. This affects the default output format.362 .IP "\fB\-EL\fR" 4363 .IX Item "-EL"364 Link little-endian objects. This affects the default output format.365 .IP "\fB\-f\fR" 4366 .IX Item "-f"367 .PD 0368 .IP "\fB\-\-auxiliary\fR \fIname\fR" 4369 .IX Item "--auxiliary name"370 .PD371 When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_AUXILIARY\s0 field372 to the specified name. This tells the dynamic linker that the symbol373 table of the shared object should be used as an auxiliary filter on the374 symbol table of the shared object \fIname\fR.375 .Sp376 If you later link a program against this filter object, then, when you377 run the program, the dynamic linker will see the \s-1DT_AUXILIARY\s0 field. If378 the dynamic linker resolves any symbols from the filter object, it will379 first check whether there is a definition in the shared object380 \&\fIname\fR. If there is one, it will be used instead of the definition381 in the filter object. The shared object \fIname\fR need not exist.382 Thus the shared object \fIname\fR may be used to provide an alternative383 implementation of certain functions, perhaps for debugging or for384 machine specific performance.385 .Sp386 This option may be specified more than once. The \s-1DT_AUXILIARY\s0 entries387 will be created in the order in which they appear on the command line.388 .IP "\fB\-F\fR \fIname\fR" 4389 .IX Item "-F name"390 .PD 0391 .IP "\fB\-\-filter\fR \fIname\fR" 4392 .IX Item "--filter name"393 .PD394 When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_FILTER\s0 field to395 the specified name. This tells the dynamic linker that the symbol table396 of the shared object which is being created should be used as a filter397 on the symbol table of the shared object \fIname\fR.398 .Sp399 If you later link a program against this filter object, then, when you400 run the program, the dynamic linker will see the \s-1DT_FILTER\s0 field. The401 dynamic linker will resolve symbols according to the symbol table of the402 filter object as usual, but it will actually link to the definitions403 found in the shared object \fIname\fR. Thus the filter object can be404 used to select a subset of the symbols provided by the object405 \&\fIname\fR.406 .Sp407 Some older linkers used the \fB\-F\fR option throughout a compilation408 toolchain for specifying object-file format for both input and output409 object files.410 The \s-1GNU\s0 linker uses other mechanisms for this purpose: the411 \&\fB\-b\fR, \fB\-\-format\fR, \fB\-\-oformat\fR options, the412 \&\f(CW\*(C`TARGET\*(C'\fR command in linker scripts, and the \f(CW\*(C`GNUTARGET\*(C'\fR413 environment variable.414 The \s-1GNU\s0 linker will ignore the \fB\-F\fR option when not415 creating an \s-1ELF\s0 shared object.416 .IP "\fB\-fini\fR \fIname\fR" 4417 .IX Item "-fini name"418 When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the419 executable or shared object is unloaded, by setting \s-1DT_FINI\s0 to the420 address of the function. By default, the linker uses \f(CW\*(C`_fini\*(C'\fR as421 the function to call.422 .IP "\fB\-g\fR" 4423 .IX Item "-g"424 Ignored. Provided for compatibility with other tools.425 .IP "\fB\-G\fR\fIvalue\fR" 4426 .IX Item "-Gvalue"427 .PD 0428 .IP "\fB\-\-gpsize=\fR\fIvalue\fR" 4429 .IX Item "--gpsize=value"430 .PD431 Set the maximum size of objects to be optimized using the \s-1GP\s0 register to432 \&\fIsize\fR. This is only meaningful for object file formats such as433 \&\s-1MIPS\s0 \s-1ECOFF\s0 which supports putting large and small objects into different434 sections. This is ignored for other object file formats.435 .IP "\fB\-h\fR\fIname\fR" 4436 .IX Item "-hname"437 .PD 0438 .IP "\fB\-soname=\fR\fIname\fR" 4439 .IX Item "-soname=name"440 .PD441 When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_SONAME\s0 field to442 the specified name. When an executable is linked with a shared object443 which has a \s-1DT_SONAME\s0 field, then when the executable is run the dynamic444 linker will attempt to load the shared object specified by the \s-1DT_SONAME\s0445 field rather than the using the file name given to the linker.446 .IP "\fB\-i\fR" 4447 .IX Item "-i"448 Perform an incremental link (same as option \fB\-r\fR).449 .IP "\fB\-init\fR \fIname\fR" 4450 .IX Item "-init name"451 When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the452 executable or shared object is loaded, by setting \s-1DT_INIT\s0 to the address453 of the function. By default, the linker uses \f(CW\*(C`_init\*(C'\fR as the454 function to call.455 .IP "\fB\-l\fR\fIarchive\fR" 4456 .IX Item "-larchive"457 .PD 0458 .IP "\fB\-\-library=\fR\fIarchive\fR" 4459 .IX Item "--library=archive"460 .PD461 Add archive file \fIarchive\fR to the list of files to link. This462 option may be used any number of times. \fBld\fR will search its463 path-list for occurrences of \f(CW\*(C`lib\f(CIarchive\f(CW.a\*(C'\fR for every464 \&\fIarchive\fR specified.465 .Sp466 On systems which support shared libraries, \fBld\fR may also search for467 libraries with extensions other than \f(CW\*(C`.a\*(C'\fR. Specifically, on \s-1ELF\s0468 and SunOS systems, \fBld\fR will search a directory for a library with469 an extension of \f(CW\*(C`.so\*(C'\fR before searching for one with an extension of470 \&\f(CW\*(C`.a\*(C'\fR. By convention, a \f(CW\*(C`.so\*(C'\fR extension indicates a shared471 library.472 .Sp473 The linker will search an archive only once, at the location where it is474 specified on the command line. If the archive defines a symbol which475 was undefined in some object which appeared before the archive on the476 command line, the linker will include the appropriate file(s) from the477 archive. However, an undefined symbol in an object appearing later on478 the command line will not cause the linker to search the archive again.479 .Sp480 See the \fB\-(\fR option for a way to force the linker to search481 archives multiple times.482 .Sp483 You may list the same archive multiple times on the command line.484 .Sp485 This type of archive searching is standard for Unix linkers. However,486 if you are using \fBld\fR on \s-1AIX\s0, note that it is different from the487 behaviour of the \s-1AIX\s0 linker.488 .IP "\fB\-L\fR\fIsearchdir\fR" 4489 .IX Item "-Lsearchdir"490 .PD 0491 .IP "\fB\-\-library\-path=\fR\fIsearchdir\fR" 4492 .IX Item "--library-path=searchdir"493 .PD494 Add path \fIsearchdir\fR to the list of paths that \fBld\fR will search495 for archive libraries and \fBld\fR control scripts. You may use this496 option any number of times. The directories are searched in the order497 in which they are specified on the command line. Directories specified498 on the command line are searched before the default directories. All499 \&\fB\-L\fR options apply to all \fB\-l\fR options, regardless of the500 order in which the options appear.501 .Sp502 If \fIsearchdir\fR begins with \f(CW\*(C`=\*(C'\fR, then the \f(CW\*(C`=\*(C'\fR will be replaced503 by the \fIsysroot prefix\fR, a path specified when the linker is configured.504 .Sp505 The default set of paths searched (without being specified with506 \&\fB\-L\fR) depends on which emulation mode \fBld\fR is using, and in507 some cases also on how it was configured.508 .Sp509 The paths can also be specified in a link script with the510 \&\f(CW\*(C`SEARCH_DIR\*(C'\fR command. Directories specified this way are searched511 at the point in which the linker script appears in the command line.512 .IP "\fB\-m\fR\fIemulation\fR" 4513 .IX Item "-memulation"514 Emulate the \fIemulation\fR linker. You can list the available515 emulations with the \fB\-\-verbose\fR or \fB\-V\fR options.516 .Sp517 If the \fB\-m\fR option is not used, the emulation is taken from the518 \&\f(CW\*(C`LDEMULATION\*(C'\fR environment variable, if that is defined.519 .Sp520 Otherwise, the default emulation depends upon how the linker was521 configured.522 .IP "\fB\-M\fR" 4523 .IX Item "-M"524 .PD 0525 .IP "\fB\-\-print\-map\fR" 4526 .IX Item "--print-map"527 .PD528 Print a link map to the standard output. A link map provides529 information about the link, including the following:530 .RS 4531 .IP "\(bu" 4532 Where object files and symbols are mapped into memory.533 .IP "\(bu" 4534 How common symbols are allocated.535 .IP "\(bu" 4536 All archive members included in the link, with a mention of the symbol537 which caused the archive member to be brought in.538 .RE539 .RS 4540 .RE541 .IP "\fB\-n\fR" 4542 .IX Item "-n"543 .PD 0544 .IP "\fB\-\-nmagic\fR" 4545 .IX Item "--nmagic"546 .PD547 Turn off page alignment of sections, and mark the output as548 \&\f(CW\*(C`NMAGIC\*(C'\fR if possible.549 .IP "\fB\-N\fR" 4550 .IX Item "-N"551 .PD 0552 .IP "\fB\-\-omagic\fR" 4553 .IX Item "--omagic"554 .PD555 Set the text and data sections to be readable and writable. Also, do556 not page-align the data segment, and disable linking against shared557 libraries. If the output format supports Unix style magic numbers,558 mark the output as \f(CW\*(C`OMAGIC\*(C'\fR.559 .IP "\fB\-\-no\-omagic\fR" 4560 .IX Item "--no-omagic"561 This option negates most of the effects of the \fB\-N\fR option. It562 sets the text section to be read\-only, and forces the data segment to563 be page\-aligned. Note \- this option does not enable linking against564 shared libraries. Use \fB\-Bdynamic\fR for this.565 .IP "\fB\-o\fR \fIoutput\fR" 4566 .IX Item "-o output"567 .PD 0568 .IP "\fB\-\-output=\fR\fIoutput\fR" 4569 .IX Item "--output=output"570 .PD571 Use \fIoutput\fR as the name for the program produced by \fBld\fR; if this572 option is not specified, the name \fIa.out\fR is used by default. The573 script command \f(CW\*(C`OUTPUT\*(C'\fR can also specify the output file name.574 .IP "\fB\-O\fR \fIlevel\fR" 4575 .IX Item "-O level"576 If \fIlevel\fR is a numeric values greater than zero \fBld\fR optimizes577 the output. This might take significantly longer and therefore probably578 should only be enabled for the final binary.579 .IP "\fB\-q\fR" 4580 .IX Item "-q"581 .PD 0582 .IP "\fB\-\-emit\-relocs\fR" 4583 .IX Item "--emit-relocs"584 .PD585 Leave relocation sections and contents in fully linked exececutables.586 Post link analysis and optimization tools may need this information in587 order to perform correct modifications of executables. This results588 in larger executables.589 .Sp590 This option is currently only supported on \s-1ELF\s0 platforms.591 .IP "\fB\-r\fR" 4592 .IX Item "-r"593 .PD 0594 .IP "\fB\-\-relocateable\fR" 4595 .IX Item "--relocateable"596 .PD597 Generate relocatable output\-\-\-i.e., generate an output file that can in598 turn serve as input to \fBld\fR. This is often called \fIpartial599 linking\fR. As a side effect, in environments that support standard Unix600 magic numbers, this option also sets the output file's magic number to601 \&\f(CW\*(C`OMAGIC\*(C'\fR.602 If this option is not specified, an absolute file is produced. When603 linking \*(C+ programs, this option \fIwill not\fR resolve references to604 constructors; to do that, use \fB\-Ur\fR.605 .Sp606 When an input file does not have the same format as the output file,607 partial linking is only supported if that input file does not contain any608 relocations. Different output formats can have further restrictions; for609 example some \f(CW\*(C`a.out\*(C'\fR\-based formats do not support partial linking610 with input files in other formats at all.611 .Sp612 This option does the same thing as \fB\-i\fR.613 .IP "\fB\-R\fR \fIfilename\fR" 4614 .IX Item "-R filename"615 .PD 0616 .IP "\fB\-\-just\-symbols=\fR\fIfilename\fR" 4617 .IX Item "--just-symbols=filename"618 .PD619 Read symbol names and their addresses from \fIfilename\fR, but do not620 relocate it or include it in the output. This allows your output file621 to refer symbolically to absolute locations of memory defined in other622 programs. You may use this option more than once.623 .Sp624 For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is625 followed by a directory name, rather than a file name, it is treated as626 the \fB\-rpath\fR option.627 .IP "\fB\-s\fR" 4628 .IX Item "-s"629 .PD 0630 .IP "\fB\-\-strip\-all\fR" 4631 .IX Item "--strip-all"632 .PD633 Omit all symbol information from the output file.634 .IP "\fB\-S\fR" 4635 .IX Item "-S"636 .PD 0637 .IP "\fB\-\-strip\-debug\fR" 4638 .IX Item "--strip-debug"639 .PD640 Omit debugger symbol information (but not all symbols) from the output file.641 .IP "\fB\-t\fR" 4642 .IX Item "-t"643 .PD 0644 .IP "\fB\-\-trace\fR" 4645 .IX Item "--trace"646 .PD647 Print the names of the input files as \fBld\fR processes them.648 .IP "\fB\-T\fR \fIscriptfile\fR" 4649 .IX Item "-T scriptfile"650 .PD 0651 .IP "\fB\-\-script=\fR\fIscriptfile\fR" 4652 .IX Item "--script=scriptfile"653 .PD654 Use \fIscriptfile\fR as the linker script. This script replaces655 \&\fBld\fR's default linker script (rather than adding to it), so656 \&\fIcommandfile\fR must specify everything necessary to describe the657 output file. If \fIscriptfile\fR does not exist in658 the current directory, \f(CW\*(C`ld\*(C'\fR looks for it in the directories659 specified by any preceding \fB\-L\fR options. Multiple \fB\-T\fR660 options accumulate.661 .IP "\fB\-u\fR \fIsymbol\fR" 4662 .IX Item "-u symbol"663 .PD 0664 .IP "\fB\-\-undefined=\fR\fIsymbol\fR" 4665 .IX Item "--undefined=symbol"666 .PD667 Force \fIsymbol\fR to be entered in the output file as an undefined668 symbol. Doing this may, for example, trigger linking of additional669 modules from standard libraries. \fB\-u\fR may be repeated with670 different option arguments to enter additional undefined symbols. This671 option is equivalent to the \f(CW\*(C`EXTERN\*(C'\fR linker script command.672 .IP "\fB\-Ur\fR" 4673 .IX Item "-Ur"674 For anything other than \*(C+ programs, this option is equivalent to675 \&\fB\-r\fR: it generates relocatable output\-\-\-i.e., an output file that can in676 turn serve as input to \fBld\fR. When linking \*(C+ programs, \fB\-Ur\fR677 \&\fIdoes\fR resolve references to constructors, unlike \fB\-r\fR.678 It does not work to use \fB\-Ur\fR on files that were themselves linked679 with \fB\-Ur\fR; once the constructor table has been built, it cannot680 be added to. Use \fB\-Ur\fR only for the last partial link, and681 \&\fB\-r\fR for the others.682 .IP "\fB\-\-unique[=\fR\fI\s-1SECTION\s0\fR\fB]\fR" 4683 .IX Item "--unique[=SECTION]"684 Creates a separate output section for every input section matching685 \&\fI\s-1SECTION\s0\fR, or if the optional wildcard \fI\s-1SECTION\s0\fR argument is686 missing, for every orphan input section. An orphan section is one not687 specifically mentioned in a linker script. You may use this option688 multiple times on the command line; It prevents the normal merging of689 input sections with the same name, overriding output section assignments690 in a linker script.691 .IP "\fB\-v\fR" 4692 .IX Item "-v"693 .PD 0694 .IP "\fB\-\-version\fR" 4695 .IX Item "--version"696 .IP "\fB\-V\fR" 4697 .IX Item "-V"698 .PD699 Display the version number for \fBld\fR. The \fB\-V\fR option also700 lists the supported emulations.701 .IP "\fB\-x\fR" 4702 .IX Item "-x"703 .PD 0704 .IP "\fB\-\-discard\-all\fR" 4705 .IX Item "--discard-all"706 .PD707 Delete all local symbols.708 .IP "\fB\-X\fR" 4709 .IX Item "-X"710 .PD 0711 .IP "\fB\-\-discard\-locals\fR" 4712 .IX Item "--discard-locals"713 .PD714 Delete all temporary local symbols. For most targets, this is all local715 symbols whose names begin with \fBL\fR.716 .IP "\fB\-y\fR \fIsymbol\fR" 4717 .IX Item "-y symbol"718 .PD 0719 .IP "\fB\-\-trace\-symbol=\fR\fIsymbol\fR" 4720 .IX Item "--trace-symbol=symbol"721 .PD722 Print the name of each linked file in which \fIsymbol\fR appears. This723 option may be given any number of times. On many systems it is necessary724 to prepend an underscore.725 .Sp726 This option is useful when you have an undefined symbol in your link but727 don't know where the reference is coming from.728 .IP "\fB\-Y\fR \fIpath\fR" 4729 .IX Item "-Y path"730 Add \fIpath\fR to the default library search path. This option exists731 for Solaris compatibility.732 .IP "\fB\-z\fR \fIkeyword\fR" 4733 .IX Item "-z keyword"734 The recognized keywords are \f(CW\*(C`initfirst\*(C'\fR, \f(CW\*(C`interpose\*(C'\fR,735 \&\f(CW\*(C`loadfltr\*(C'\fR, \f(CW\*(C`nodefaultlib\*(C'\fR, \f(CW\*(C`nodelete\*(C'\fR, \f(CW\*(C`nodlopen\*(C'\fR,736 \&\f(CW\*(C`nodump\*(C'\fR, \f(CW\*(C`now\*(C'\fR, \f(CW\*(C`origin\*(C'\fR, \f(CW\*(C`combreloc\*(C'\fR, \f(CW\*(C`nocombreloc\*(C'\fR737 and \f(CW\*(C`nocopyreloc\*(C'\fR.738 The other keywords are739 ignored for Solaris compatibility. \f(CW\*(C`initfirst\*(C'\fR marks the object740 to be initialized first at runtime before any other objects.741 \&\f(CW\*(C`interpose\*(C'\fR marks the object that its symbol table interposes742 before all symbols but the primary executable. \f(CW\*(C`loadfltr\*(C'\fR marks743 the object that its filtees be processed immediately at runtime.744 \&\f(CW\*(C`nodefaultlib\*(C'\fR marks the object that the search for dependencies745 of this object will ignore any default library search paths.746 \&\f(CW\*(C`nodelete\*(C'\fR marks the object shouldn't be unloaded at runtime.747 \&\f(CW\*(C`nodlopen\*(C'\fR marks the object not available to \f(CW\*(C`dlopen\*(C'\fR.748 \&\f(CW\*(C`nodump\*(C'\fR marks the object can not be dumped by \f(CW\*(C`dldump\*(C'\fR.749 \&\f(CW\*(C`now\*(C'\fR marks the object with the non-lazy runtime binding.750 \&\f(CW\*(C`origin\*(C'\fR marks the object may contain \f(CW$ORIGIN\fR.751 \&\f(CW\*(C`defs\*(C'\fR disallows undefined symbols.752 \&\f(CW\*(C`muldefs\*(C'\fR allows multiple definitions.753 \&\f(CW\*(C`combreloc\*(C'\fR combines multiple reloc sections and sorts them754 to make dynamic symbol lookup caching possible.755 \&\f(CW\*(C`nocombreloc\*(C'\fR disables multiple reloc sections combining.756 \&\f(CW\*(C`nocopyreloc\*(C'\fR disables production of copy relocs.757 .IP "\fB\-(\fR \fIarchives\fR \fB\-)\fR" 4758 .IX Item "-( archives -)"759 .PD 0760 .IP "\fB\-\-start\-group\fR \fIarchives\fR \fB\-\-end\-group\fR" 4761 .IX Item "--start-group archives --end-group"762 .PD763 The \fIarchives\fR should be a list of archive files. They may be764 either explicit file names, or \fB\-l\fR options.765 .Sp766 The specified archives are searched repeatedly until no new undefined767 references are created. Normally, an archive is searched only once in768 the order that it is specified on the command line. If a symbol in that769 archive is needed to resolve an undefined symbol referred to by an770 object in an archive that appears later on the command line, the linker771 would not be able to resolve that reference. By grouping the archives,772 they all be searched repeatedly until all possible references are773 resolved.774 .Sp775 Using this option has a significant performance cost. It is best to use776 it only when there are unavoidable circular references between two or777 more archives.778 .IP "\fB\-\-accept\-unknown\-input\-arch\fR" 4779 .IX Item "--accept-unknown-input-arch"780 .PD 0781 .IP "\fB\-\-no\-accept\-unknown\-input\-arch\fR" 4782 .IX Item "--no-accept-unknown-input-arch"783 .PD784 Tells the linker to accept input files whose architecture cannot be785 recognised. The assumption is that the user knows what they are doing786 and deliberately wants to link in these unknown input files. This was787 the default behaviour of the linker, before release 2.14. The default788 behaviour from release 2.14 onwards is to reject such input files, and789 so the \fB\-\-accept\-unknown\-input\-arch\fR option has been added to790 restore the old behaviour.791 .IP "\fB\-assert\fR \fIkeyword\fR" 4792 .IX Item "-assert keyword"793 This option is ignored for SunOS compatibility.794 .IP "\fB\-Bdynamic\fR" 4795 .IX Item "-Bdynamic"796 .PD 0797 .IP "\fB\-dy\fR" 4798 .IX Item "-dy"799 .IP "\fB\-call_shared\fR" 4800 .IX Item "-call_shared"801 .PD802 Link against dynamic libraries. This is only meaningful on platforms803 for which shared libraries are supported. This option is normally the804 default on such platforms. The different variants of this option are805 for compatibility with various systems. You may use this option806 multiple times on the command line: it affects library searching for807 \&\fB\-l\fR options which follow it.808 .IP "\fB\-Bgroup\fR" 4809 .IX Item "-Bgroup"810 Set the \f(CW\*(C`DF_1_GROUP\*(C'\fR flag in the \f(CW\*(C`DT_FLAGS_1\*(C'\fR entry in the dynamic811 section. This causes the runtime linker to handle lookups in this812 object and its dependencies to be performed only inside the group.813 \&\fB\-\-no\-undefined\fR is implied. This option is only meaningful on \s-1ELF\s0814 platforms which support shared libraries.815 .IP "\fB\-Bstatic\fR" 4816 .IX Item "-Bstatic"817 .PD 0818 .IP "\fB\-dn\fR" 4819 .IX Item "-dn"820 .IP "\fB\-non_shared\fR" 4821 .IX Item "-non_shared"822 .IP "\fB\-static\fR" 4823 .IX Item "-static"824 .PD825 Do not link against shared libraries. This is only meaningful on826 platforms for which shared libraries are supported. The different827 variants of this option are for compatibility with various systems. You828 may use this option multiple times on the command line: it affects829 library searching for \fB\-l\fR options which follow it.830 .IP "\fB\-Bsymbolic\fR" 4831 .IX Item "-Bsymbolic"832 When creating a shared library, bind references to global symbols to the833 definition within the shared library, if any. Normally, it is possible834 for a program linked against a shared library to override the definition835 within the shared library. This option is only meaningful on \s-1ELF\s0836 platforms which support shared libraries.837 .IP "\fB\-\-check\-sections\fR" 4838 .IX Item "--check-sections"839 .PD 0840 .IP "\fB\-\-no\-check\-sections\fR" 4841 .IX Item "--no-check-sections"842 .PD843 Asks the linker \fInot\fR to check section addresses after they have844 been assigned to see if there any overlaps. Normally the linker will845 perform this check, and if it finds any overlaps it will produce846 suitable error messages. The linker does know about, and does make847 allowances for sections in overlays. The default behaviour can be848 restored by using the command line switch \fB\-\-check\-sections\fR.849 .IP "\fB\-\-cref\fR" 4850 .IX Item "--cref"851 Output a cross reference table. If a linker map file is being852 generated, the cross reference table is printed to the map file.853 Otherwise, it is printed on the standard output.854 .Sp855 The format of the table is intentionally simple, so that it may be856 easily processed by a script if necessary. The symbols are printed out,857 sorted by name. For each symbol, a list of file names is given. If the858 symbol is defined, the first file listed is the location of the859 definition. The remaining files contain references to the symbol.860 .IP "\fB\-\-no\-define\-common\fR" 4861 .IX Item "--no-define-common"862 This option inhibits the assignment of addresses to common symbols.863 The script command \f(CW\*(C`INHIBIT_COMMON_ALLOCATION\*(C'\fR has the same effect.864 .Sp865 The \fB\-\-no\-define\-common\fR option allows decoupling866 the decision to assign addresses to Common symbols from the choice867 of the output file type; otherwise a non-Relocatable output type868 forces assigning addresses to Common symbols.869 Using \fB\-\-no\-define\-common\fR allows Common symbols that are referenced870 from a shared library to be assigned addresses only in the main program.871 This eliminates the unused duplicate space in the shared library,872 and also prevents any possible confusion over resolving to the wrong873 duplicate when there are many dynamic modules with specialized search874 paths for runtime symbol resolution.875 .IP "\fB\-\-defsym\fR \fIsymbol\fR\fB=\fR\fIexpression\fR" 4876 .IX Item "--defsym symbol=expression"877 Create a global symbol in the output file, containing the absolute878 address given by \fIexpression\fR. You may use this option as many879 times as necessary to define multiple symbols in the command line. A880 limited form of arithmetic is supported for the \fIexpression\fR in this881 context: you may give a hexadecimal constant or the name of an existing882 symbol, or use \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`\-\*(C'\fR to add or subtract hexadecimal883 constants or symbols. If you need more elaborate expressions, consider884 using the linker command language from a script. \fINote:\fR there should be no white885 space between \fIsymbol\fR, the equals sign (``\fB=\fR''), and886 \&\fIexpression\fR.887 .IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4888 .IX Item "--demangle[=style]"889 .PD 0890 .IP "\fB\-\-no\-demangle\fR" 4891 .IX Item "--no-demangle"892 .PD893 These options control whether to demangle symbol names in error messages894 and other output. When the linker is told to demangle, it tries to895 present symbol names in a readable fashion: it strips leading896 underscores if they are used by the object file format, and converts \*(C+897 mangled symbol names into user readable names. Different compilers have898 different mangling styles. The optional demangling style argument can be used899 to choose an appropriate demangling style for your compiler. The linker will900 demangle by default unless the environment variable \fB\s-1COLLECT_NO_DEMANGLE\s0\fR901 is set. These options may be used to override the default.902 .IP "\fB\-\-dynamic\-linker\fR \fIfile\fR" 4903 .IX Item "--dynamic-linker file"904 Set the name of the dynamic linker. This is only meaningful when905 generating dynamically linked \s-1ELF\s0 executables. The default dynamic906 linker is normally correct; don't use this unless you know what you are907 doing.908 .IP "\fB\-\-embedded\-relocs\fR" 4909 .IX Item "--embedded-relocs"910 This option is only meaningful when linking \s-1MIPS\s0 embedded \s-1PIC\s0 code,911 generated by the \-membedded\-pic option to the \s-1GNU\s0 compiler and912 assembler. It causes the linker to create a table which may be used at913 runtime to relocate any data which was statically initialized to pointer914 values. See the code in testsuite/ld\-empic for details.915 .IP "\fB\-\-fatal\-warnings\fR" 4916 .IX Item "--fatal-warnings"917 Treat all warnings as errors.918 .IP "\fB\-\-force\-exe\-suffix\fR" 4919 .IX Item "--force-exe-suffix"920 Make sure that an output file has a .exe suffix.921 .Sp922 If a successfully built fully linked output file does not have a923 \&\f(CW\*(C`.exe\*(C'\fR or \f(CW\*(C`.dll\*(C'\fR suffix, this option forces the linker to copy924 the output file to one of the same name with a \f(CW\*(C`.exe\*(C'\fR suffix. This925 option is useful when using unmodified Unix makefiles on a Microsoft926 Windows host, since some versions of Windows won't run an image unless927 it ends in a \f(CW\*(C`.exe\*(C'\fR suffix.928 .IP "\fB\-\-no\-gc\-sections\fR" 4929 .IX Item "--no-gc-sections"930 .PD 0931 .IP "\fB\-\-gc\-sections\fR" 4932 .IX Item "--gc-sections"933 .PD934 Enable garbage collection of unused input sections. It is ignored on935 targets that do not support this option. This option is not compatible936 with \fB\-r\fR, nor should it be used with dynamic linking. The default937 behaviour (of not performing this garbage collection) can be restored by938 specifying \fB\-\-no\-gc\-sections\fR on the command line.939 .IP "\fB\-\-help\fR" 4940 .IX Item "--help"941 Print a summary of the command-line options on the standard output and exit.942 .IP "\fB\-\-target\-help\fR" 4943 .IX Item "--target-help"944 Print a summary of all target specific options on the standard output and exit.945 .IP "\fB\-Map\fR \fImapfile\fR" 4946 .IX Item "-Map mapfile"947 Print a link map to the file \fImapfile\fR. See the description of the948 \&\fB\-M\fR option, above.949 .IP "\fB\-\-no\-keep\-memory\fR" 4950 .IX Item "--no-keep-memory"951 \&\fBld\fR normally optimizes for speed over memory usage by caching the952 symbol tables of input files in memory. This option tells \fBld\fR to953 instead optimize for memory usage, by rereading the symbol tables as954 necessary. This may be required if \fBld\fR runs out of memory space955 while linking a large executable.956 .IP "\fB\-\-no\-undefined\fR" 4957 .IX Item "--no-undefined"958 .PD 0959 .IP "\fB\-z defs\fR" 4960 .IX Item "-z defs"961 .PD962 Normally when creating a non-symbolic shared library, undefined symbols963 are allowed and left to be resolved by the runtime loader. This option964 disallows such undefined symbols if they come from regular object965 files. The switch \fB\-\-no\-allow\-shlib\-undefined\fR controls the966 behaviour for shared objects being linked into the shared library.967 .IP "\fB\-\-allow\-multiple\-definition\fR" 4968 .IX Item "--allow-multiple-definition"969 .PD 0970 .IP "\fB\-z muldefs\fR" 4971 .IX Item "-z muldefs"972 .PD973 Normally when a symbol is defined multiple times, the linker will974 report a fatal error. These options allow multiple definitions and the975 first definition will be used.976 .IP "\fB\-\-allow\-shlib\-undefined\fR" 4977 .IX Item "--allow-shlib-undefined"978 .PD 0979 .IP "\fB\-\-no\-allow\-shlib\-undefined\fR" 4980 .IX Item "--no-allow-shlib-undefined"981 .PD982 Allow (the default) or disallow undefined symbols in shared objects.983 The setting of this switch overrides \fB\-\-no\-undefined\fR where984 shared objects are concerned. Thus if \fB\-\-no\-undefined\fR is set985 but \fB\-\-no\-allow\-shlib\-undefined\fR is not, the net result will be986 that undefined symbols in regular object files will trigger an error,987 but undefined symbols in shared objects will be ignored.988 .Sp989 The reason that \fB\-\-allow\-shlib\-undefined\fR is the default is that990 the shared object being specified at link time may not be the same one991 that is available at load time, so the symbols might actually be992 resolvable at load time. Plus there are some systems, (eg BeOS) where993 undefined symbols in shared libraries is normal since the kernel994 patches them at load time to select which function is most appropriate995 for the current architecture. eg. to dynamically select an appropriate996 memset function. Apparently it is also normal for \s-1HPPA\s0 shared997 libraries to have undefined symbols.998 .IP "\fB\-\-no\-undefined\-version\fR" 4999 .IX Item "--no-undefined-version"1000 Normally when a symbol has an undefined version, the linker will ignore1001 it. This option disallows symbols with undefined version and a fatal error1002 will be issued instead.1003 .IP "\fB\-\-no\-warn\-mismatch\fR" 41004 .IX Item "--no-warn-mismatch"1005 Normally \fBld\fR will give an error if you try to link together input1006 files that are mismatched for some reason, perhaps because they have1007 been compiled for different processors or for different endiannesses.1008 This option tells \fBld\fR that it should silently permit such possible1009 errors. This option should only be used with care, in cases when you1010 have taken some special action that ensures that the linker errors are1011 inappropriate.1012 .IP "\fB\-\-no\-whole\-archive\fR" 41013 .IX Item "--no-whole-archive"1014 Turn off the effect of the \fB\-\-whole\-archive\fR option for subsequent1015 archive files.1016 .IP "\fB\-\-noinhibit\-exec\fR" 41017 .IX Item "--noinhibit-exec"1018 Retain the executable output file whenever it is still usable.1019 Normally, the linker will not produce an output file if it encounters1020 errors during the link process; it exits without writing an output file1021 when it issues any error whatsoever.1022 .IP "\fB\-nostdlib\fR" 41023 .IX Item "-nostdlib"1024 Only search library directories explicitly specified on the1025 command line. Library directories specified in linker scripts1026 (including linker scripts specified on the command line) are ignored.1027 .IP "\fB\-\-oformat\fR \fIoutput-format\fR" 41028 .IX Item "--oformat output-format"1029 \&\fBld\fR may be configured to support more than one kind of object1030 file. If your \fBld\fR is configured this way, you can use the1031 \&\fB\-\-oformat\fR option to specify the binary format for the output1032 object file. Even when \fBld\fR is configured to support alternative1033 object formats, you don't usually need to specify this, as \fBld\fR1034 should be configured to produce as a default output format the most1035 usual format on each machine. \fIoutput-format\fR is a text string, the1036 name of a particular format supported by the \s-1BFD\s0 libraries. (You can1037 list the available binary formats with \fBobjdump \-i\fR.) The script1038 command \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR can also specify the output format, but1039 this option overrides it.1040 .IP "\fB\-qmagic\fR" 41041 .IX Item "-qmagic"1042 This option is ignored for Linux compatibility.1043 .IP "\fB\-Qy\fR" 41044 .IX Item "-Qy"1045 This option is ignored for \s-1SVR4\s0 compatibility.1046 .IP "\fB\-\-relax\fR" 41047 .IX Item "--relax"1048 An option with machine dependent effects.1049 This option is only supported on a few targets.1050 .Sp1051 On some platforms, the \fB\-\-relax\fR option performs global1052 optimizations that become possible when the linker resolves addressing1053 in the program, such as relaxing address modes and synthesizing new1054 instructions in the output object file.1055 .Sp1056 On some platforms these link time global optimizations may make symbolic1057 debugging of the resulting executable impossible.1058 This is known to be1059 the case for the Matsushita \s-1MN10200\s0 and \s-1MN10300\s0 family of processors.1060 .Sp1061 On platforms where this is not supported, \fB\-\-relax\fR is accepted,1062 but ignored.1063 .IP "\fB\-\-retain\-symbols\-file\fR \fIfilename\fR" 41064 .IX Item "--retain-symbols-file filename"1065 Retain \fIonly\fR the symbols listed in the file \fIfilename\fR,1066 discarding all others. \fIfilename\fR is simply a flat file, with one1067 symbol name per line. This option is especially useful in environments1068 (such as VxWorks)1069 where a large global symbol table is accumulated gradually, to conserve1070 run-time memory.1071 .Sp1072 \&\fB\-\-retain\-symbols\-file\fR does \fInot\fR discard undefined symbols,1073 or symbols needed for relocations.1074 .Sp1075 You may only specify \fB\-\-retain\-symbols\-file\fR once in the command1076 line. It overrides \fB\-s\fR and \fB\-S\fR.1077 .IP "\fB\-rpath\fR \fIdir\fR" 41078 .IX Item "-rpath dir"1079 Add a directory to the runtime library search path. This is used when1080 linking an \s-1ELF\s0 executable with shared objects. All \fB\-rpath\fR1081 arguments are concatenated and passed to the runtime linker, which uses1082 them to locate shared objects at runtime. The \fB\-rpath\fR option is1083 also used when locating shared objects which are needed by shared1084 objects explicitly included in the link; see the description of the1085 \&\fB\-rpath\-link\fR option. If \fB\-rpath\fR is not used when linking an1086 \&\s-1ELF\s0 executable, the contents of the environment variable1087 \&\f(CW\*(C`LD_RUN_PATH\*(C'\fR will be used if it is defined.1088 .Sp1089 The \fB\-rpath\fR option may also be used on SunOS. By default, on1090 SunOS, the linker will form a runtime search patch out of all the1091 \&\fB\-L\fR options it is given. If a \fB\-rpath\fR option is used, the1092 runtime search path will be formed exclusively using the \fB\-rpath\fR1093 options, ignoring the \fB\-L\fR options. This can be useful when using1094 gcc, which adds many \fB\-L\fR options which may be on \s-1NFS\s0 mounted1095 filesystems.1096 .Sp1097 For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is1098 followed by a directory name, rather than a file name, it is treated as1099 the \fB\-rpath\fR option.1100 .IP "\fB\-rpath\-link\fR \fI\s-1DIR\s0\fR" 41101 .IX Item "-rpath-link DIR"1102 When using \s-1ELF\s0 or SunOS, one shared library may require another. This1103 happens when an \f(CW\*(C`ld \-shared\*(C'\fR link includes a shared library as one1104 of the input files.1105 .Sp1106 When the linker encounters such a dependency when doing a non\-shared,1107 non-relocatable link, it will automatically try to locate the required1108 shared library and include it in the link, if it is not included1109 explicitly. In such a case, the \fB\-rpath\-link\fR option1110 specifies the first set of directories to search. The1111 \&\fB\-rpath\-link\fR option may specify a sequence of directory names1112 either by specifying a list of names separated by colons, or by1113 appearing multiple times.1114 .Sp1115 This option should be used with caution as it overrides the search path1116 that may have been hard compiled into a shared library. In such a case it1117 is possible to use unintentionally a different search path than the1118 runtime linker would do.1119 .Sp1120 The linker uses the following search paths to locate required shared1121 libraries.1122 .RS 41123 .IP "1." 41124 Any directories specified by \fB\-rpath\-link\fR options.1125 .IP "2." 41126 Any directories specified by \fB\-rpath\fR options. The difference1127 between \fB\-rpath\fR and \fB\-rpath\-link\fR is that directories1128 specified by \fB\-rpath\fR options are included in the executable and1129 used at runtime, whereas the \fB\-rpath\-link\fR option is only effective1130 at link time. It is for the native linker only.1131 .IP "3." 41132 On an \s-1ELF\s0 system, if the \fB\-rpath\fR and \f(CW\*(C`rpath\-link\*(C'\fR options1133 were not used, search the contents of the environment variable1134 \&\f(CW\*(C`LD_RUN_PATH\*(C'\fR. It is for the native linker only.1135 .IP "4." 41136 On SunOS, if the \fB\-rpath\fR option was not used, search any1137 directories specified using \fB\-L\fR options.1138 .IP "5." 41139 For a native linker, the contents of the environment variable1140 \&\f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR.1141 .IP "6." 41142 For a native \s-1ELF\s0 linker, the directories in \f(CW\*(C`DT_RUNPATH\*(C'\fR or1143 \&\f(CW\*(C`DT_RPATH\*(C'\fR of a shared library are searched for shared1144 libraries needed by it. The \f(CW\*(C`DT_RPATH\*(C'\fR entries are ignored if1145 \&\f(CW\*(C`DT_RUNPATH\*(C'\fR entries exist.1146 .IP "7." 41147 The default directories, normally \fI/lib\fR and \fI/usr/lib\fR.1148 .IP "8." 41149 For a native linker on an \s-1ELF\s0 system, if the file \fI/etc/ld.so.conf\fR1150 exists, the list of directories found in that file.1151 .RE1152 .RS 41153 .Sp1154 If the required shared library is not found, the linker will issue a1155 warning and continue with the link.1156 .RE1157 .IP "\fB\-shared\fR" 41158 .IX Item "-shared"1159 .PD 01160 .IP "\fB\-Bshareable\fR" 41161 .IX Item "-Bshareable"1162 .PD1163 Create a shared library. This is currently only supported on \s-1ELF\s0, \s-1XCOFF\s01164 and SunOS platforms. On SunOS, the linker will automatically create a1165 shared library if the \fB\-e\fR option is not used and there are1166 undefined symbols in the link.1167 .IP "\fB\-\-sort\-common\fR" 41168 .IX Item "--sort-common"1169 This option tells \fBld\fR to sort the common symbols by size when it1170 places them in the appropriate output sections. First come all the one1171 byte symbols, then all the two byte, then all the four byte, and then1172 everything else. This is to prevent gaps between symbols due to1173 alignment constraints.1174 .IP "\fB\-\-split\-by\-file [\fR\fIsize\fR\fB]\fR" 41175 .IX Item "--split-by-file [size]"1176 Similar to \fB\-\-split\-by\-reloc\fR but creates a new output section for1177 each input file when \fIsize\fR is reached. \fIsize\fR defaults to a1178 size of 1 if not given.1179 .IP "\fB\-\-split\-by\-reloc [\fR\fIcount\fR\fB]\fR" 41180 .IX Item "--split-by-reloc [count]"1181 Tries to creates extra sections in the output file so that no single1182 output section in the file contains more than \fIcount\fR relocations.1183 This is useful when generating huge relocatable files for downloading into1184 certain real time kernels with the \s-1COFF\s0 object file format; since \s-1COFF\s01185 cannot represent more than 65535 relocations in a single section. Note1186 that this will fail to work with object file formats which do not1187 support arbitrary sections. The linker will not split up individual1188 input sections for redistribution, so if a single input section contains1189 more than \fIcount\fR relocations one output section will contain that1190 many relocations. \fIcount\fR defaults to a value of 32768.1191 .IP "\fB\-\-stats\fR" 41192 .IX Item "--stats"1193 Compute and display statistics about the operation of the linker, such1194 as execution time and memory usage.1195 .IP "\fB\-\-traditional\-format\fR" 41196 .IX Item "--traditional-format"1197 For some targets, the output of \fBld\fR is different in some ways from1198 the output of some existing linker. This switch requests \fBld\fR to1199 use the traditional format instead.1200 .Sp1201 For example, on SunOS, \fBld\fR combines duplicate entries in the1202 symbol string table. This can reduce the size of an output file with1203 full debugging information by over 30 percent. Unfortunately, the SunOS1204 \&\f(CW\*(C`dbx\*(C'\fR program can not read the resulting program (\f(CW\*(C`gdb\*(C'\fR has no1205 trouble). The \fB\-\-traditional\-format\fR switch tells \fBld\fR to not1206 combine duplicate entries.1207 .IP "\fB\-\-section\-start\fR \fIsectionname\fR\fB=\fR\fIorg\fR" 41208 .IX Item "--section-start sectionname=org"1209 Locate a section in the output file at the absolute1210 address given by \fIorg\fR. You may use this option as many1211 times as necessary to locate multiple sections in the command1212 line.1213 \&\fIorg\fR must be a single hexadecimal integer;1214 for compatibility with other linkers, you may omit the leading1215 \&\fB0x\fR usually associated with hexadecimal values. \fINote:\fR there1216 should be no white space between \fIsectionname\fR, the equals1217 sign (``\fB=\fR''), and \fIorg\fR.1218 .IP "\fB\-Tbss\fR \fIorg\fR" 41219 .IX Item "-Tbss org"1220 .PD 01221 .IP "\fB\-Tdata\fR \fIorg\fR" 41222 .IX Item "-Tdata org"1223 .IP "\fB\-Ttext\fR \fIorg\fR" 41224 .IX Item "-Ttext org"1225 .PD1226 Same as \-\-section\-start, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or1227 \&\f(CW\*(C`.text\*(C'\fR as the \fIsectionname\fR.1228 .IP "\fB\-\-dll\-verbose\fR" 41229 .IX Item "--dll-verbose"1230 .PD 01231 .IP "\fB\-\-verbose\fR" 41232 .IX Item "--verbose"1233 .PD1234 Display the version number for \fBld\fR and list the linker emulations1235 supported. Display which input files can and cannot be opened. Display1236 the linker script being used by the linker.1237 .IP "\fB\-\-version\-script=\fR\fIversion-scriptfile\fR" 41238 .IX Item "--version-script=version-scriptfile"1239 Specify the name of a version script to the linker. This is typically1240 used when creating shared libraries to specify additional information1241 about the version hierarchy for the library being created. This option1242 is only meaningful on \s-1ELF\s0 platforms which support shared libraries.1243 .IP "\fB\-\-warn\-common\fR" 41244 .IX Item "--warn-common"1245 Warn when a common symbol is combined with another common symbol or with1246 a symbol definition. Unix linkers allow this somewhat sloppy practice,1247 but linkers on some other operating systems do not. This option allows1248 you to find potential problems from combining global symbols.1249 Unfortunately, some C libraries use this practice, so you may get some1250 warnings about symbols in the libraries as well as in your programs.1251 .Sp1252 There are three kinds of global symbols, illustrated here by C examples:1253 .RS 41254 .IP "\fBint i = 1;\fR" 41255 .IX Item "int i = 1;"1256 A definition, which goes in the initialized data section of the output1257 file.1258 .IP "\fBextern int i;\fR" 41259 .IX Item "extern int i;"1260 An undefined reference, which does not allocate space.1261 There must be either a definition or a common symbol for the1262 variable somewhere.1263 .IP "\fBint i;\fR" 41264 .IX Item "int i;"1265 A common symbol. If there are only (one or more) common symbols for a1266 variable, it goes in the uninitialized data area of the output file.1267 The linker merges multiple common symbols for the same variable into a1268 single symbol. If they are of different sizes, it picks the largest1269 size. The linker turns a common symbol into a declaration, if there is1270 a definition of the same variable.1271 .RE1272 .RS 41273 .Sp1274 The \fB\-\-warn\-common\fR option can produce five kinds of warnings.1275 Each warning consists of a pair of lines: the first describes the symbol1276 just encountered, and the second describes the previous symbol1277 encountered with the same name. One or both of the two symbols will be1278 a common symbol.1279 .IP "1." 41280 Turning a common symbol into a reference, because there is already a1281 definition for the symbol.1282 .Sp1283 .Vb 31284 \& <file>(<section>): warning: common of `<symbol>'1285 \& overridden by definition1286 \& <file>(<section>): warning: defined here1287 .Ve1288 .IP "2." 41289 Turning a common symbol into a reference, because a later definition for1290 the symbol is encountered. This is the same as the previous case,1291 except that the symbols are encountered in a different order.1292 .Sp1293 .Vb 31294 \& <file>(<section>): warning: definition of `<symbol>'1295 \& overriding common1296 \& <file>(<section>): warning: common is here1297 .Ve1298 .IP "3." 41299 Merging a common symbol with a previous same-sized common symbol.1300 .Sp1301 .Vb 31302 \& <file>(<section>): warning: multiple common1303 \& of `<symbol>'1304 \& <file>(<section>): warning: previous common is here1305 .Ve1306 .IP "4." 41307 Merging a common symbol with a previous larger common symbol.1308 .Sp1309 .Vb 31310 \& <file>(<section>): warning: common of `<symbol>'1311 \& overridden by larger common1312 \& <file>(<section>): warning: larger common is here1313 .Ve1314 .IP "5." 41315 Merging a common symbol with a previous smaller common symbol. This is1316 the same as the previous case, except that the symbols are1317 encountered in a different order.1318 .Sp1319 .Vb 31320 \& <file>(<section>): warning: common of `<symbol>'1321 \& overriding smaller common1322 \& <file>(<section>): warning: smaller common is here1323 .Ve1324 .RE1325 .RS 41326 .RE1327 .IP "\fB\-\-warn\-constructors\fR" 41328 .IX Item "--warn-constructors"1329 Warn if any global constructors are used. This is only useful for a few1330 object file formats. For formats like \s-1COFF\s0 or \s-1ELF\s0, the linker can not1331 detect the use of global constructors.1332 .IP "\fB\-\-warn\-multiple\-gp\fR" 41333 .IX Item "--warn-multiple-gp"1334 Warn if multiple global pointer values are required in the output file.1335 This is only meaningful for certain processors, such as the Alpha.1336 Specifically, some processors put large-valued constants in a special1337 section. A special register (the global pointer) points into the middle1338 of this section, so that constants can be loaded efficiently via a1339 base-register relative addressing mode. Since the offset in1340 base-register relative mode is fixed and relatively small (e.g., 161341 bits), this limits the maximum size of the constant pool. Thus, in1342 large programs, it is often necessary to use multiple global pointer1343 values in order to be able to address all possible constants. This1344 option causes a warning to be issued whenever this case occurs.1345 .IP "\fB\-\-warn\-once\fR" 41346 .IX Item "--warn-once"1347 Only warn once for each undefined symbol, rather than once per module1348 which refers to it.1349 .IP "\fB\-\-warn\-section\-align\fR" 41350 .IX Item "--warn-section-align"1351 Warn if the address of an output section is changed because of1352 alignment. Typically, the alignment will be set by an input section.1353 The address will only be changed if it not explicitly specified; that1354 is, if the \f(CW\*(C`SECTIONS\*(C'\fR command does not specify a start address for1355 the section.1356 .IP "\fB\-\-whole\-archive\fR" 41357 .IX Item "--whole-archive"1358 For each archive mentioned on the command line after the1359 \&\fB\-\-whole\-archive\fR option, include every object file in the archive1360 in the link, rather than searching the archive for the required object1361 files. This is normally used to turn an archive file into a shared1362 library, forcing every object to be included in the resulting shared1363 library. This option may be used more than once.1364 .Sp1365 Two notes when using this option from gcc: First, gcc doesn't know1366 about this option, so you have to use \fB\-Wl,\-whole\-archive\fR.1367 Second, don't forget to use \fB\-Wl,\-no\-whole\-archive\fR after your1368 list of archives, because gcc will add its own list of archives to1369 your link and you may not want this flag to affect those as well.1370 .IP "\fB\-\-wrap\fR \fIsymbol\fR" 41371 .IX Item "--wrap symbol"1372 Use a wrapper function for \fIsymbol\fR. Any undefined reference to1373 \&\fIsymbol\fR will be resolved to \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. Any1374 undefined reference to \f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR will be resolved to1375 \&\fIsymbol\fR.1376 .Sp1377 This can be used to provide a wrapper for a system function. The1378 wrapper function should be called \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. If it1379 wishes to call the system function, it should call1380 \&\f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR.1381 .Sp1382 Here is a trivial example:1383 .Sp1384 .Vb 61385 \& void *1386 \& __wrap_malloc (int c)1387 \& {1388 \& printf ("malloc called with %ld\en", c);1389 \& return __real_malloc (c);1390 \& }1391 .Ve1392 .Sp1393 If you link other code with this file using \fB\-\-wrap malloc\fR, then1394 all calls to \f(CW\*(C`malloc\*(C'\fR will call the function \f(CW\*(C`_\|_wrap_malloc\*(C'\fR1395 instead. The call to \f(CW\*(C`_\|_real_malloc\*(C'\fR in \f(CW\*(C`_\|_wrap_malloc\*(C'\fR will1396 call the real \f(CW\*(C`malloc\*(C'\fR function.1397 .Sp1398 You may wish to provide a \f(CW\*(C`_\|_real_malloc\*(C'\fR function as well, so that1399 links without the \fB\-\-wrap\fR option will succeed. If you do this,1400 you should not put the definition of \f(CW\*(C`_\|_real_malloc\*(C'\fR in the same1401 file as \f(CW\*(C`_\|_wrap_malloc\*(C'\fR; if you do, the assembler may resolve the1402 call before the linker has a chance to wrap it to \f(CW\*(C`malloc\*(C'\fR.1403 .IP "\fB\-\-enable\-new\-dtags\fR" 41404 .IX Item "--enable-new-dtags"1405 .PD 01406 .IP "\fB\-\-disable\-new\-dtags\fR" 41407 .IX Item "--disable-new-dtags"1408 .PD1409 This linker can create the new dynamic tags in \s-1ELF\s0. But the older \s-1ELF\s01410 systems may not understand them. If you specify1411 \&\fB\-\-enable\-new\-dtags\fR, the dynamic tags will be created as needed.1412 If you specify \fB\-\-disable\-new\-dtags\fR, no new dynamic tags will be1413 created. By default, the new dynamic tags are not created. Note that1414 those options are only available for \s-1ELF\s0 systems.1415 .PP1416 The i386 \s-1PE\s0 linker supports the \fB\-shared\fR option, which causes1417 the output to be a dynamically linked library (\s-1DLL\s0) instead of a1418 normal executable. You should name the output \f(CW\*(C`*.dll\*(C'\fR when you1419 use this option. In addition, the linker fully supports the standard1420 \&\f(CW\*(C`*.def\*(C'\fR files, which may be specified on the linker command line1421 like an object file (in fact, it should precede archives it exports1422 symbols from, to ensure that they get linked in, just like a normal1423 object file).1424 .PP1425 In addition to the options common to all targets, the i386 \s-1PE\s0 linker1426 support additional command line options that are specific to the i3861427 \&\s-1PE\s0 target. Options that take values may be separated from their1428 values by either a space or an equals sign.1429 .IP "\fB\-\-add\-stdcall\-alias\fR" 41430 .IX Item "--add-stdcall-alias"1431 If given, symbols with a stdcall suffix (@\fInn\fR) will be exported1432 as-is and also with the suffix stripped.1433 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1434 .IP "\fB\-\-base\-file\fR \fIfile\fR" 41435 .IX Item "--base-file file"1436 Use \fIfile\fR as the name of a file in which to save the base1437 addresses of all the relocations needed for generating DLLs with1438 \&\fIdlltool\fR.1439 [This is an i386 \s-1PE\s0 specific option]1440 .IP "\fB\-\-dll\fR" 41441 .IX Item "--dll"1442 Create a \s-1DLL\s0 instead of a regular executable. You may also use1443 \&\fB\-shared\fR or specify a \f(CW\*(C`LIBRARY\*(C'\fR in a given \f(CW\*(C`.def\*(C'\fR1444 file.1445 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1446 .IP "\fB\-\-enable\-stdcall\-fixup\fR" 41447 .IX Item "--enable-stdcall-fixup"1448 .PD 01449 .IP "\fB\-\-disable\-stdcall\-fixup\fR" 41450 .IX Item "--disable-stdcall-fixup"1451 .PD1452 If the link finds a symbol that it cannot resolve, it will attempt to1453 do ``fuzzy linking'' by looking for another defined symbol that differs1454 only in the format of the symbol name (cdecl vs stdcall) and will1455 resolve that symbol by linking to the match. For example, the1456 undefined symbol \f(CW\*(C`_foo\*(C'\fR might be linked to the function1457 \&\f(CW\*(C`_foo@12\*(C'\fR, or the undefined symbol \f(CW\*(C`_bar@16\*(C'\fR might be linked1458 to the function \f(CW\*(C`_bar\*(C'\fR. When the linker does this, it prints a1459 warning, since it normally should have failed to link, but sometimes1460 import libraries generated from third-party dlls may need this feature1461 to be usable. If you specify \fB\-\-enable\-stdcall\-fixup\fR, this1462 feature is fully enabled and warnings are not printed. If you specify1463 \&\fB\-\-disable\-stdcall\-fixup\fR, this feature is disabled and such1464 mismatches are considered to be errors.1465 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1466 .IP "\fB\-\-export\-all\-symbols\fR" 41467 .IX Item "--export-all-symbols"1468 If given, all global symbols in the objects used to build a \s-1DLL\s0 will1469 be exported by the \s-1DLL\s0. Note that this is the default if there1470 otherwise wouldn't be any exported symbols. When symbols are1471 explicitly exported via \s-1DEF\s0 files or implicitly exported via function1472 attributes, the default is to not export anything else unless this1473 option is given. Note that the symbols \f(CW\*(C`DllMain@12\*(C'\fR,1474 \&\f(CW\*(C`DllEntryPoint@0\*(C'\fR, \f(CW\*(C`DllMainCRTStartup@12\*(C'\fR, and1475 \&\f(CW\*(C`impure_ptr\*(C'\fR will not be automatically1476 exported. Also, symbols imported from other DLLs will not be1477 re\-exported, nor will symbols specifying the \s-1DLL\s0's internal layout1478 such as those beginning with \f(CW\*(C`_head_\*(C'\fR or ending with1479 \&\f(CW\*(C`_iname\*(C'\fR. In addition, no symbols from \f(CW\*(C`libgcc\*(C'\fR,1480 \&\f(CW\*(C`libstd++\*(C'\fR, \f(CW\*(C`libmingw32\*(C'\fR, or \f(CW\*(C`crtX.o\*(C'\fR will be exported.1481 Symbols whose names begin with \f(CW\*(C`_\|_rtti_\*(C'\fR or \f(CW\*(C`_\|_builtin_\*(C'\fR will1482 not be exported, to help with \*(C+ DLLs. Finally, there is an1483 extensive list of cygwin-private symbols that are not exported1484 (obviously, this applies on when building DLLs for cygwin targets).1485 These cygwin-excludes are: \f(CW\*(C`_cygwin_dll_entry@12\*(C'\fR,1486 \&\f(CW\*(C`_cygwin_crt0_common@8\*(C'\fR, \f(CW\*(C`_cygwin_noncygwin_dll_entry@12\*(C'\fR,1487 \&\f(CW\*(C`_fmode\*(C'\fR, \f(CW\*(C`_impure_ptr\*(C'\fR, \f(CW\*(C`cygwin_attach_dll\*(C'\fR,1488 \&\f(CW\*(C`cygwin_premain0\*(C'\fR, \f(CW\*(C`cygwin_premain1\*(C'\fR, \f(CW\*(C`cygwin_premain2\*(C'\fR,1489 \&\f(CW\*(C`cygwin_premain3\*(C'\fR, and \f(CW\*(C`environ\*(C'\fR.1490 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1491 .IP "\fB\-\-exclude\-symbols\fR \fIsymbol\fR\fB,\fR\fIsymbol\fR\fB,...\fR" 41492 .IX Item "--exclude-symbols symbol,symbol,..."1493 Specifies a list of symbols which should not be automatically1494 exported. The symbol names may be delimited by commas or colons.1495 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1496 .IP "\fB\-\-exclude\-libs\fR \fIlib\fR\fB,\fR\fIlib\fR\fB,...\fR" 41497 .IX Item "--exclude-libs lib,lib,..."1498 Specifies a list of archive libraries from which symbols should not be automatically1499 exported. The library names may be delimited by commas or colons. Specifying1500 \&\f(CW\*(C`\-\-exclude\-libs ALL\*(C'\fR excludes symbols in all archive libraries from1501 automatic export. Symbols explicitly listed in a .def file are still exported,1502 regardless of this option.1503 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1504 .IP "\fB\-\-file\-alignment\fR" 41505 .IX Item "--file-alignment"1506 Specify the file alignment. Sections in the file will always begin at1507 file offsets which are multiples of this number. This defaults to1508 512.1509 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1510 .IP "\fB\-\-heap\fR \fIreserve\fR" 41511 .IX Item "--heap reserve"1512 .PD 01513 .IP "\fB\-\-heap\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 41514 .IX Item "--heap reserve,commit"1515 .PD1516 Specify the amount of memory to reserve (and optionally commit) to be1517 used as heap for this program. The default is 1Mb reserved, 4K1518 committed.1519 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1520 .IP "\fB\-\-image\-base\fR \fIvalue\fR" 41521 .IX Item "--image-base value"1522 Use \fIvalue\fR as the base address of your program or dll. This is1523 the lowest memory location that will be used when your program or dll1524 is loaded. To reduce the need to relocate and improve performance of1525 your dlls, each should have a unique base address and not overlap any1526 other dlls. The default is 0x400000 for executables, and 0x100000001527 for dlls.1528 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1529 .IP "\fB\-\-kill\-at\fR" 41530 .IX Item "--kill-at"1531 If given, the stdcall suffixes (@\fInn\fR) will be stripped from1532 symbols before they are exported.1533 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1534 .IP "\fB\-\-major\-image\-version\fR \fIvalue\fR" 41535 .IX Item "--major-image-version value"1536 Sets the major number of the ``image version''. Defaults to 1.1537 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1538 .IP "\fB\-\-major\-os\-version\fR \fIvalue\fR" 41539 .IX Item "--major-os-version value"1540 Sets the major number of the ``os version''. Defaults to 4.1541 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1542 .IP "\fB\-\-major\-subsystem\-version\fR \fIvalue\fR" 41543 .IX Item "--major-subsystem-version value"1544 Sets the major number of the ``subsystem version''. Defaults to 4.1545 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1546 .IP "\fB\-\-minor\-image\-version\fR \fIvalue\fR" 41547 .IX Item "--minor-image-version value"1548 Sets the minor number of the ``image version''. Defaults to 0.1549 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1550 .IP "\fB\-\-minor\-os\-version\fR \fIvalue\fR" 41551 .IX Item "--minor-os-version value"1552 Sets the minor number of the ``os version''. Defaults to 0.1553 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1554 .IP "\fB\-\-minor\-subsystem\-version\fR \fIvalue\fR" 41555 .IX Item "--minor-subsystem-version value"1556 Sets the minor number of the ``subsystem version''. Defaults to 0.1557 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1558 .IP "\fB\-\-output\-def\fR \fIfile\fR" 41559 .IX Item "--output-def file"1560 The linker will create the file \fIfile\fR which will contain a \s-1DEF\s01561 file corresponding to the \s-1DLL\s0 the linker is generating. This \s-1DEF\s0 file1562 (which should be called \f(CW\*(C`*.def\*(C'\fR) may be used to create an import1563 library with \f(CW\*(C`dlltool\*(C'\fR or may be used as a reference to1564 automatically or implicitly exported symbols.1565 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1566 .IP "\fB\-\-out\-implib\fR \fIfile\fR" 41567 .IX Item "--out-implib file"1568 The linker will create the file \fIfile\fR which will contain an1569 import lib corresponding to the \s-1DLL\s0 the linker is generating. This1570 import lib (which should be called \f(CW\*(C`*.dll.a\*(C'\fR or \f(CW\*(C`*.a\*(C'\fR1571 may be used to link clients against the generated \s-1DLL\s0; this behavior1572 makes it possible to skip a separate \f(CW\*(C`dlltool\*(C'\fR import library1573 creation step.1574 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1575 .IP "\fB\-\-enable\-auto\-image\-base\fR" 41576 .IX Item "--enable-auto-image-base"1577 Automatically choose the image base for DLLs, unless one is specified1578 using the \f(CW\*(C`\-\-image\-base\*(C'\fR argument. By using a hash generated1579 from the dllname to create unique image bases for each \s-1DLL\s0, in-memory1580 collisions and relocations which can delay program execution are1581 avoided.1582 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1583 .IP "\fB\-\-disable\-auto\-image\-base\fR" 41584 .IX Item "--disable-auto-image-base"1585 Do not automatically generate a unique image base. If there is no1586 user-specified image base (\f(CW\*(C`\-\-image\-base\*(C'\fR) then use the platform1587 default.1588 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1589 .IP "\fB\-\-dll\-search\-prefix\fR \fIstring\fR" 41590 .IX Item "--dll-search-prefix string"1591 When linking dynamically to a dll without an import library,1592 search for \f(CW\*(C`<string><basename>.dll\*(C'\fR in preference to1593 \&\f(CW\*(C`lib<basename>.dll\*(C'\fR. This behavior allows easy distinction1594 between DLLs built for the various \*(L"subplatforms\*(R": native, cygwin,1595 uwin, pw, etc. For instance, cygwin DLLs typically use1596 \&\f(CW\*(C`\-\-dll\-search\-prefix=cyg\*(C'\fR.1597 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1598 .IP "\fB\-\-enable\-auto\-import\fR" 41599 .IX Item "--enable-auto-import"1600 Do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to \f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for1601 \&\s-1DATA\s0 imports from DLLs, and create the necessary thunking symbols when1602 building the import libraries with those \s-1DATA\s0 exports. This generally1603 will 'just work' \*(-- but sometimes you may see this message:1604 .Sp1605 "variable '<var>' can't be auto\-imported. Please read the1606 documentation for ld's \f(CW\*(C`\-\-enable\-auto\-import\*(C'\fR for details."1607 .Sp1608 This message occurs when some (sub)expression accesses an address1609 ultimately given by the sum of two constants (Win32 import tables only1610 allow one). Instances where this may occur include accesses to member1611 fields of struct variables imported from a \s-1DLL\s0, as well as using a1612 constant index into an array variable imported from a \s-1DLL\s0. Any1613 multiword variable (arrays, structs, long long, etc) may trigger1614 this error condition. However, regardless of the exact data type1615 of the offending exported variable, ld will always detect it, issue1616 the warning, and exit.1617 .Sp1618 There are several ways to address this difficulty, regardless of the1619 data type of the exported variable:1620 .Sp1621 One way is to use \-\-enable\-runtime\-pseudo\-reloc switch. This leaves the task1622 of adjusting references in your client code for runtime environment, so1623 this method works only when runtime environtment supports this feature.1624 .Sp1625 A second solution is to force one of the 'constants' to be a variable \*(--1626 that is, unknown and un-optimizable at compile time. For arrays,1627 there are two possibilities: a) make the indexee (the array's address)1628 a variable, or b) make the 'constant' index a variable. Thus:1629 .Sp1630 .Vb 31631 \& extern type extern_array[];1632 \& extern_array[1] -->1633 \& { volatile type *t=extern_array; t[1] }1634 .Ve1635 .Sp1636 or1637 .Sp1638 .Vb 31639 \& extern type extern_array[];1640 \& extern_array[1] -->1641 \& { volatile int t=1; extern_array[t] }1642 .Ve1643 .Sp1644 For structs (and most other multiword data types) the only option1645 is to make the struct itself (or the long long, or the ...) variable:1646 .Sp1647 .Vb 31648 \& extern struct s extern_struct;1649 \& extern_struct.field -->1650 \& { volatile struct s *t=&extern_struct; t->field }1651 .Ve1652 .Sp1653 or1654 .Sp1655 .Vb 31656 \& extern long long extern_ll;1657 \& extern_ll -->1658 \& { volatile long long * local_ll=&extern_ll; *local_ll }1659 .Ve1660 .Sp1661 A third method of dealing with this difficulty is to abandon1662 \&'auto\-import' for the offending symbol and mark it with1663 \&\f(CW\*(C`_\|_declspec(dllimport)\*(C'\fR. However, in practice that1664 requires using compile-time #defines to indicate whether you are1665 building a \s-1DLL\s0, building client code that will link to the \s-1DLL\s0, or1666 merely building/linking to a static library. In making the choice1667 between the various methods of resolving the 'direct address with1668 constant offset' problem, you should consider typical real-world usage:1669 .Sp1670 Original:1671 .Sp1672 .Vb 71673 \& --foo.h1674 \& extern int arr[];1675 \& --foo.c1676 \& #include "foo.h"1677 \& void main(int argc, char **argv){1678 \& printf("%d\en",arr[1]);1679 \& }1680 .Ve1681 .Sp1682 Solution 1:1683 .Sp1684 .Vb 91685 \& --foo.h1686 \& extern int arr[];1687 \& --foo.c1688 \& #include "foo.h"1689 \& void main(int argc, char **argv){1690 \& /* This workaround is for win32 and cygwin; do not "optimize" */1691 \& volatile int *parr = arr;1692 \& printf("%d\en",parr[1]);1693 \& }1694 .Ve1695 .Sp1696 Solution 2:1697 .Sp1698 .Vb 141699 \& --foo.h1700 \& /* Note: auto-export is assumed (no __declspec(dllexport)) */1701 \& #if (defined(_WIN32) || defined(__CYGWIN__)) && \e1702 \& !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))1703 \& #define FOO_IMPORT __declspec(dllimport)1704 \& #else1705 \& #define FOO_IMPORT1706 \& #endif1707 \& extern FOO_IMPORT int arr[];1708 \& --foo.c1709 \& #include "foo.h"1710 \& void main(int argc, char **argv){1711 \& printf("%d\en",arr[1]);1712 \& }1713 .Ve1714 .Sp1715 A fourth way to avoid this problem is to re-code your1716 library to use a functional interface rather than a data interface1717 for the offending variables (e.g. \fIset_foo()\fR and \fIget_foo()\fR accessor1718 functions).1719 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1720 .IP "\fB\-\-disable\-auto\-import\fR" 41721 .IX Item "--disable-auto-import"1722 Do not attempt to do sophisticalted linking of \f(CW\*(C`_symbol\*(C'\fR to1723 \&\f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for \s-1DATA\s0 imports from DLLs.1724 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1725 .IP "\fB\-\-enable\-runtime\-pseudo\-reloc\fR" 41726 .IX Item "--enable-runtime-pseudo-reloc"1727 If your code contains expressions described in \-\-enable\-auto\-import section,1728 that is, \s-1DATA\s0 imports from \s-1DLL\s0 with non-zero offset, this switch will create1729 a vector of 'runtime pseudo relocations' which can be used by runtime1730 environment to adjust references to such data in your client code.1731 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1732 .IP "\fB\-\-disable\-runtime\-pseudo\-reloc\fR" 41733 .IX Item "--disable-runtime-pseudo-reloc"1734 Do not create pseudo relocations for non-zero offset \s-1DATA\s0 imports from1735 DLLs. This is the default.1736 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1737 .IP "\fB\-\-enable\-extra\-pe\-debug\fR" 41738 .IX Item "--enable-extra-pe-debug"1739 Show additional debug info related to auto-import symbol thunking.1740 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1741 .IP "\fB\-\-section\-alignment\fR" 41742 .IX Item "--section-alignment"1743 Sets the section alignment. Sections in memory will always begin at1744 addresses which are a multiple of this number. Defaults to 0x1000.1745 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1746 .IP "\fB\-\-stack\fR \fIreserve\fR" 41747 .IX Item "--stack reserve"1748 .PD 01749 .IP "\fB\-\-stack\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 41750 .IX Item "--stack reserve,commit"1751 .PD1752 Specify the amount of memory to reserve (and optionally commit) to be1753 used as stack for this program. The default is 2Mb reserved, 4K1754 committed.1755 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1756 .IP "\fB\-\-subsystem\fR \fIwhich\fR" 41757 .IX Item "--subsystem which"1758 .PD 01759 .IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR" 41760 .IX Item "--subsystem which:major"1761 .IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR\fB.\fR\fIminor\fR" 41762 .IX Item "--subsystem which:major.minor"1763 .PD1764 Specifies the subsystem under which your program will execute. The1765 legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C'\fR,1766 \&\f(CW\*(C`console\*(C'\fR, and \f(CW\*(C`posix\*(C'\fR. You may optionally set the1767 subsystem version also.1768 [This option is specific to the i386 \s-1PE\s0 targeted port of the linker]1769 .SH "ENVIRONMENT"1770 .IX Header "ENVIRONMENT"1771 You can change the behavior of \fBld\fR with the environment variables1772 \&\f(CW\*(C`GNUTARGET\*(C'\fR,1773 \&\f(CW\*(C`LDEMULATION\*(C'\fR and \f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR.1774 .PP1775 \&\f(CW\*(C`GNUTARGET\*(C'\fR determines the input-file object format if you don't1776 use \fB\-b\fR (or its synonym \fB\-\-format\fR). Its value should be one1777 of the \s-1BFD\s0 names for an input format. If there is no1778 \&\f(CW\*(C`GNUTARGET\*(C'\fR in the environment, \fBld\fR uses the natural format1779 of the target. If \f(CW\*(C`GNUTARGET\*(C'\fR is set to \f(CW\*(C`default\*(C'\fR then \s-1BFD\s01780 attempts to discover the input format by examining binary input files;1781 this method often succeeds, but there are potential ambiguities, since1782 there is no method of ensuring that the magic number used to specify1783 object-file formats is unique. However, the configuration procedure for1784 \&\s-1BFD\s0 on each system places the conventional format for that system first1785 in the search\-list, so ambiguities are resolved in favor of convention.1786 .PP1787 \&\f(CW\*(C`LDEMULATION\*(C'\fR determines the default emulation if you don't use the1788 \&\fB\-m\fR option. The emulation can affect various aspects of linker1789 behaviour, particularly the default linker script. You can list the1790 available emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. If1791 the \fB\-m\fR option is not used, and the \f(CW\*(C`LDEMULATION\*(C'\fR environment1792 variable is not defined, the default emulation depends upon how the1793 linker was configured.1794 .PP1795 Normally, the linker will default to demangling symbols. However, if1796 \&\f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR is set in the environment, then it will1797 default to not demangling symbols. This environment variable is used in1798 a similar fashion by the \f(CW\*(C`gcc\*(C'\fR linker wrapper program. The default1799 may be overridden by the \fB\-\-demangle\fR and \fB\-\-no\-demangle\fR1800 options.1801 .SH "SEE ALSO"1802 .IX Header "SEE ALSO"1803 \&\fIar\fR\|(1), \fInm\fR\|(1), \fIobjcopy\fR\|(1), \fIobjdump\fR\|(1), \fIreadelf\fR\|(1) and1804 the Info entries for \fIbinutils\fR and1805 \&\fIld\fR.1806 .SH "COPYRIGHT"1807 .IX Header "COPYRIGHT"1808 Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001,1809 2002, 2003 Free Software Foundation, Inc.1810 .PP1811 Permission is granted to copy, distribute and/or modify this document1812 under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.11813 or any later version published by the Free Software Foundation;1814 with no Invariant Sections, with no Front-Cover Texts, and with no1815 Back-Cover Texts. A copy of the license is included in the1816 section entitled ``\s-1GNU\s0 Free Documentation License''. -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.