1 | This is ld.info, produced by makeinfo version 4.0 from ./ld.texinfo.
|
---|
2 |
|
---|
3 | START-INFO-DIR-ENTRY
|
---|
4 | * Ld: (ld). The GNU linker.
|
---|
5 | END-INFO-DIR-ENTRY
|
---|
6 |
|
---|
7 | This file documents the GNU linker LD version 2.11.2.
|
---|
8 |
|
---|
9 | Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free
|
---|
10 | Software Foundation, Inc.
|
---|
11 |
|
---|
12 |
|
---|
13 | File: ld.info, Node: Options, Next: Environment, Up: Invocation
|
---|
14 |
|
---|
15 | Command Line Options
|
---|
16 | ====================
|
---|
17 |
|
---|
18 | The linker supports a plethora of command-line options, but in actual
|
---|
19 | practice few of them are used in any particular context. For instance,
|
---|
20 | a frequent use of `ld' is to link standard Unix object files on a
|
---|
21 | standard, supported Unix system. On such a system, to link a file
|
---|
22 | `hello.o':
|
---|
23 |
|
---|
24 | ld -o OUTPUT /lib/crt0.o hello.o -lc
|
---|
25 |
|
---|
26 | This tells `ld' to produce a file called OUTPUT as the result of
|
---|
27 | linking the file `/lib/crt0.o' with `hello.o' and the library `libc.a',
|
---|
28 | which will come from the standard search directories. (See the
|
---|
29 | discussion of the `-l' option below.)
|
---|
30 |
|
---|
31 | Some of the command-line options to `ld' may be specified at any
|
---|
32 | point in the command line. However, options which refer to files, such
|
---|
33 | as `-l' or `-T', cause the file to be read at the point at which the
|
---|
34 | option appears in the command line, relative to the object files and
|
---|
35 | other file options. Repeating non-file options with a different
|
---|
36 | argument will either have no further effect, or override prior
|
---|
37 | occurrences (those further to the left on the command line) of that
|
---|
38 | option. Options which may be meaningfully specified more than once are
|
---|
39 | noted in the descriptions below.
|
---|
40 |
|
---|
41 | Non-option arguments are object files or archives which are to be
|
---|
42 | linked together. They may follow, precede, or be mixed in with
|
---|
43 | command-line options, except that an object file argument may not be
|
---|
44 | placed between an option and its argument.
|
---|
45 |
|
---|
46 | Usually the linker is invoked with at least one object file, but you
|
---|
47 | can specify other forms of binary input files using `-l', `-R', and the
|
---|
48 | script command language. If _no_ binary input files at all are
|
---|
49 | specified, the linker does not produce any output, and issues the
|
---|
50 | message `No input files'.
|
---|
51 |
|
---|
52 | If the linker can not recognize the format of an object file, it will
|
---|
53 | assume that it is a linker script. A script specified in this way
|
---|
54 | augments the main linker script used for the link (either the default
|
---|
55 | linker script or the one specified by using `-T'). This feature
|
---|
56 | permits the linker to link against a file which appears to be an object
|
---|
57 | or an archive, but actually merely defines some symbol values, or uses
|
---|
58 | `INPUT' or `GROUP' to load other objects. Note that specifying a
|
---|
59 | script in this way should only be used to augment the main linker
|
---|
60 | script; if you want to use some command that logically can only appear
|
---|
61 | once, such as the `SECTIONS' or `MEMORY' command, you must replace the
|
---|
62 | default linker script using the `-T' option. *Note Scripts::.
|
---|
63 |
|
---|
64 | For options whose names are a single letter, option arguments must
|
---|
65 | either follow the option letter without intervening whitespace, or be
|
---|
66 | given as separate arguments immediately following the option that
|
---|
67 | requires them.
|
---|
68 |
|
---|
69 | For options whose names are multiple letters, either one dash or two
|
---|
70 | can precede the option name; for example, `-trace-symbol' and
|
---|
71 | `--trace-symbol' are equivalent. Note - there is one exception to this
|
---|
72 | rule. Multiple letter options that start with a lower case 'o' can
|
---|
73 | only be preceeded by two dashes. This is to reduce confusion with the
|
---|
74 | `-o' option. So for example `-omagic' sets the output file name to
|
---|
75 | `magic' whereas `--omagic' sets the NMAGIC flag on the output.
|
---|
76 |
|
---|
77 | Arguments to multiple-letter options must either be separated from
|
---|
78 | the option name by an equals sign, or be given as separate arguments
|
---|
79 | immediately following the option that requires them. For example,
|
---|
80 | `--trace-symbol foo' and `--trace-symbol=foo' are equivalent. Unique
|
---|
81 | abbreviations of the names of multiple-letter options are accepted.
|
---|
82 |
|
---|
83 | Note - if the linker is being invoked indirectly, via a compiler
|
---|
84 | driver (eg `gcc') then all the linker command line options should be
|
---|
85 | prefixed by `-Wl,' (or whatever is appropriate for the particular
|
---|
86 | compiler driver) like this:
|
---|
87 |
|
---|
88 | gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup
|
---|
89 |
|
---|
90 | This is important, because otherwise the compiler driver program may
|
---|
91 | silently drop the linker options, resulting in a bad link.
|
---|
92 |
|
---|
93 | Here is a table of the generic command line switches accepted by the
|
---|
94 | GNU linker:
|
---|
95 |
|
---|
96 | `-aKEYWORD'
|
---|
97 | This option is supported for HP/UX compatibility. The KEYWORD
|
---|
98 | argument must be one of the strings `archive', `shared', or
|
---|
99 | `default'. `-aarchive' is functionally equivalent to `-Bstatic',
|
---|
100 | and the other two keywords are functionally equivalent to
|
---|
101 | `-Bdynamic'. This option may be used any number of times.
|
---|
102 |
|
---|
103 | `-AARCHITECTURE'
|
---|
104 | `--architecture=ARCHITECTURE'
|
---|
105 | In the current release of `ld', this option is useful only for the
|
---|
106 | Intel 960 family of architectures. In that `ld' configuration, the
|
---|
107 | ARCHITECTURE argument identifies the particular architecture in
|
---|
108 | the 960 family, enabling some safeguards and modifying the
|
---|
109 | archive-library search path. *Note `ld' and the Intel 960 family:
|
---|
110 | i960, for details.
|
---|
111 |
|
---|
112 | Future releases of `ld' may support similar functionality for
|
---|
113 | other architecture families.
|
---|
114 |
|
---|
115 | `-b INPUT-FORMAT'
|
---|
116 | `--format=INPUT-FORMAT'
|
---|
117 | `ld' may be configured to support more than one kind of object
|
---|
118 | file. If your `ld' is configured this way, you can use the `-b'
|
---|
119 | option to specify the binary format for input object files that
|
---|
120 | follow this option on the command line. Even when `ld' is
|
---|
121 | configured to support alternative object formats, you don't
|
---|
122 | usually need to specify this, as `ld' should be configured to
|
---|
123 | expect as a default input format the most usual format on each
|
---|
124 | machine. INPUT-FORMAT is a text string, the name of a particular
|
---|
125 | format supported by the BFD libraries. (You can list the
|
---|
126 | available binary formats with `objdump -i'.) *Note BFD::.
|
---|
127 |
|
---|
128 | You may want to use this option if you are linking files with an
|
---|
129 | unusual binary format. You can also use `-b' to switch formats
|
---|
130 | explicitly (when linking object files of different formats), by
|
---|
131 | including `-b INPUT-FORMAT' before each group of object files in a
|
---|
132 | particular format.
|
---|
133 |
|
---|
134 | The default format is taken from the environment variable
|
---|
135 | `GNUTARGET'. *Note Environment::. You can also define the input
|
---|
136 | format from a script, using the command `TARGET'; see *Note Format
|
---|
137 | Commands::.
|
---|
138 |
|
---|
139 | `-c MRI-COMMANDFILE'
|
---|
140 | `--mri-script=MRI-COMMANDFILE'
|
---|
141 | For compatibility with linkers produced by MRI, `ld' accepts script
|
---|
142 | files written in an alternate, restricted command language,
|
---|
143 | described in *Note MRI Compatible Script Files: MRI. Introduce
|
---|
144 | MRI script files with the option `-c'; use the `-T' option to run
|
---|
145 | linker scripts written in the general-purpose `ld' scripting
|
---|
146 | language. If MRI-CMDFILE does not exist, `ld' looks for it in the
|
---|
147 | directories specified by any `-L' options.
|
---|
148 |
|
---|
149 | `-d'
|
---|
150 | `-dc'
|
---|
151 | `-dp'
|
---|
152 | These three options are equivalent; multiple forms are supported
|
---|
153 | for compatibility with other linkers. They assign space to common
|
---|
154 | symbols even if a relocatable output file is specified (with
|
---|
155 | `-r'). The script command `FORCE_COMMON_ALLOCATION' has the same
|
---|
156 | effect. *Note Miscellaneous Commands::.
|
---|
157 |
|
---|
158 | `-e ENTRY'
|
---|
159 | `--entry=ENTRY'
|
---|
160 | Use ENTRY as the explicit symbol for beginning execution of your
|
---|
161 | program, rather than the default entry point. If there is no
|
---|
162 | symbol named ENTRY, the linker will try to parse ENTRY as a number,
|
---|
163 | and use that as the entry address (the number will be interpreted
|
---|
164 | in base 10; you may use a leading `0x' for base 16, or a leading
|
---|
165 | `0' for base 8). *Note Entry Point::, for a discussion of defaults
|
---|
166 | and other ways of specifying the entry point.
|
---|
167 |
|
---|
168 | `-E'
|
---|
169 | `--export-dynamic'
|
---|
170 | When creating a dynamically linked executable, add all symbols to
|
---|
171 | the dynamic symbol table. The dynamic symbol table is the set of
|
---|
172 | symbols which are visible from dynamic objects at run time.
|
---|
173 |
|
---|
174 | If you do not use this option, the dynamic symbol table will
|
---|
175 | normally contain only those symbols which are referenced by some
|
---|
176 | dynamic object mentioned in the link.
|
---|
177 |
|
---|
178 | If you use `dlopen' to load a dynamic object which needs to refer
|
---|
179 | back to the symbols defined by the program, rather than some other
|
---|
180 | dynamic object, then you will probably need to use this option when
|
---|
181 | linking the program itself.
|
---|
182 |
|
---|
183 | `-EB'
|
---|
184 | Link big-endian objects. This affects the default output format.
|
---|
185 |
|
---|
186 | `-EL'
|
---|
187 | Link little-endian objects. This affects the default output
|
---|
188 | format.
|
---|
189 |
|
---|
190 | `-f'
|
---|
191 | `--auxiliary NAME'
|
---|
192 | When creating an ELF shared object, set the internal DT_AUXILIARY
|
---|
193 | field to the specified name. This tells the dynamic linker that
|
---|
194 | the symbol table of the shared object should be used as an
|
---|
195 | auxiliary filter on the symbol table of the shared object NAME.
|
---|
196 |
|
---|
197 | If you later link a program against this filter object, then, when
|
---|
198 | you run the program, the dynamic linker will see the DT_AUXILIARY
|
---|
199 | field. If the dynamic linker resolves any symbols from the filter
|
---|
200 | object, it will first check whether there is a definition in the
|
---|
201 | shared object NAME. If there is one, it will be used instead of
|
---|
202 | the definition in the filter object. The shared object NAME need
|
---|
203 | not exist. Thus the shared object NAME may be used to provide an
|
---|
204 | alternative implementation of certain functions, perhaps for
|
---|
205 | debugging or for machine specific performance.
|
---|
206 |
|
---|
207 | This option may be specified more than once. The DT_AUXILIARY
|
---|
208 | entries will be created in the order in which they appear on the
|
---|
209 | command line.
|
---|
210 |
|
---|
211 | `-F NAME'
|
---|
212 | `--filter NAME'
|
---|
213 | When creating an ELF shared object, set the internal DT_FILTER
|
---|
214 | field to the specified name. This tells the dynamic linker that
|
---|
215 | the symbol table of the shared object which is being created
|
---|
216 | should be used as a filter on the symbol table of the shared
|
---|
217 | object NAME.
|
---|
218 |
|
---|
219 | If you later link a program against this filter object, then, when
|
---|
220 | you run the program, the dynamic linker will see the DT_FILTER
|
---|
221 | field. The dynamic linker will resolve symbols according to the
|
---|
222 | symbol table of the filter object as usual, but it will actually
|
---|
223 | link to the definitions found in the shared object NAME. Thus the
|
---|
224 | filter object can be used to select a subset of the symbols
|
---|
225 | provided by the object NAME.
|
---|
226 |
|
---|
227 | Some older linkers used the `-F' option throughout a compilation
|
---|
228 | toolchain for specifying object-file format for both input and
|
---|
229 | output object files. The GNU linker uses other mechanisms for this
|
---|
230 | purpose: the `-b', `--format', `--oformat' options, the `TARGET'
|
---|
231 | command in linker scripts, and the `GNUTARGET' environment
|
---|
232 | variable. The GNU linker will ignore the `-F' option when not
|
---|
233 | creating an ELF shared object.
|
---|
234 |
|
---|
235 | `-fini NAME'
|
---|
236 | When creating an ELF executable or shared object, call NAME when
|
---|
237 | the executable or shared object is unloaded, by setting DT_FINI to
|
---|
238 | the address of the function. By default, the linker uses `_fini'
|
---|
239 | as the function to call.
|
---|
240 |
|
---|
241 | `-g'
|
---|
242 | Ignored. Provided for compatibility with other tools.
|
---|
243 |
|
---|
244 | `-GVALUE'
|
---|
245 | `--gpsize=VALUE'
|
---|
246 | Set the maximum size of objects to be optimized using the GP
|
---|
247 | register to SIZE. This is only meaningful for object file formats
|
---|
248 | such as MIPS ECOFF which supports putting large and small objects
|
---|
249 | into different sections. This is ignored for other object file
|
---|
250 | formats.
|
---|
251 |
|
---|
252 | `-hNAME'
|
---|
253 | `-soname=NAME'
|
---|
254 | When creating an ELF shared object, set the internal DT_SONAME
|
---|
255 | field to the specified name. When an executable is linked with a
|
---|
256 | shared object which has a DT_SONAME field, then when the
|
---|
257 | executable is run the dynamic linker will attempt to load the
|
---|
258 | shared object specified by the DT_SONAME field rather than the
|
---|
259 | using the file name given to the linker.
|
---|
260 |
|
---|
261 | `-i'
|
---|
262 | Perform an incremental link (same as option `-r').
|
---|
263 |
|
---|
264 | `-init NAME'
|
---|
265 | When creating an ELF executable or shared object, call NAME when
|
---|
266 | the executable or shared object is loaded, by setting DT_INIT to
|
---|
267 | the address of the function. By default, the linker uses `_init'
|
---|
268 | as the function to call.
|
---|
269 |
|
---|
270 | `-lARCHIVE'
|
---|
271 | `--library=ARCHIVE'
|
---|
272 | Add archive file ARCHIVE to the list of files to link. This
|
---|
273 | option may be used any number of times. `ld' will search its
|
---|
274 | path-list for occurrences of `libARCHIVE.a' for every ARCHIVE
|
---|
275 | specified.
|
---|
276 |
|
---|
277 | On systems which support shared libraries, `ld' may also search for
|
---|
278 | libraries with extensions other than `.a'. Specifically, on ELF
|
---|
279 | and SunOS systems, `ld' will search a directory for a library with
|
---|
280 | an extension of `.so' before searching for one with an extension of
|
---|
281 | `.a'. By convention, a `.so' extension indicates a shared library.
|
---|
282 |
|
---|
283 | The linker will search an archive only once, at the location where
|
---|
284 | it is specified on the command line. If the archive defines a
|
---|
285 | symbol which was undefined in some object which appeared before
|
---|
286 | the archive on the command line, the linker will include the
|
---|
287 | appropriate file(s) from the archive. However, an undefined
|
---|
288 | symbol in an object appearing later on the command line will not
|
---|
289 | cause the linker to search the archive again.
|
---|
290 |
|
---|
291 | See the `-(' option for a way to force the linker to search
|
---|
292 | archives multiple times.
|
---|
293 |
|
---|
294 | You may list the same archive multiple times on the command line.
|
---|
295 |
|
---|
296 | This type of archive searching is standard for Unix linkers.
|
---|
297 | However, if you are using `ld' on AIX, note that it is different
|
---|
298 | from the behaviour of the AIX linker.
|
---|
299 |
|
---|
300 | `-LSEARCHDIR'
|
---|
301 | `--library-path=SEARCHDIR'
|
---|
302 | Add path SEARCHDIR to the list of paths that `ld' will search for
|
---|
303 | archive libraries and `ld' control scripts. You may use this
|
---|
304 | option any number of times. The directories are searched in the
|
---|
305 | order in which they are specified on the command line.
|
---|
306 | Directories specified on the command line are searched before the
|
---|
307 | default directories. All `-L' options apply to all `-l' options,
|
---|
308 | regardless of the order in which the options appear.
|
---|
309 |
|
---|
310 | The default set of paths searched (without being specified with
|
---|
311 | `-L') depends on which emulation mode `ld' is using, and in some
|
---|
312 | cases also on how it was configured. *Note Environment::.
|
---|
313 |
|
---|
314 | The paths can also be specified in a link script with the
|
---|
315 | `SEARCH_DIR' command. Directories specified this way are searched
|
---|
316 | at the point in which the linker script appears in the command
|
---|
317 | line.
|
---|
318 |
|
---|
319 | `-mEMULATION'
|
---|
320 | Emulate the EMULATION linker. You can list the available
|
---|
321 | emulations with the `--verbose' or `-V' options.
|
---|
322 |
|
---|
323 | If the `-m' option is not used, the emulation is taken from the
|
---|
324 | `LDEMULATION' environment variable, if that is defined.
|
---|
325 |
|
---|
326 | Otherwise, the default emulation depends upon how the linker was
|
---|
327 | configured.
|
---|
328 |
|
---|
329 | `-M'
|
---|
330 | `--print-map'
|
---|
331 | Print a link map to the standard output. A link map provides
|
---|
332 | information about the link, including the following:
|
---|
333 |
|
---|
334 | * Where object files and symbols are mapped into memory.
|
---|
335 |
|
---|
336 | * How common symbols are allocated.
|
---|
337 |
|
---|
338 | * All archive members included in the link, with a mention of
|
---|
339 | the symbol which caused the archive member to be brought in.
|
---|
340 |
|
---|
341 | `-n'
|
---|
342 | `--nmagic'
|
---|
343 | Turn off page alignment of sections, and mark the output as
|
---|
344 | `NMAGIC' if possible.
|
---|
345 |
|
---|
346 | `-N'
|
---|
347 | `--omagic'
|
---|
348 | Set the text and data sections to be readable and writable. Also,
|
---|
349 | do not page-align the data segment. If the output format supports
|
---|
350 | Unix style magic numbers, mark the output as `OMAGIC'.
|
---|
351 |
|
---|
352 | `-o OUTPUT'
|
---|
353 | `--output=OUTPUT'
|
---|
354 | Use OUTPUT as the name for the program produced by `ld'; if this
|
---|
355 | option is not specified, the name `a.out' is used by default. The
|
---|
356 | script command `OUTPUT' can also specify the output file name.
|
---|
357 |
|
---|
358 | `-O LEVEL'
|
---|
359 | If LEVEL is a numeric values greater than zero `ld' optimizes the
|
---|
360 | output. This might take significantly longer and therefore
|
---|
361 | probably should only be enabled for the final binary.
|
---|
362 |
|
---|
363 | `-q'
|
---|
364 | `--emit-relocs'
|
---|
365 | Leave relocation sections and contents in fully linked
|
---|
366 | exececutables. Post link analysis and optimization tools may need
|
---|
367 | this information in order to perform correct modifications of
|
---|
368 | executables. This results in larger executables.
|
---|
369 |
|
---|
370 | `-r'
|
---|
371 | `--relocateable'
|
---|
372 | Generate relocatable output--i.e., generate an output file that
|
---|
373 | can in turn serve as input to `ld'. This is often called "partial
|
---|
374 | linking". As a side effect, in environments that support standard
|
---|
375 | Unix magic numbers, this option also sets the output file's magic
|
---|
376 | number to `OMAGIC'. If this option is not specified, an absolute
|
---|
377 | file is produced. When linking C++ programs, this option _will
|
---|
378 | not_ resolve references to constructors; to do that, use `-Ur'.
|
---|
379 |
|
---|
380 | This option does the same thing as `-i'.
|
---|
381 |
|
---|
382 | `-R FILENAME'
|
---|
383 | `--just-symbols=FILENAME'
|
---|
384 | Read symbol names and their addresses from FILENAME, but do not
|
---|
385 | relocate it or include it in the output. This allows your output
|
---|
386 | file to refer symbolically to absolute locations of memory defined
|
---|
387 | in other programs. You may use this option more than once.
|
---|
388 |
|
---|
389 | For compatibility with other ELF linkers, if the `-R' option is
|
---|
390 | followed by a directory name, rather than a file name, it is
|
---|
391 | treated as the `-rpath' option.
|
---|
392 |
|
---|
393 | `-s'
|
---|
394 | `--strip-all'
|
---|
395 | Omit all symbol information from the output file.
|
---|
396 |
|
---|
397 | `-S'
|
---|
398 | `--strip-debug'
|
---|
399 | Omit debugger symbol information (but not all symbols) from the
|
---|
400 | output file.
|
---|
401 |
|
---|
402 | `-t'
|
---|
403 | `--trace'
|
---|
404 | Print the names of the input files as `ld' processes them.
|
---|
405 |
|
---|
406 | `-T SCRIPTFILE'
|
---|
407 | `--script=SCRIPTFILE'
|
---|
408 | Use SCRIPTFILE as the linker script. This script replaces `ld''s
|
---|
409 | default linker script (rather than adding to it), so COMMANDFILE
|
---|
410 | must specify everything necessary to describe the output file.
|
---|
411 | You must use this option if you want to use a command which can
|
---|
412 | only appear once in a linker script, such as the `SECTIONS' or
|
---|
413 | `MEMORY' command. *Note Scripts::. If SCRIPTFILE does not exist
|
---|
414 | in the current directory, `ld' looks for it in the directories
|
---|
415 | specified by any preceding `-L' options. Multiple `-T' options
|
---|
416 | accumulate.
|
---|
417 |
|
---|
418 | `-u SYMBOL'
|
---|
419 | `--undefined=SYMBOL'
|
---|
420 | Force SYMBOL to be entered in the output file as an undefined
|
---|
421 | symbol. Doing this may, for example, trigger linking of additional
|
---|
422 | modules from standard libraries. `-u' may be repeated with
|
---|
423 | different option arguments to enter additional undefined symbols.
|
---|
424 | This option is equivalent to the `EXTERN' linker script command.
|
---|
425 |
|
---|
426 | `-Ur'
|
---|
427 | For anything other than C++ programs, this option is equivalent to
|
---|
428 | `-r': it generates relocatable output--i.e., an output file that
|
---|
429 | can in turn serve as input to `ld'. When linking C++ programs,
|
---|
430 | `-Ur' _does_ resolve references to constructors, unlike `-r'. It
|
---|
431 | does not work to use `-Ur' on files that were themselves linked
|
---|
432 | with `-Ur'; once the constructor table has been built, it cannot
|
---|
433 | be added to. Use `-Ur' only for the last partial link, and `-r'
|
---|
434 | for the others.
|
---|
435 |
|
---|
436 | `--unique[=SECTION]'
|
---|
437 | Creates a separate output section for every input section matching
|
---|
438 | SECTION, or if the optional wildcard SECTION argument is missing,
|
---|
439 | for every orphan input section. An orphan section is one not
|
---|
440 | specifically mentioned in a linker script. You may use this option
|
---|
441 | multiple times on the command line; It prevents the normal
|
---|
442 | merging of input sections with the same name, overriding output
|
---|
443 | section assignments in a linker script.
|
---|
444 |
|
---|
445 | `-v'
|
---|
446 | `--version'
|
---|
447 | `-V'
|
---|
448 | Display the version number for `ld'. The `-V' option also lists
|
---|
449 | the supported emulations.
|
---|
450 |
|
---|
451 | `-x'
|
---|
452 | `--discard-all'
|
---|
453 | Delete all local symbols.
|
---|
454 |
|
---|
455 | `-X'
|
---|
456 | `--discard-locals'
|
---|
457 | Delete all temporary local symbols. For most targets, this is all
|
---|
458 | local symbols whose names begin with `L'.
|
---|
459 |
|
---|
460 | `-y SYMBOL'
|
---|
461 | `--trace-symbol=SYMBOL'
|
---|
462 | Print the name of each linked file in which SYMBOL appears. This
|
---|
463 | option may be given any number of times. On many systems it is
|
---|
464 | necessary to prepend an underscore.
|
---|
465 |
|
---|
466 | This option is useful when you have an undefined symbol in your
|
---|
467 | link but don't know where the reference is coming from.
|
---|
468 |
|
---|
469 | `-Y PATH'
|
---|
470 | Add PATH to the default library search path. This option exists
|
---|
471 | for Solaris compatibility.
|
---|
472 |
|
---|
473 | `-z KEYWORD'
|
---|
474 | The recognized keywords are `initfirst', `interpose', `loadfltr',
|
---|
475 | `nodefaultlib', `nodelete', `nodlopen', `nodump', `now' and
|
---|
476 | `origin'. The other keywords are ignored for Solaris
|
---|
477 | compatibility. `initfirst' marks the object to be initialized
|
---|
478 | first at runtime before any other objects. `interpose' marks the
|
---|
479 | object that its symbol table interposes before all symbols but the
|
---|
480 | primary executable. `loadfltr' marks the object that its filtees
|
---|
481 | be processed immediately at runtime. `nodefaultlib' marks the
|
---|
482 | object that the search for dependencies of this object will ignore
|
---|
483 | any default library search paths. `nodelete' marks the object
|
---|
484 | shouldn't be unloaded at runtime. `nodlopen' marks the object not
|
---|
485 | available to `dlopen'. `nodump' marks the object can not be
|
---|
486 | dumped by `dldump'. `now' marks the object with the non-lazy
|
---|
487 | runtime binding. `origin' marks the object may contain $ORIGIN.
|
---|
488 | `defs' disallows undefined symbols.
|
---|
489 |
|
---|
490 | `-( ARCHIVES -)'
|
---|
491 | `--start-group ARCHIVES --end-group'
|
---|
492 | The ARCHIVES should be a list of archive files. They may be
|
---|
493 | either explicit file names, or `-l' options.
|
---|
494 |
|
---|
495 | The specified archives are searched repeatedly until no new
|
---|
496 | undefined references are created. Normally, an archive is
|
---|
497 | searched only once in the order that it is specified on the
|
---|
498 | command line. If a symbol in that archive is needed to resolve an
|
---|
499 | undefined symbol referred to by an object in an archive that
|
---|
500 | appears later on the command line, the linker would not be able to
|
---|
501 | resolve that reference. By grouping the archives, they all be
|
---|
502 | searched repeatedly until all possible references are resolved.
|
---|
503 |
|
---|
504 | Using this option has a significant performance cost. It is best
|
---|
505 | to use it only when there are unavoidable circular references
|
---|
506 | between two or more archives.
|
---|
507 |
|
---|
508 | `-assert KEYWORD'
|
---|
509 | This option is ignored for SunOS compatibility.
|
---|
510 |
|
---|
511 | `-Bdynamic'
|
---|
512 | `-dy'
|
---|
513 | `-call_shared'
|
---|
514 | Link against dynamic libraries. This is only meaningful on
|
---|
515 | platforms for which shared libraries are supported. This option
|
---|
516 | is normally the default on such platforms. The different variants
|
---|
517 | of this option are for compatibility with various systems. You
|
---|
518 | may use this option multiple times on the command line: it affects
|
---|
519 | library searching for `-l' options which follow it.
|
---|
520 |
|
---|
521 | `-Bgroup'
|
---|
522 | Set the `DF_1_GROUP' flag in the `DT_FLAGS_1' entry in the dynamic
|
---|
523 | section. This causes the runtime linker to handle lookups in this
|
---|
524 | object and its dependencies to be performed only inside the group.
|
---|
525 | `--no-undefined' is implied. This option is only meaningful on ELF
|
---|
526 | platforms which support shared libraries.
|
---|
527 |
|
---|
528 | `-Bstatic'
|
---|
529 | `-dn'
|
---|
530 | `-non_shared'
|
---|
531 | `-static'
|
---|
532 | Do not link against shared libraries. This is only meaningful on
|
---|
533 | platforms for which shared libraries are supported. The different
|
---|
534 | variants of this option are for compatibility with various
|
---|
535 | systems. You may use this option multiple times on the command
|
---|
536 | line: it affects library searching for `-l' options which follow
|
---|
537 | it.
|
---|
538 |
|
---|
539 | `-Bsymbolic'
|
---|
540 | When creating a shared library, bind references to global symbols
|
---|
541 | to the definition within the shared library, if any. Normally, it
|
---|
542 | is possible for a program linked against a shared library to
|
---|
543 | override the definition within the shared library. This option is
|
---|
544 | only meaningful on ELF platforms which support shared libraries.
|
---|
545 |
|
---|
546 | `--check-sections'
|
---|
547 | `--no-check-sections'
|
---|
548 | Asks the linker _not_ to check section addresses after they have
|
---|
549 | been assigned to see if there any overlaps. Normally the linker
|
---|
550 | will perform this check, and if it finds any overlaps it will
|
---|
551 | produce suitable error messages. The linker does know about, and
|
---|
552 | does make allowances for sections in overlays. The default
|
---|
553 | behaviour can be restored by using the command line switch
|
---|
554 | `--check-sections'.
|
---|
555 |
|
---|
556 | `--cref'
|
---|
557 | Output a cross reference table. If a linker map file is being
|
---|
558 | generated, the cross reference table is printed to the map file.
|
---|
559 | Otherwise, it is printed on the standard output.
|
---|
560 |
|
---|
561 | The format of the table is intentionally simple, so that it may be
|
---|
562 | easily processed by a script if necessary. The symbols are
|
---|
563 | printed out, sorted by name. For each symbol, a list of file
|
---|
564 | names is given. If the symbol is defined, the first file listed
|
---|
565 | is the location of the definition. The remaining files contain
|
---|
566 | references to the symbol.
|
---|
567 |
|
---|
568 | `--defsym SYMBOL=EXPRESSION'
|
---|
569 | Create a global symbol in the output file, containing the absolute
|
---|
570 | address given by EXPRESSION. You may use this option as many
|
---|
571 | times as necessary to define multiple symbols in the command line.
|
---|
572 | A limited form of arithmetic is supported for the EXPRESSION in
|
---|
573 | this context: you may give a hexadecimal constant or the name of
|
---|
574 | an existing symbol, or use `+' and `-' to add or subtract
|
---|
575 | hexadecimal constants or symbols. If you need more elaborate
|
---|
576 | expressions, consider using the linker command language from a
|
---|
577 | script (*note Assignment: Symbol Definitions: Assignments.).
|
---|
578 | _Note:_ there should be no white space between SYMBOL, the equals
|
---|
579 | sign ("<=>"), and EXPRESSION.
|
---|
580 |
|
---|
581 | `--demangle[=STYLE]'
|
---|
582 | `--no-demangle'
|
---|
583 | These options control whether to demangle symbol names in error
|
---|
584 | messages and other output. When the linker is told to demangle,
|
---|
585 | it tries to present symbol names in a readable fashion: it strips
|
---|
586 | leading underscores if they are used by the object file format,
|
---|
587 | and converts C++ mangled symbol names into user readable names.
|
---|
588 | Different compilers have different mangling styles. The optional
|
---|
589 | demangling style argument can be used to choose an appropriate
|
---|
590 | demangling style for your compiler. The linker will demangle by
|
---|
591 | default unless the environment variable `COLLECT_NO_DEMANGLE' is
|
---|
592 | set. These options may be used to override the default.
|
---|
593 |
|
---|
594 | `--dynamic-linker FILE'
|
---|
595 | Set the name of the dynamic linker. This is only meaningful when
|
---|
596 | generating dynamically linked ELF executables. The default dynamic
|
---|
597 | linker is normally correct; don't use this unless you know what
|
---|
598 | you are doing.
|
---|
599 |
|
---|
600 | `--embedded-relocs'
|
---|
601 | This option is only meaningful when linking MIPS embedded PIC code,
|
---|
602 | generated by the -membedded-pic option to the GNU compiler and
|
---|
603 | assembler. It causes the linker to create a table which may be
|
---|
604 | used at runtime to relocate any data which was statically
|
---|
605 | initialized to pointer values. See the code in testsuite/ld-empic
|
---|
606 | for details.
|
---|
607 |
|
---|
608 | `--force-exe-suffix'
|
---|
609 | Make sure that an output file has a .exe suffix.
|
---|
610 |
|
---|
611 | If a successfully built fully linked output file does not have a
|
---|
612 | `.exe' or `.dll' suffix, this option forces the linker to copy the
|
---|
613 | output file to one of the same name with a `.exe' suffix. This
|
---|
614 | option is useful when using unmodified Unix makefiles on a
|
---|
615 | Microsoft Windows host, since some versions of Windows won't run
|
---|
616 | an image unless it ends in a `.exe' suffix.
|
---|
617 |
|
---|
618 | `--no-gc-sections'
|
---|
619 | `--gc-sections'
|
---|
620 | Enable garbage collection of unused input sections. It is ignored
|
---|
621 | on targets that do not support this option. This option is not
|
---|
622 | compatible with `-r', nor should it be used with dynamic linking.
|
---|
623 | The default behaviour (of not performing this garbage collection)
|
---|
624 | can be restored by specifying `--no-gc-sections' on the command
|
---|
625 | line.
|
---|
626 |
|
---|
627 | `--help'
|
---|
628 | Print a summary of the command-line options on the standard output
|
---|
629 | and exit.
|
---|
630 |
|
---|
631 | `--target-help'
|
---|
632 | Print a summary of all target specific options on the standard
|
---|
633 | output and exit.
|
---|
634 |
|
---|
635 | `-Map MAPFILE'
|
---|
636 | Print a link map to the file MAPFILE. See the description of the
|
---|
637 | `-M' option, above.
|
---|
638 |
|
---|
639 | `--no-keep-memory'
|
---|
640 | `ld' normally optimizes for speed over memory usage by caching the
|
---|
641 | symbol tables of input files in memory. This option tells `ld' to
|
---|
642 | instead optimize for memory usage, by rereading the symbol tables
|
---|
643 | as necessary. This may be required if `ld' runs out of memory
|
---|
644 | space while linking a large executable.
|
---|
645 |
|
---|
646 | `--no-undefined'
|
---|
647 | `-z defs'
|
---|
648 | Normally when creating a non-symbolic shared library, undefined
|
---|
649 | symbols are allowed and left to be resolved by the runtime loader.
|
---|
650 | These options disallow such undefined symbols.
|
---|
651 |
|
---|
652 | `--allow-shlib-undefined'
|
---|
653 | Allow undefined symbols in shared objects even when -no-undefined
|
---|
654 | is set. The net result will be that undefined symbols in regular
|
---|
655 | objects will still trigger an error, but undefined symbols in
|
---|
656 | shared objects will be ignored. The implementation of
|
---|
657 | no_undefined makes the assumption that the runtime linker will
|
---|
658 | choke on undefined symbols. However there is at least one system
|
---|
659 | (BeOS) where undefined symbols in shared libraries is normal since
|
---|
660 | the kernel patches them at load time to select which function is
|
---|
661 | most appropriate for the current architecture. I.E. dynamically
|
---|
662 | select an appropriate memset function. Apparently it is also
|
---|
663 | normal for HPPA shared libraries to have undefined symbols.
|
---|
664 |
|
---|
665 | `--no-warn-mismatch'
|
---|
666 | Normally `ld' will give an error if you try to link together input
|
---|
667 | files that are mismatched for some reason, perhaps because they
|
---|
668 | have been compiled for different processors or for different
|
---|
669 | endiannesses. This option tells `ld' that it should silently
|
---|
670 | permit such possible errors. This option should only be used with
|
---|
671 | care, in cases when you have taken some special action that
|
---|
672 | ensures that the linker errors are inappropriate.
|
---|
673 |
|
---|
674 | `--no-whole-archive'
|
---|
675 | Turn off the effect of the `--whole-archive' option for subsequent
|
---|
676 | archive files.
|
---|
677 |
|
---|
678 | `--noinhibit-exec'
|
---|
679 | Retain the executable output file whenever it is still usable.
|
---|
680 | Normally, the linker will not produce an output file if it
|
---|
681 | encounters errors during the link process; it exits without
|
---|
682 | writing an output file when it issues any error whatsoever.
|
---|
683 |
|
---|
684 | `--oformat OUTPUT-FORMAT'
|
---|
685 | `ld' may be configured to support more than one kind of object
|
---|
686 | file. If your `ld' is configured this way, you can use the
|
---|
687 | `--oformat' option to specify the binary format for the output
|
---|
688 | object file. Even when `ld' is configured to support alternative
|
---|
689 | object formats, you don't usually need to specify this, as `ld'
|
---|
690 | should be configured to produce as a default output format the most
|
---|
691 | usual format on each machine. OUTPUT-FORMAT is a text string, the
|
---|
692 | name of a particular format supported by the BFD libraries. (You
|
---|
693 | can list the available binary formats with `objdump -i'.) The
|
---|
694 | script command `OUTPUT_FORMAT' can also specify the output format,
|
---|
695 | but this option overrides it. *Note BFD::.
|
---|
696 |
|
---|
697 | `-qmagic'
|
---|
698 | This option is ignored for Linux compatibility.
|
---|
699 |
|
---|
700 | `-Qy'
|
---|
701 | This option is ignored for SVR4 compatibility.
|
---|
702 |
|
---|
703 | `--relax'
|
---|
704 | An option with machine dependent effects. This option is only
|
---|
705 | supported on a few targets. *Note `ld' and the H8/300: H8/300.
|
---|
706 | *Note `ld' and the Intel 960 family: i960.
|
---|
707 |
|
---|
708 | On some platforms, the `--relax' option performs global
|
---|
709 | optimizations that become possible when the linker resolves
|
---|
710 | addressing in the program, such as relaxing address modes and
|
---|
711 | synthesizing new instructions in the output object file.
|
---|
712 |
|
---|
713 | On some platforms these link time global optimizations may make
|
---|
714 | symbolic debugging of the resulting executable impossible. This
|
---|
715 | is known to be the case for the Matsushita MN10200 and MN10300
|
---|
716 | family of processors.
|
---|
717 |
|
---|
718 | On platforms where this is not supported, `--relax' is accepted,
|
---|
719 | but ignored.
|
---|
720 |
|
---|
721 | `--retain-symbols-file FILENAME'
|
---|
722 | Retain _only_ the symbols listed in the file FILENAME, discarding
|
---|
723 | all others. FILENAME is simply a flat file, with one symbol name
|
---|
724 | per line. This option is especially useful in environments (such
|
---|
725 | as VxWorks) where a large global symbol table is accumulated
|
---|
726 | gradually, to conserve run-time memory.
|
---|
727 |
|
---|
728 | `--retain-symbols-file' does _not_ discard undefined symbols, or
|
---|
729 | symbols needed for relocations.
|
---|
730 |
|
---|
731 | You may only specify `--retain-symbols-file' once in the command
|
---|
732 | line. It overrides `-s' and `-S'.
|
---|
733 |
|
---|
734 | `-rpath DIR'
|
---|
735 | Add a directory to the runtime library search path. This is used
|
---|
736 | when linking an ELF executable with shared objects. All `-rpath'
|
---|
737 | arguments are concatenated and passed to the runtime linker, which
|
---|
738 | uses them to locate shared objects at runtime. The `-rpath'
|
---|
739 | option is also used when locating shared objects which are needed
|
---|
740 | by shared objects explicitly included in the link; see the
|
---|
741 | description of the `-rpath-link' option. If `-rpath' is not used
|
---|
742 | when linking an ELF executable, the contents of the environment
|
---|
743 | variable `LD_RUN_PATH' will be used if it is defined.
|
---|
744 |
|
---|
745 | The `-rpath' option may also be used on SunOS. By default, on
|
---|
746 | SunOS, the linker will form a runtime search patch out of all the
|
---|
747 | `-L' options it is given. If a `-rpath' option is used, the
|
---|
748 | runtime search path will be formed exclusively using the `-rpath'
|
---|
749 | options, ignoring the `-L' options. This can be useful when using
|
---|
750 | gcc, which adds many `-L' options which may be on NFS mounted
|
---|
751 | filesystems.
|
---|
752 |
|
---|
753 | For compatibility with other ELF linkers, if the `-R' option is
|
---|
754 | followed by a directory name, rather than a file name, it is
|
---|
755 | treated as the `-rpath' option.
|
---|
756 |
|
---|
757 | `-rpath-link DIR'
|
---|
758 | When using ELF or SunOS, one shared library may require another.
|
---|
759 | This happens when an `ld -shared' link includes a shared library
|
---|
760 | as one of the input files.
|
---|
761 |
|
---|
762 | When the linker encounters such a dependency when doing a
|
---|
763 | non-shared, non-relocatable link, it will automatically try to
|
---|
764 | locate the required shared library and include it in the link, if
|
---|
765 | it is not included explicitly. In such a case, the `-rpath-link'
|
---|
766 | option specifies the first set of directories to search. The
|
---|
767 | `-rpath-link' option may specify a sequence of directory names
|
---|
768 | either by specifying a list of names separated by colons, or by
|
---|
769 | appearing multiple times.
|
---|
770 |
|
---|
771 | This option should be used with caution as it overrides the search
|
---|
772 | path that may have been hard compiled into a shared library. In
|
---|
773 | such a case it is possible to use unintentionally a different
|
---|
774 | search path than the runtime linker would do.
|
---|
775 |
|
---|
776 | The linker uses the following search paths to locate required
|
---|
777 | shared libraries.
|
---|
778 | 1. Any directories specified by `-rpath-link' options.
|
---|
779 |
|
---|
780 | 2. Any directories specified by `-rpath' options. The difference
|
---|
781 | between `-rpath' and `-rpath-link' is that directories
|
---|
782 | specified by `-rpath' options are included in the executable
|
---|
783 | and used at runtime, whereas the `-rpath-link' option is only
|
---|
784 | effective at link time. It is for the native linker only.
|
---|
785 |
|
---|
786 | 3. On an ELF system, if the `-rpath' and `rpath-link' options
|
---|
787 | were not used, search the contents of the environment variable
|
---|
788 | `LD_RUN_PATH'. It is for the native linker only.
|
---|
789 |
|
---|
790 | 4. On SunOS, if the `-rpath' option was not used, search any
|
---|
791 | directories specified using `-L' options.
|
---|
792 |
|
---|
793 | 5. For a native linker, the contents of the environment variable
|
---|
794 | `LD_LIBRARY_PATH'.
|
---|
795 |
|
---|
796 | 6. For a native ELF linker, the directories in `DT_RUNPATH' or
|
---|
797 | `DT_RPATH' of a shared library are searched for shared
|
---|
798 | libraries needed by it. The `DT_RPATH' entries are ignored if
|
---|
799 | `DT_RUNPATH' entries exist.
|
---|
800 |
|
---|
801 | 7. The default directories, normally `/lib' and `/usr/lib'.
|
---|
802 |
|
---|
803 | 8. For a native linker on an ELF system, if the file
|
---|
804 | `/etc/ld.so.conf' exists, the list of directories found in
|
---|
805 | that file.
|
---|
806 |
|
---|
807 | If the required shared library is not found, the linker will issue
|
---|
808 | a warning and continue with the link.
|
---|
809 |
|
---|
810 | `-shared'
|
---|
811 | `-Bshareable'
|
---|
812 | Create a shared library. This is currently only supported on ELF,
|
---|
813 | XCOFF and SunOS platforms. On SunOS, the linker will
|
---|
814 | automatically create a shared library if the `-e' option is not
|
---|
815 | used and there are undefined symbols in the link.
|
---|
816 |
|
---|
817 | `--sort-common'
|
---|
818 | This option tells `ld' to sort the common symbols by size when it
|
---|
819 | places them in the appropriate output sections. First come all
|
---|
820 | the one byte symbols, then all the two bytes, then all the four
|
---|
821 | bytes, and then everything else. This is to prevent gaps between
|
---|
822 | symbols due to alignment constraints.
|
---|
823 |
|
---|
824 | `--split-by-file [SIZE]'
|
---|
825 | Similar to `--split-by-reloc' but creates a new output section for
|
---|
826 | each input file when SIZE is reached. SIZE defaults to a size of
|
---|
827 | 1 if not given.
|
---|
828 |
|
---|
829 | `--split-by-reloc [COUNT]'
|
---|
830 | Tries to creates extra sections in the output file so that no
|
---|
831 | single output section in the file contains more than COUNT
|
---|
832 | relocations. This is useful when generating huge relocatable
|
---|
833 | files for downloading into certain real time kernels with the COFF
|
---|
834 | object file format; since COFF cannot represent more than 65535
|
---|
835 | relocations in a single section. Note that this will fail to work
|
---|
836 | with object file formats which do not support arbitrary sections.
|
---|
837 | The linker will not split up individual input sections for
|
---|
838 | redistribution, so if a single input section contains more than
|
---|
839 | COUNT relocations one output section will contain that many
|
---|
840 | relocations. COUNT defaults to a value of 32768.
|
---|
841 |
|
---|
842 | `--stats'
|
---|
843 | Compute and display statistics about the operation of the linker,
|
---|
844 | such as execution time and memory usage.
|
---|
845 |
|
---|
846 | `--traditional-format'
|
---|
847 | For some targets, the output of `ld' is different in some ways from
|
---|
848 | the output of some existing linker. This switch requests `ld' to
|
---|
849 | use the traditional format instead.
|
---|
850 |
|
---|
851 | For example, on SunOS, `ld' combines duplicate entries in the
|
---|
852 | symbol string table. This can reduce the size of an output file
|
---|
853 | with full debugging information by over 30 percent.
|
---|
854 | Unfortunately, the SunOS `dbx' program can not read the resulting
|
---|
855 | program (`gdb' has no trouble). The `--traditional-format' switch
|
---|
856 | tells `ld' to not combine duplicate entries.
|
---|
857 |
|
---|
858 | `--section-start SECTIONNAME=ORG'
|
---|
859 | Locate a section in the output file at the absolute address given
|
---|
860 | by ORG. You may use this option as many times as necessary to
|
---|
861 | locate multiple sections in the command line. ORG must be a
|
---|
862 | single hexadecimal integer; for compatibility with other linkers,
|
---|
863 | you may omit the leading `0x' usually associated with hexadecimal
|
---|
864 | values. _Note:_ there should be no white space between
|
---|
865 | SECTIONNAME, the equals sign ("<=>"), and ORG.
|
---|
866 |
|
---|
867 | `-Tbss ORG'
|
---|
868 | `-Tdata ORG'
|
---|
869 | `-Ttext ORG'
|
---|
870 | Use ORG as the starting address for--respectively--the `bss',
|
---|
871 | `data', or the `text' segment of the output file. ORG must be a
|
---|
872 | single hexadecimal integer; for compatibility with other linkers,
|
---|
873 | you may omit the leading `0x' usually associated with hexadecimal
|
---|
874 | values.
|
---|
875 |
|
---|
876 | `--dll-verbose'
|
---|
877 | `--verbose'
|
---|
878 | Display the version number for `ld' and list the linker emulations
|
---|
879 | supported. Display which input files can and cannot be opened.
|
---|
880 | Display the linker script if using a default builtin script.
|
---|
881 |
|
---|
882 | `--version-script=VERSION-SCRIPTFILE'
|
---|
883 | Specify the name of a version script to the linker. This is
|
---|
884 | typically used when creating shared libraries to specify
|
---|
885 | additional information about the version heirarchy for the library
|
---|
886 | being created. This option is only meaningful on ELF platforms
|
---|
887 | which support shared libraries. *Note VERSION::.
|
---|
888 |
|
---|
889 | `--warn-common'
|
---|
890 | Warn when a common symbol is combined with another common symbol
|
---|
891 | or with a symbol definition. Unix linkers allow this somewhat
|
---|
892 | sloppy practice, but linkers on some other operating systems do
|
---|
893 | not. This option allows you to find potential problems from
|
---|
894 | combining global symbols. Unfortunately, some C libraries use
|
---|
895 | this practice, so you may get some warnings about symbols in the
|
---|
896 | libraries as well as in your programs.
|
---|
897 |
|
---|
898 | There are three kinds of global symbols, illustrated here by C
|
---|
899 | examples:
|
---|
900 |
|
---|
901 | `int i = 1;'
|
---|
902 | A definition, which goes in the initialized data section of
|
---|
903 | the output file.
|
---|
904 |
|
---|
905 | `extern int i;'
|
---|
906 | An undefined reference, which does not allocate space. There
|
---|
907 | must be either a definition or a common symbol for the
|
---|
908 | variable somewhere.
|
---|
909 |
|
---|
910 | `int i;'
|
---|
911 | A common symbol. If there are only (one or more) common
|
---|
912 | symbols for a variable, it goes in the uninitialized data
|
---|
913 | area of the output file. The linker merges multiple common
|
---|
914 | symbols for the same variable into a single symbol. If they
|
---|
915 | are of different sizes, it picks the largest size. The
|
---|
916 | linker turns a common symbol into a declaration, if there is
|
---|
917 | a definition of the same variable.
|
---|
918 |
|
---|
919 | The `--warn-common' option can produce five kinds of warnings.
|
---|
920 | Each warning consists of a pair of lines: the first describes the
|
---|
921 | symbol just encountered, and the second describes the previous
|
---|
922 | symbol encountered with the same name. One or both of the two
|
---|
923 | symbols will be a common symbol.
|
---|
924 |
|
---|
925 | 1. Turning a common symbol into a reference, because there is
|
---|
926 | already a definition for the symbol.
|
---|
927 | FILE(SECTION): warning: common of `SYMBOL'
|
---|
928 | overridden by definition
|
---|
929 | FILE(SECTION): warning: defined here
|
---|
930 |
|
---|
931 | 2. Turning a common symbol into a reference, because a later
|
---|
932 | definition for the symbol is encountered. This is the same
|
---|
933 | as the previous case, except that the symbols are encountered
|
---|
934 | in a different order.
|
---|
935 | FILE(SECTION): warning: definition of `SYMBOL'
|
---|
936 | overriding common
|
---|
937 | FILE(SECTION): warning: common is here
|
---|
938 |
|
---|
939 | 3. Merging a common symbol with a previous same-sized common
|
---|
940 | symbol.
|
---|
941 | FILE(SECTION): warning: multiple common
|
---|
942 | of `SYMBOL'
|
---|
943 | FILE(SECTION): warning: previous common is here
|
---|
944 |
|
---|
945 | 4. Merging a common symbol with a previous larger common symbol.
|
---|
946 | FILE(SECTION): warning: common of `SYMBOL'
|
---|
947 | overridden by larger common
|
---|
948 | FILE(SECTION): warning: larger common is here
|
---|
949 |
|
---|
950 | 5. Merging a common symbol with a previous smaller common
|
---|
951 | symbol. This is the same as the previous case, except that
|
---|
952 | the symbols are encountered in a different order.
|
---|
953 | FILE(SECTION): warning: common of `SYMBOL'
|
---|
954 | overriding smaller common
|
---|
955 | FILE(SECTION): warning: smaller common is here
|
---|
956 |
|
---|
957 | `--warn-constructors'
|
---|
958 | Warn if any global constructors are used. This is only useful for
|
---|
959 | a few object file formats. For formats like COFF or ELF, the
|
---|
960 | linker can not detect the use of global constructors.
|
---|
961 |
|
---|
962 | `--warn-multiple-gp'
|
---|
963 | Warn if multiple global pointer values are required in the output
|
---|
964 | file. This is only meaningful for certain processors, such as the
|
---|
965 | Alpha. Specifically, some processors put large-valued constants
|
---|
966 | in a special section. A special register (the global pointer)
|
---|
967 | points into the middle of this section, so that constants can be
|
---|
968 | loaded efficiently via a base-register relative addressing mode.
|
---|
969 | Since the offset in base-register relative mode is fixed and
|
---|
970 | relatively small (e.g., 16 bits), this limits the maximum size of
|
---|
971 | the constant pool. Thus, in large programs, it is often necessary
|
---|
972 | to use multiple global pointer values in order to be able to
|
---|
973 | address all possible constants. This option causes a warning to
|
---|
974 | be issued whenever this case occurs.
|
---|
975 |
|
---|
976 | `--warn-once'
|
---|
977 | Only warn once for each undefined symbol, rather than once per
|
---|
978 | module which refers to it.
|
---|
979 |
|
---|
980 | `--warn-section-align'
|
---|
981 | Warn if the address of an output section is changed because of
|
---|
982 | alignment. Typically, the alignment will be set by an input
|
---|
983 | section. The address will only be changed if it not explicitly
|
---|
984 | specified; that is, if the `SECTIONS' command does not specify a
|
---|
985 | start address for the section (*note SECTIONS::).
|
---|
986 |
|
---|
987 | `--whole-archive'
|
---|
988 | For each archive mentioned on the command line after the
|
---|
989 | `--whole-archive' option, include every object file in the archive
|
---|
990 | in the link, rather than searching the archive for the required
|
---|
991 | object files. This is normally used to turn an archive file into
|
---|
992 | a shared library, forcing every object to be included in the
|
---|
993 | resulting shared library. This option may be used more than once.
|
---|
994 |
|
---|
995 | Two notes when using this option from gcc: First, gcc doesn't know
|
---|
996 | about this option, so you have to use `-Wl,-whole-archive'.
|
---|
997 | Second, don't forget to use `-Wl,-no-whole-archive' after your
|
---|
998 | list of archives, because gcc will add its own list of archives to
|
---|
999 | your link and you may not want this flag to affect those as well.
|
---|
1000 |
|
---|
1001 | `--wrap SYMBOL'
|
---|
1002 | Use a wrapper function for SYMBOL. Any undefined reference to
|
---|
1003 | SYMBOL will be resolved to `__wrap_SYMBOL'. Any undefined
|
---|
1004 | reference to `__real_SYMBOL' will be resolved to SYMBOL.
|
---|
1005 |
|
---|
1006 | This can be used to provide a wrapper for a system function. The
|
---|
1007 | wrapper function should be called `__wrap_SYMBOL'. If it wishes
|
---|
1008 | to call the system function, it should call `__real_SYMBOL'.
|
---|
1009 |
|
---|
1010 | Here is a trivial example:
|
---|
1011 |
|
---|
1012 | void *
|
---|
1013 | __wrap_malloc (int c)
|
---|
1014 | {
|
---|
1015 | printf ("malloc called with %ld\n", c);
|
---|
1016 | return __real_malloc (c);
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | If you link other code with this file using `--wrap malloc', then
|
---|
1020 | all calls to `malloc' will call the function `__wrap_malloc'
|
---|
1021 | instead. The call to `__real_malloc' in `__wrap_malloc' will call
|
---|
1022 | the real `malloc' function.
|
---|
1023 |
|
---|
1024 | You may wish to provide a `__real_malloc' function as well, so that
|
---|
1025 | links without the `--wrap' option will succeed. If you do this,
|
---|
1026 | you should not put the definition of `__real_malloc' in the same
|
---|
1027 | file as `__wrap_malloc'; if you do, the assembler may resolve the
|
---|
1028 | call before the linker has a chance to wrap it to `malloc'.
|
---|
1029 |
|
---|
1030 | `--enable-new-dtags'
|
---|
1031 | `--disable-new-dtags'
|
---|
1032 | This linker can create the new dynamic tags in ELF. But the older
|
---|
1033 | ELF systems may not understand them. If you specify
|
---|
1034 | `--enable-new-dtags', the dynamic tags will be created as needed.
|
---|
1035 | If you specify `--disable-new-dtags', no new dynamic tags will be
|
---|
1036 | created. By default, the new dynamic tags are not created. Note
|
---|
1037 | that those options are only available for ELF systems.
|
---|
1038 |
|
---|
1039 | Options specific to i386 PE targets
|
---|
1040 | -----------------------------------
|
---|
1041 |
|
---|
1042 | The i386 PE linker supports the `-shared' option, which causes the
|
---|
1043 | output to be a dynamically linked library (DLL) instead of a normal
|
---|
1044 | executable. You should name the output `*.dll' when you use this
|
---|
1045 | option. In addition, the linker fully supports the standard `*.def'
|
---|
1046 | files, which may be specified on the linker command line like an object
|
---|
1047 | file (in fact, it should precede archives it exports symbols from, to
|
---|
1048 | ensure that they get linked in, just like a normal object file).
|
---|
1049 |
|
---|
1050 | In addition to the options common to all targets, the i386 PE linker
|
---|
1051 | support additional command line options that are specific to the i386
|
---|
1052 | PE target. Options that take values may be separated from their values
|
---|
1053 | by either a space or an equals sign.
|
---|
1054 |
|
---|
1055 | `--add-stdcall-alias'
|
---|
1056 | If given, symbols with a stdcall suffix (@NN) will be exported
|
---|
1057 | as-is and also with the suffix stripped.
|
---|
1058 |
|
---|
1059 | `--base-file FILE'
|
---|
1060 | Use FILE as the name of a file in which to save the base addresses
|
---|
1061 | of all the relocations needed for generating DLLs with `dlltool'.
|
---|
1062 |
|
---|
1063 | `--dll'
|
---|
1064 | Create a DLL instead of a regular executable. You may also use
|
---|
1065 | `-shared' or specify a `LIBRARY' in a given `.def' file.
|
---|
1066 |
|
---|
1067 | `--enable-stdcall-fixup'
|
---|
1068 | `--disable-stdcall-fixup'
|
---|
1069 | If the link finds a symbol that it cannot resolve, it will attempt
|
---|
1070 | to do "fuzzy linking" by looking for another defined symbol that
|
---|
1071 | differs only in the format of the symbol name (cdecl vs stdcall)
|
---|
1072 | and will resolve that symbol by linking to the match. For
|
---|
1073 | example, the undefined symbol `_foo' might be linked to the
|
---|
1074 | function `_foo@12', or the undefined symbol `_bar@16' might be
|
---|
1075 | linked to the function `_bar'. When the linker does this, it
|
---|
1076 | prints a warning, since it normally should have failed to link,
|
---|
1077 | but sometimes import libraries generated from third-party dlls may
|
---|
1078 | need this feature to be usable. If you specify
|
---|
1079 | `--enable-stdcall-fixup', this feature is fully enabled and
|
---|
1080 | warnings are not printed. If you specify
|
---|
1081 | `--disable-stdcall-fixup', this feature is disabled and such
|
---|
1082 | mismatches are considered to be errors.
|
---|
1083 |
|
---|
1084 | `--export-all-symbols'
|
---|
1085 | If given, all global symbols in the objects used to build a DLL
|
---|
1086 | will be exported by the DLL. Note that this is the default if
|
---|
1087 | there otherwise wouldn't be any exported symbols. When symbols are
|
---|
1088 | explicitly exported via DEF files or implicitly exported via
|
---|
1089 | function attributes, the default is to not export anything else
|
---|
1090 | unless this option is given. Note that the symbols `DllMain@12',
|
---|
1091 | `DllEntryPoint@0', and `impure_ptr' will not be automatically
|
---|
1092 | exported.
|
---|
1093 |
|
---|
1094 | `--exclude-symbols SYMBOL,SYMBOL,...'
|
---|
1095 | Specifies a list of symbols which should not be automatically
|
---|
1096 | exported. The symbol names may be delimited by commas or colons.
|
---|
1097 |
|
---|
1098 | `--file-alignment'
|
---|
1099 | Specify the file alignment. Sections in the file will always
|
---|
1100 | begin at file offsets which are multiples of this number. This
|
---|
1101 | defaults to 512.
|
---|
1102 |
|
---|
1103 | `--heap RESERVE'
|
---|
1104 | `--heap RESERVE,COMMIT'
|
---|
1105 | Specify the amount of memory to reserve (and optionally commit) to
|
---|
1106 | be used as heap for this program. The default is 1Mb reserved, 4K
|
---|
1107 | committed.
|
---|
1108 |
|
---|
1109 | `--image-base VALUE'
|
---|
1110 | Use VALUE as the base address of your program or dll. This is the
|
---|
1111 | lowest memory location that will be used when your program or dll
|
---|
1112 | is loaded. To reduce the need to relocate and improve performance
|
---|
1113 | of your dlls, each should have a unique base address and not
|
---|
1114 | overlap any other dlls. The default is 0x400000 for executables,
|
---|
1115 | and 0x10000000 for dlls.
|
---|
1116 |
|
---|
1117 | `--kill-at'
|
---|
1118 | If given, the stdcall suffixes (@NN) will be stripped from symbols
|
---|
1119 | before they are exported.
|
---|
1120 |
|
---|
1121 | `--major-image-version VALUE'
|
---|
1122 | Sets the major number of the "image version". Defaults to 1.
|
---|
1123 |
|
---|
1124 | `--major-os-version VALUE'
|
---|
1125 | Sets the major number of the "os version". Defaults to 4.
|
---|
1126 |
|
---|
1127 | `--major-subsystem-version VALUE'
|
---|
1128 | Sets the major number of the "subsystem version". Defaults to 4.
|
---|
1129 |
|
---|
1130 | `--minor-image-version VALUE'
|
---|
1131 | Sets the minor number of the "image version". Defaults to 0.
|
---|
1132 |
|
---|
1133 | `--minor-os-version VALUE'
|
---|
1134 | Sets the minor number of the "os version". Defaults to 0.
|
---|
1135 |
|
---|
1136 | `--minor-subsystem-version VALUE'
|
---|
1137 | Sets the minor number of the "subsystem version". Defaults to 0.
|
---|
1138 |
|
---|
1139 | `--output-def FILE'
|
---|
1140 | The linker will create the file FILE which will contain a DEF file
|
---|
1141 | corresponding to the DLL the linker is generating. This DEF file
|
---|
1142 | (which should be called `*.def') may be used to create an import
|
---|
1143 | library with `dlltool' or may be used as a reference to
|
---|
1144 | automatically or implicitly exported symbols.
|
---|
1145 |
|
---|
1146 | `--section-alignment'
|
---|
1147 | Sets the section alignment. Sections in memory will always begin
|
---|
1148 | at addresses which are a multiple of this number. Defaults to
|
---|
1149 | 0x1000.
|
---|
1150 |
|
---|
1151 | `--stack RESERVE'
|
---|
1152 | `--stack RESERVE,COMMIT'
|
---|
1153 | Specify the amount of memory to reserve (and optionally commit) to
|
---|
1154 | be used as stack for this program. The default is 32Mb reserved,
|
---|
1155 | 4K committed.
|
---|
1156 |
|
---|
1157 | `--subsystem WHICH'
|
---|
1158 | `--subsystem WHICH:MAJOR'
|
---|
1159 | `--subsystem WHICH:MAJOR.MINOR'
|
---|
1160 | Specifies the subsystem under which your program will execute. The
|
---|
1161 | legal values for WHICH are `native', `windows', `console', and
|
---|
1162 | `posix'. You may optionally set the subsystem version also.
|
---|
1163 |
|
---|