Commit | Line | Data |
---|---|---|
a8880eda | 1 | .\" Copyright (c) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation |
0e166a63 RP |
2 | .\" See section COPYING for conditions for redistribution |
3 | .TH ld 1 "17 August 1992" "cygnus support" "GNU Development Tools" | |
4 | .de BP | |
5 | .sp | |
6 | .ti \-.2i | |
7 | \(** | |
8 | .. | |
9 | ||
10 | .SH NAME | |
11 | ld \- the GNU linker | |
12 | ||
13 | .SH SYNOPSIS | |
14 | .hy 0 | |
15 | .na | |
16 | .TP | |
17 | .B ld | |
18 | .RB "[\|" \-o " | |
19 | .I output\c | |
20 | \&\|] \c | |
8ddef552 | 21 | .I objfile\c |
0e166a63 RP |
22 | \&.\|.\|. |
23 | .br | |
24 | .RB "[\|" \-A\c | |
25 | .I architecture\c | |
26 | \&\|] | |
27 | .RB "[\|" "\-b\ "\c | |
28 | .I input-format\c | |
29 | \&\|] | |
30 | .RB "[\|" \-Bstatic "\|]" | |
4551e108 ILT |
31 | .RB "[\|" \-Bdynamic "\|]" |
32 | .RB "[\|" \-Bsymbolic "\|]" | |
0e166a63 RP |
33 | .RB "[\|" "\-c\ "\c |
34 | .I commandfile\c | |
35 | \&\|] | |
07acd23b | 36 | .RB "[\|" \-\-cref "\|]" |
0e166a63 RP |
37 | .RB "[\|" \-d | \-dc | \-dp\c |
38 | \|] | |
39 | .br | |
40 | .RB "[\|" "\-defsym\ "\c | |
41 | .I symbol\c | |
42 | \& = \c | |
43 | .I expression\c | |
44 | \&\|] | |
45 | .RB "[\|" "\-e\ "\c | |
46 | .I entry\c | |
47 | \&\|] | |
39a6e282 | 48 | .RB "[\|" \-embedded\-relocs "\|]" |
7ec9d825 | 49 | .RB "[\|" \-E "\|]" |
4bdd9722 | 50 | .RB "[\|" \-export\-dynamic "\|]" |
de220cbd ILT |
51 | .RB "[\|" "\-f\ "\c |
52 | .I name\c | |
53 | \&\|] | |
54 | .RB "[\|" "\-\-auxiliary\ "\c | |
55 | .I name\c | |
56 | \&\|] | |
0e166a63 | 57 | .RB "[\|" "\-F\ "\c |
de220cbd ILT |
58 | .I name\c |
59 | \&\|] | |
60 | .RB "[\|" "\-\-filter\ "\c | |
61 | .I name\c | |
0e166a63 RP |
62 | \&\|] |
63 | .RB "[\|" "\-format\ "\c | |
64 | .I input-format\c | |
65 | \&\|] | |
66 | .RB "[\|" \-g "\|]" | |
80165535 | 67 | .RB "[\|" \-G |
8ddef552 DM |
68 | .I size\c |
69 | \&\|] | |
de220cbd ILT |
70 | .RB "[\|" "\-h\ "\c |
71 | .I name\c | |
72 | \&\|] | |
73 | .RB "[\|" "\-soname\ "\c | |
74 | .I name\c | |
75 | \&\|] | |
bf065bfd | 76 | .RB "[\|" \-\-help "\|]" |
0e166a63 RP |
77 | .RB "[\|" \-i "\|]" |
78 | .RB "[\|" \-l\c | |
79 | .I ar\c | |
80 | \&\|] | |
81 | .RB "[\|" \-L\c | |
82 | .I searchdir\c | |
83 | \&\|] | |
8ddef552 | 84 | .RB "[\|" \-M "\|]" |
80165535 | 85 | .RB "[\|" \-Map |
d18a4527 DM |
86 | .I mapfile\c |
87 | \&\|] | |
80165535 | 88 | .RB "[\|" \-m |
8ddef552 DM |
89 | .I emulation\c |
90 | \&\|] | |
0e166a63 RP |
91 | .RB "[\|" \-n | \-N "\|]" |
92 | .RB "[\|" \-noinhibit-exec "\|]" | |
e920526d | 93 | .RB "[\|" \-no\-keep\-memory "\|]" |
a8880eda | 94 | .RB "[\|" \-no\-warn\-mismatch "\|]" |
c470f2eb UD |
95 | .RB "[\|" \-O\c |
96 | .I level\c | |
97 | \&\|] | |
346535cc DM |
98 | .RB "[\|" "\-oformat\ "\c |
99 | .I output-format\c | |
100 | \&\|] | |
0e166a63 RP |
101 | .RB "[\|" "\-R\ "\c |
102 | .I filename\c | |
103 | \&\|] | |
104 | .RB "[\|" \-relax "\|]" | |
105 | .RB "[\|" \-r | \-Ur "\|]" | |
5caef232 ILT |
106 | .RB "[\|" "\-rpath\ "\c |
107 | .I directory\c | |
108 | \&\|] | |
109 | .RB "[\|" "\-rpath\-link\ "\c | |
110 | .I directory\c | |
111 | \&\|] | |
0e166a63 RP |
112 | .RB "[\|" \-S "\|]" |
113 | .RB "[\|" \-s "\|]" | |
4551e108 | 114 | .RB "[\|" \-shared "\|]" |
2a28d8b0 | 115 | .RB "[\|" \-sort\-common "\|]" |
80165535 | 116 | .RB "[\|" "\-split\-by\-reloc\ "\c |
ec586565 ILT |
117 | .I count\c |
118 | \&\|] | |
119 | .RB "[\|" \-split\-by\-file "\|]" | |
0e166a63 RP |
120 | .RB "[\|" "\-T\ "\c |
121 | .I commandfile\c | |
122 | \&\|] | |
123 | .RB "[\|" "\-Ttext\ "\c | |
124 | .I textorg\c | |
125 | \&\|] | |
126 | .RB "[\|" "\-Tdata\ "\c | |
127 | .I dataorg\c | |
128 | \&\|] | |
129 | .RB "[\|" "\-Tbss\ "\c | |
130 | .I bssorg\c | |
131 | \&\|] | |
132 | .RB "[\|" \-t "\|]" | |
133 | .RB "[\|" "\-u\ "\c | |
134 | .I sym\c | |
135 | \&] | |
8ddef552 | 136 | .RB "[\|" \-V "\|]" |
0e166a63 | 137 | .RB "[\|" \-v "\|]" |
a82ae15d | 138 | .RB "[\|" \-\-verbose "\|]" |
bf065bfd | 139 | .RB "[\|" \-\-version "\|]" |
2a28d8b0 | 140 | .RB "[\|" \-warn\-common "\|]" |
a89d9f5b | 141 | .RB "[\|" \-warn\-constructors "\|]" |
4b7d2399 | 142 | .RB "[\|" \-warn\-multiple\-gp "\|]" |
809ee7e0 | 143 | .RB "[\|" \-warn\-once "\|]" |
458fc056 | 144 | .RB "[\|" \-warn\-section\-align "\|]" |
ee499d81 | 145 | .RB "[\|" \-\-whole\-archive "\|]" |
3c8deccc | 146 | .RB "[\|" \-\-no\-whole\-archive "\|]" |
e3d73386 ILT |
147 | .RB "[\|" "\-\-wrap\ "\c |
148 | .I symbol\c | |
149 | \&\|] | |
0e166a63 RP |
150 | .RB "[\|" \-X "\|]" |
151 | .RB "[\|" \-x "\|]" | |
0e166a63 RP |
152 | .ad b |
153 | .hy 1 | |
154 | .SH DESCRIPTION | |
155 | \c | |
156 | .B ld\c | |
157 | \& combines a number of object and archive files, relocates | |
158 | their data and ties up symbol references. Often the last step in | |
159 | building a new compiled program to run is a call to \c | |
160 | .B ld\c | |
161 | \&. | |
162 | ||
163 | \c | |
164 | .B ld\c | |
165 | \& accepts Linker Command Language files | |
166 | to provide explicit and total control over the linking process. | |
167 | This man page does not describe the command language; see the `\|\c | |
168 | .B ld\c | |
169 | \|' entry in `\|\c | |
170 | .B info\c | |
171 | \|', or the manual | |
172 | .I | |
173 | ld: the GNU linker | |
174 | \&, for full details on the command language and on other aspects of | |
175 | the GNU linker. | |
176 | ||
177 | This version of \c | |
178 | .B ld\c | |
179 | \& uses the general purpose BFD libraries | |
180 | to operate on object files. This allows \c | |
181 | .B ld\c | |
182 | \& to read, combine, and | |
183 | write object files in many different formats\(em\&for example, COFF or | |
184 | \c | |
185 | .B a.out\c | |
186 | \&. Different formats may be linked together to produce any | |
187 | available kind of object file. You can use `\|\c | |
188 | .B objdump \-i\c | |
189 | \|' to get a list of formats supported on various architectures; see | |
190 | .BR objdump ( 1 ). | |
191 | ||
192 | Aside from its flexibility, the GNU linker is more helpful than other | |
193 | linkers in providing diagnostic information. Many linkers abandon | |
194 | execution immediately upon encountering an error; whenever possible, | |
195 | \c | |
196 | .B ld\c | |
197 | \& continues executing, allowing you to identify other errors | |
198 | (or, in some cases, to get an output file in spite of the error). | |
199 | ||
200 | The GNU linker \c | |
201 | .B ld\c | |
202 | \& is meant to cover a broad range of situations, | |
203 | and to be as compatible as possible with other linkers. As a result, | |
204 | you have many choices to control its behavior through the command line, | |
205 | and through environment variables. | |
206 | ||
207 | .SH OPTIONS | |
208 | The plethora of command-line options may seem intimidating, but in | |
209 | actual practice few of them are used in any particular context. | |
210 | For instance, a frequent use of \c | |
211 | .B ld\c | |
212 | \& is to link standard Unix | |
213 | object files on a standard, supported Unix system. On such a system, to | |
214 | link a file \c | |
215 | .B hello.o\c | |
216 | \&: | |
217 | .sp | |
218 | .br | |
219 | $\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc | |
220 | .br | |
221 | .sp | |
222 | This tells \c | |
223 | .B ld\c | |
224 | \& to produce a file called \c | |
225 | .B output\c | |
226 | \& as the | |
227 | result of linking the file \c | |
228 | .B /lib/crt0.o\c | |
229 | \& with \c | |
230 | .B hello.o\c | |
231 | \& and | |
232 | the library \c | |
233 | .B libc.a\c | |
234 | \& which will come from the standard search | |
235 | directories. | |
236 | ||
237 | The command-line options to \c | |
238 | .B ld\c | |
239 | \& may be specified in any order, and | |
240 | may be repeated at will. For the most part, repeating an option with a | |
241 | different argument will either have no further effect, or override prior | |
242 | occurrences (those further to the left on the command line) of an | |
243 | option. | |
244 | ||
245 | The exceptions\(em\&which may meaningfully be used more than once\(em\&are | |
246 | \c | |
247 | .B \-A\c | |
248 | \&, \c | |
249 | .B \-b\c | |
250 | \& (or its synonym \c | |
251 | .B \-format\c | |
252 | \&), \c | |
253 | .B \-defsym\c | |
254 | \&, | |
255 | \c | |
256 | .B \-L\c | |
257 | \&, \c | |
258 | .B \-l\c | |
259 | \&, \c | |
260 | .B \-R\c | |
261 | \&, and \c | |
262 | .B \-u\c | |
263 | \&. | |
264 | ||
265 | The list of object files to be linked together, shown as \c | |
8ddef552 | 266 | .I objfile\c |
0e166a63 RP |
267 | \&, |
268 | may follow, precede, or be mixed in with command-line options; save that | |
269 | an \c | |
8ddef552 | 270 | .I objfile\c |
0e166a63 RP |
271 | \& argument may not be placed between an option flag and |
272 | its argument. | |
273 | ||
274 | Usually the linker is invoked with at least one object file, but other | |
275 | forms of binary input files can also be specified with \c | |
276 | .B \-l\c | |
277 | \&, | |
278 | \c | |
279 | .B \-R\c | |
280 | \&, and the script command language. If \c | |
281 | .I no\c | |
282 | \& binary input | |
283 | files at all are specified, the linker does not produce any output, and | |
284 | issues the message `\|\c | |
285 | .B No input files\c | |
286 | \|'. | |
287 | ||
288 | Option arguments must either follow the option letter without intervening | |
289 | whitespace, or be given as separate arguments immediately following the | |
290 | option that requires them. | |
291 | ||
0e166a63 | 292 | .TP |
80165535 | 293 | .BI "-A" "architecture" |
0e166a63 RP |
294 | In the current release of \c |
295 | .B ld\c | |
296 | \&, this option is useful only for the | |
297 | Intel 960 family of architectures. In that \c | |
298 | .B ld\c | |
299 | \& configuration, the | |
300 | \c | |
301 | .I architecture\c | |
302 | \& argument is one of the two-letter names identifying | |
303 | members of the 960 family; the option specifies the desired output | |
304 | target, and warns of any incompatible instructions in the input files. | |
305 | It also modifies the linker's search strategy for archive libraries, to | |
306 | support the use of libraries specific to each particular | |
307 | architecture, by including in the search loop names suffixed with the | |
308 | string identifying the architecture. | |
309 | ||
310 | For example, if your \c | |
311 | .B ld\c | |
312 | \& command line included `\|\c | |
313 | .B \-ACA\c | |
314 | \|' as | |
315 | well as `\|\c | |
316 | .B \-ltry\c | |
317 | \|', the linker would look (in its built-in search | |
318 | paths, and in any paths you specify with \c | |
319 | .B \-L\c | |
320 | \&) for a library with | |
321 | the names | |
322 | .sp | |
323 | .br | |
324 | try | |
325 | .br | |
326 | libtry.a | |
327 | .br | |
328 | tryca | |
329 | .br | |
330 | libtryca.a | |
331 | .br | |
332 | .sp | |
333 | ||
334 | The first two possibilities would be considered in any event; the last | |
335 | two are due to the use of `\|\c | |
336 | .B \-ACA\c | |
337 | \|'. | |
338 | ||
339 | Future releases of \c | |
340 | .B ld\c | |
341 | \& may support similar functionality for | |
342 | other architecture families. | |
343 | ||
344 | You can meaningfully use \c | |
345 | .B \-A\c | |
346 | \& more than once on a command line, if | |
347 | an architecture family allows combination of target architectures; each | |
348 | use will add another pair of name variants to search for when \c | |
80165535 | 349 | .B \-l |
0e166a63 RP |
350 | specifies a library. |
351 | ||
352 | .TP | |
80165535 | 353 | .BI "\-b " "input-format" |
0e166a63 RP |
354 | Specify the binary format for input object files that follow this option |
355 | on the command line. You don't usually need to specify this, as | |
356 | \c | |
357 | .B ld\c | |
358 | \& is configured to expect as a default input format the most | |
359 | usual format on each machine. \c | |
360 | .I input-format\c | |
361 | \& is a text string, the | |
362 | name of a particular format supported by the BFD libraries. | |
363 | \c | |
364 | .B \-format \c | |
365 | .I input-format\c | |
366 | \&\c | |
346535cc DM |
367 | \& has the same effect, as does the script command |
368 | .BR TARGET . | |
0e166a63 RP |
369 | |
370 | You may want to use this option if you are linking files with an unusual | |
371 | binary format. You can also use \c | |
372 | .B \-b\c | |
373 | \& to switch formats explicitly (when | |
374 | linking object files of different formats), by including | |
375 | \c | |
376 | .B \-b \c | |
377 | .I input-format\c | |
378 | \&\c | |
379 | \& before each group of object files in a | |
380 | particular format. | |
381 | ||
382 | The default format is taken from the environment variable | |
383 | .B GNUTARGET\c | |
384 | \&. You can also define the input | |
385 | format from a script, using the command \c | |
386 | .B TARGET\c | |
387 | \&. | |
388 | ||
389 | .TP | |
390 | .B \-Bstatic | |
4551e108 ILT |
391 | Do not link against shared libraries. This is only meaningful on |
392 | platforms for which shared libraries are supported. | |
393 | ||
394 | .TP | |
395 | .B \-Bdynamic | |
396 | Link against dynamic libraries. This is only meaningful on platforms | |
397 | for which shared libraries are supported. This option is normally the | |
398 | default on such platforms. | |
399 | ||
400 | .TP | |
401 | .B \-Bsymbolic | |
402 | When creating a shared library, bind references to global symbols to | |
403 | the definition within the shared library, if any. Normally, it is | |
404 | possible for a program linked against a shared library to override the | |
405 | definition within the shared library. This option is only meaningful | |
406 | on ELF platforms which support shared libraries. | |
0e166a63 RP |
407 | |
408 | .TP | |
80165535 | 409 | .BI "\-c " "commandfile" |
0e166a63 RP |
410 | Directs \c |
411 | .B ld\c | |
412 | \& to read link commands from the file | |
413 | \c | |
414 | .I commandfile\c | |
415 | \&. These commands will completely override \c | |
416 | .B ld\c | |
417 | \&'s | |
418 | default link format (rather than adding to it); \c | |
419 | .I commandfile\c | |
420 | \& must | |
421 | specify everything necessary to describe the target format. | |
422 | ||
423 | ||
424 | You may also include a script of link commands directly in the command | |
425 | line by bracketing it between `\|\c | |
426 | .B {\c | |
427 | \|' and `\|\c | |
428 | .B }\c | |
429 | \|' characters. | |
430 | ||
07acd23b ILT |
431 | .TP |
432 | .B \-\-cref | |
433 | Output a cross reference table. If a linker map file is being | |
434 | generated, the cross reference table is printed to the map file. | |
435 | Otherwise, it is printed on the standard output. | |
436 | ||
0e166a63 RP |
437 | .TP |
438 | .B \-d | |
439 | .TP | |
440 | .B \-dc | |
441 | .TP | |
442 | .B \-dp | |
443 | These three options are equivalent; multiple forms are supported for | |
444 | compatibility with other linkers. Use any of them to make \c | |
80165535 | 445 | .B ld |
0e166a63 RP |
446 | assign space to common symbols even if a relocatable output file is |
447 | specified (\c | |
448 | .B \-r\c | |
449 | \&). The script command | |
450 | \c | |
451 | .B FORCE_COMMON_ALLOCATION\c | |
452 | \& has the same effect. | |
453 | ||
454 | .TP | |
80165535 | 455 | .BI "-defsym " "symbol" "\fR = \fP" expression |
0e166a63 RP |
456 | Create a global symbol in the output file, containing the absolute |
457 | address given by \c | |
458 | .I expression\c | |
459 | \&. You may use this option as many | |
460 | times as necessary to define multiple symbols in the command line. A | |
461 | limited form of arithmetic is supported for the \c | |
462 | .I expression\c | |
463 | \& in this | |
464 | context: you may give a hexadecimal constant or the name of an existing | |
465 | symbol, or use \c | |
466 | .B +\c | |
467 | \& and \c | |
468 | .B \-\c | |
469 | \& to add or subtract hexadecimal | |
470 | constants or symbols. If you need more elaborate expressions, consider | |
471 | using the linker command language from a script. | |
472 | ||
473 | .TP | |
474 | .BI "-e " "entry"\c | |
475 | \& | |
476 | Use \c | |
477 | .I entry\c | |
478 | \& as the explicit symbol for beginning execution of your | |
479 | program, rather than the default entry point. for a | |
480 | discussion of defaults and other ways of specifying the | |
481 | entry point. | |
482 | ||
39a6e282 ILT |
483 | .TP |
484 | .B \-embedded\-relocs | |
485 | This option is only meaningful when linking MIPS embedded PIC code, | |
486 | generated by the | |
487 | .B \-membedded\-pic | |
488 | option to the GNU compiler and assembler. It causes the linker to | |
489 | create a table which may be used at runtime to relocate any data which | |
490 | was statically initialized to pointer values. See the code in | |
491 | testsuite/ld-empic for details. | |
492 | ||
7ec9d825 ILT |
493 | .TP |
494 | .B \-E | |
4bdd9722 ILT |
495 | .TP |
496 | .B \-export\-dynamic | |
497 | When creating an ELF file, add all symbols to the dynamic symbol table. | |
498 | Normally, the dynamic symbol table contains only symbols which are used | |
499 | by a dynamic object. This option is needed for some uses of | |
500 | .I dlopen. | |
501 | ||
0e166a63 | 502 | .TP |
de220cbd | 503 | .BI "-f " "name" |
0e166a63 | 504 | .TP |
de220cbd ILT |
505 | .BI "--auxiliary " "name" |
506 | When creating an ELF shared object, set the internal DT_AUXILIARY field | |
507 | to the specified name. This tells the dynamic linker that the symbol | |
508 | table of the shared object should be used as an auxiliary filter on the | |
509 | symbol table of the shared object | |
510 | .I name. | |
511 | ||
512 | .TP | |
513 | .BI "-F " "name" | |
514 | .TP | |
515 | .BI "--filter " "name" | |
516 | When creating an ELF shared object, set the internal DT_FILTER field to | |
517 | the specified name. This tells the dynamic linker that the symbol table | |
518 | of the shared object should be used as a filter on the symbol table of | |
519 | the shared object | |
520 | .I name. | |
0e166a63 RP |
521 | |
522 | .TP | |
80165535 | 523 | .BI "\-format " "input\-format" |
0e166a63 RP |
524 | Synonym for \c |
525 | .B \-b\c | |
526 | \& \c | |
2a28d8b0 | 527 | .I input\-format\c |
0e166a63 RP |
528 | \&. |
529 | ||
530 | .TP | |
531 | .B \-g | |
532 | Accepted, but ignored; provided for compatibility with other tools. | |
533 | ||
8ddef552 DM |
534 | .TP |
535 | .BI "\-G " "size"\c | |
536 | Set the maximum size of objects to be optimized using the GP register | |
537 | to | |
538 | .I size | |
539 | under MIPS ECOFF. Ignored for other object file formats. | |
540 | ||
de220cbd ILT |
541 | .TP |
542 | .BI "-h " "name" | |
543 | .TP | |
544 | .BI "-soname " "name" | |
545 | When creating an ELF shared object, set the internal DT_SONAME field to | |
546 | the specified name. When an executable is linked with a shared object | |
547 | which has a DT_SONAME field, then when the executable is run the dynamic | |
548 | linker will attempt to load the shared object specified by the DT_SONAME | |
549 | field rather than the using the file name given to the linker. | |
550 | ||
bf065bfd DM |
551 | .TP |
552 | .B \-\-help | |
553 | Print a summary of the command-line options on the standard output and exit. | |
554 | This option and | |
555 | .B \-\-version | |
556 | begin with two dashes instead of one | |
557 | for compatibility with other GNU programs. The other options start with | |
558 | only one dash for compatibility with other linkers. | |
559 | ||
0e166a63 RP |
560 | .TP |
561 | .B \-i | |
562 | Perform an incremental link (same as option \c | |
563 | .B \-r\c | |
564 | \&). | |
565 | ||
566 | .TP | |
2a28d8b0 | 567 | .BI "\-l" "ar"\c |
0e166a63 RP |
568 | \& |
569 | Add an archive file \c | |
570 | .I ar\c | |
571 | \& to the list of files to link. This | |
572 | option may be used any number of times. \c | |
573 | .B ld\c | |
574 | \& will search its | |
575 | path-list for occurrences of \c | |
576 | .B lib\c | |
577 | .I ar\c | |
578 | \&.a\c | |
579 | \& for every \c | |
80165535 | 580 | .I ar |
0e166a63 RP |
581 | specified. |
582 | ||
583 | .TP | |
80165535 | 584 | .BI "\-L" "searchdir" |
0e166a63 RP |
585 | This command adds path \c |
586 | .I searchdir\c | |
587 | \& to the list of paths that | |
588 | \c | |
589 | .B ld\c | |
590 | \& will search for archive libraries. You may use this option | |
591 | any number of times. | |
592 | ||
593 | The default set of paths searched (without being specified with | |
594 | \c | |
595 | .B \-L\c | |
596 | \&) depends on what emulation mode \c | |
597 | .B ld\c | |
598 | \& is using, and in | |
599 | some cases also on how it was configured. The | |
600 | paths can also be specified in a link script with the \c | |
80165535 | 601 | .B SEARCH_DIR |
0e166a63 RP |
602 | command. |
603 | ||
604 | .TP | |
605 | .B \-M | |
0e166a63 RP |
606 | Print (to the standard output file) a link map\(em\&diagnostic information |
607 | about where symbols are mapped by \c | |
608 | .B ld\c | |
609 | \&, and information on global | |
610 | common storage allocation. | |
611 | ||
d18a4527 DM |
612 | .TP |
613 | .BI "\-Map " "mapfile"\c | |
614 | Print to the file | |
615 | .I mapfile | |
616 | a link map\(em\&diagnostic information | |
617 | about where symbols are mapped by \c | |
618 | .B ld\c | |
619 | \&, and information on global | |
620 | common storage allocation. | |
621 | ||
8ddef552 DM |
622 | .TP |
623 | .BI "\-m " "emulation"\c | |
624 | Emulate the | |
625 | .I emulation | |
626 | linker. You can list the available emulations with the | |
a82ae15d | 627 | .I \-\-verbose |
1f59c7a7 ILT |
628 | or |
629 | .I \-V | |
630 | options. This option overrides the compiled-in default, which is the | |
8ddef552 DM |
631 | system for which you configured |
632 | .BR ld . | |
633 | ||
0e166a63 RP |
634 | .TP |
635 | .B \-N | |
636 | specifies readable and writable \c | |
637 | .B text\c | |
638 | \& and \c | |
639 | .B data\c | |
640 | \& sections. If | |
641 | the output format supports Unix style magic numbers, the output is | |
642 | marked as \c | |
643 | .B OMAGIC\c | |
644 | \&. | |
645 | ||
646 | When you use the `\|\c | |
647 | .B \-N\c | |
648 | \&\|' option, the linker does not page-align the | |
649 | data segment. | |
650 | ||
651 | .TP | |
652 | .B \-n | |
653 | sets the text segment to be read only, and \c | |
654 | .B NMAGIC\c | |
655 | \& is written | |
656 | if possible. | |
657 | ||
658 | .TP | |
2a28d8b0 | 659 | .B \-noinhibit\-exec |
0e166a63 RP |
660 | Normally, the linker will not produce an output file if it encounters |
661 | errors during the link process. With this flag, you can specify that | |
662 | you wish the output file retained even after non-fatal errors. | |
663 | ||
e920526d ILT |
664 | .TP |
665 | .B \-no\-keep\-memory | |
666 | The linker normally optimizes for speed over memory usage by caching | |
667 | the symbol tables of input files in memory. This option tells the | |
668 | linker to instead optimize for memory usage, by rereading the symbol | |
669 | tables as necessary. This may be required if the linker runs out of | |
670 | memory space while linking a large executable. | |
671 | ||
a8880eda ILT |
672 | .TP |
673 | .B \-no\-warn\-mismatch | |
674 | Normally the linker will give an error if you try to link together | |
675 | input files that are mismatched for some reason, perhaps because they | |
676 | have been compiled for different processors or for different | |
677 | endiannesses. This option tells the linker that it should silently | |
678 | permit such possible errors. This option should only be used with | |
679 | care, in cases when you have taken some special action that ensures | |
680 | that the linker errors are inappropriate. | |
681 | ||
0e166a63 | 682 | .TP |
80165535 | 683 | .BI "\-o " "output" |
0e166a63 RP |
684 | .I output\c |
685 | \& is a name for the program produced by \c | |
686 | .B ld\c | |
687 | \&; if this | |
688 | option is not specified, the name `\|\c | |
689 | .B a.out\c | |
690 | \|' is used by default. The | |
691 | script command \c | |
692 | .B OUTPUT\c | |
693 | \& can also specify the output file name. | |
694 | ||
c470f2eb UD |
695 | .TP |
696 | .BI "\-O" "level" | |
697 | Generate optimized output files. This might use significantly more | |
698 | time and therefore probably should be enabled only for generating the | |
699 | final binary. | |
700 | \c | |
701 | .I level\c | |
702 | \& is supposed to be a numeric value. Any value greater than zero enables | |
703 | the optimizations. | |
704 | ||
346535cc | 705 | .TP |
80165535 | 706 | .BI "\-oformat " "output\-format" |
346535cc DM |
707 | Specify the binary format for the output object file. |
708 | You don't usually need to specify this, as | |
709 | \c | |
710 | .B ld\c | |
711 | \& is configured to produce as a default output format the most | |
712 | usual format on each machine. \c | |
713 | .I output-format\c | |
714 | \& is a text string, the | |
715 | name of a particular format supported by the BFD libraries. | |
716 | The script command | |
717 | .B OUTPUT_FORMAT | |
718 | can also specify the output format, but this option overrides it. | |
719 | ||
0e166a63 | 720 | .TP |
80165535 | 721 | .BI "\-R " "filename" |
0e166a63 RP |
722 | Read symbol names and their addresses from \c |
723 | .I filename\c | |
724 | \&, but do not | |
725 | relocate it or include it in the output. This allows your output file | |
726 | to refer symbolically to absolute locations of memory defined in other | |
727 | programs. | |
728 | ||
729 | .TP | |
730 | .B \-relax | |
731 | An option with machine dependent effects. Currently this option is only | |
732 | supported on the H8/300. | |
733 | ||
734 | On some platforms, use this option to perform global optimizations that | |
735 | become possible when the linker resolves addressing in your program, such | |
736 | as relaxing address modes and synthesizing new instructions in the | |
737 | output object file. | |
738 | ||
739 | On platforms where this is not supported, `\|\c | |
740 | .B \-relax\c | |
741 | \&\|' is accepted, but has no effect. | |
742 | ||
743 | .TP | |
744 | .B \-r | |
745 | Generates relocatable output\(em\&i.e., generate an output file that can in | |
746 | turn serve as input to \c | |
747 | .B ld\c | |
748 | \&. This is often called \c | |
749 | .I partial | |
750 | linking\c | |
751 | \&. As a side effect, in environments that support standard Unix | |
752 | magic numbers, this option also sets the output file's magic number to | |
753 | \c | |
754 | .B OMAGIC\c | |
755 | \&. | |
756 | If this option is not specified, an absolute file is produced. When | |
757 | linking C++ programs, this option \c | |
758 | .I will not\c | |
759 | \& resolve references to | |
760 | constructors; \c | |
761 | .B \-Ur\c | |
762 | \& is an alternative. | |
763 | ||
764 | This option does the same as \c | |
765 | .B \-i\c | |
766 | \&. | |
767 | ||
5caef232 ILT |
768 | .TP |
769 | .B \-rpath\ \fIdirectory | |
770 | Add a directory to the runtime library search path. This is used when | |
771 | linking an ELF executable with shared objects. All | |
772 | .B \-rpath | |
773 | arguments are concatenated and passed to the runtime linker, which uses | |
774 | them to locate shared objects at runtime. The | |
775 | .B \-rpath | |
776 | option is also used when locating shared objects which are needed by | |
777 | shared objects explicitly included in the link; see the description of | |
778 | the | |
779 | .B \-rpath\-link | |
20406675 ILT |
780 | option. If |
781 | .B \-rpath | |
782 | is not used when linking an ELF executable, the contents of the | |
783 | environment variable | |
784 | .B LD_RUN_PATH | |
785 | will be used if it is defined. | |
5caef232 ILT |
786 | |
787 | The | |
788 | .B \-rpath | |
789 | option may also be used on SunOS. By default, on SunOS, the linker | |
790 | will form a runtime search patch out of all the | |
791 | .B \-L | |
792 | options it is given. If a | |
4bdd9722 ILT |
793 | .B \-rpath |
794 | option is used, the runtime search path will be formed exclusively | |
795 | using the | |
5caef232 ILT |
796 | .B \-rpath |
797 | options, ignoring | |
798 | the | |
799 | .B \-L | |
800 | options. This can be useful when using gcc, which adds many | |
801 | .B \-L | |
802 | options which may be on NFS mounted filesystems. | |
803 | ||
804 | .TP | |
805 | .B \-rpath\-link\ \fIdirectory | |
235c6a67 ILT |
806 | When using ELF or SunOS, one shared library may require another. This |
807 | happens when an | |
5caef232 ILT |
808 | .B ld\ \-shared |
809 | link includes a shared library as one of the input files. | |
810 | ||
811 | When the linker encounters such a dependency when doing a non-shared, | |
812 | non-relocateable link, it will automatically try to locate the required | |
813 | shared library and include it in the link, if it is not included | |
814 | explicitly. In such a case, the | |
815 | .B \-rpath\-link | |
816 | option specifies the first set of directories to search. The | |
817 | .B \-rpath\-link | |
818 | option may specify a sequence of directory names either by specifying | |
819 | a list of names separated by colons, or by appearing multiple times. | |
820 | ||
821 | If the required shared library is not found, the linker will issue a | |
822 | warning and continue with the link. | |
823 | ||
0e166a63 RP |
824 | .TP |
825 | .B \-S | |
826 | Omits debugger symbol information (but not all symbols) from the output file. | |
827 | ||
828 | .TP | |
829 | .B \-s | |
830 | Omits all symbol information from the output file. | |
831 | ||
4551e108 ILT |
832 | .TP |
833 | .B \-shared | |
235c6a67 ILT |
834 | Create a shared library. This is currently only supported on ELF and |
835 | SunOS platforms (on SunOS it is not required, as the linker will | |
836 | automatically create a shared library when there are undefined symbols | |
837 | and the | |
838 | .B \-e | |
839 | option is not used). | |
4551e108 | 840 | |
0e166a63 | 841 | .TP |
2a28d8b0 DM |
842 | .B \-sort\-common |
843 | Normally, when | |
844 | .B ld | |
845 | places the global common symbols in the appropriate output sections, | |
846 | it sorts them by size. First come all the one byte symbols, then all | |
847 | the two bytes, then all the four bytes, and then everything else. | |
da08e9b9 DM |
848 | This is to prevent gaps between symbols due to |
849 | alignment constraints. This option disables that sorting. | |
2a28d8b0 | 850 | |
ec586565 ILT |
851 | .TP |
852 | .B \-split\-by\-reloc\ \fIcount | |
853 | Trys to creates extra sections in the output file so that no single | |
854 | output section in the file contains more than | |
855 | .I count | |
856 | relocations. | |
857 | This is useful when generating huge relocatable for downloading into | |
858 | certain real time kernels with the COFF object file format; since COFF | |
859 | cannot represent more than 65535 relocations in a single section. | |
860 | Note that this will fail to work with object file formats which do not | |
861 | support arbitrary sections. The linker will not split up individual | |
862 | input sections for redistribution, so if a single input section | |
863 | contains more than | |
864 | .I count | |
865 | relocations one output section will contain that many relocations. | |
866 | ||
867 | .TP | |
868 | .B \-split\-by\-file | |
869 | Similar to | |
870 | .B \-split\-by\-reloc | |
871 | but creates a new output section for each input file. | |
872 | ||
2a28d8b0 DM |
873 | .TP |
874 | .BI "\-Tbss " "org"\c | |
0e166a63 | 875 | .TP |
2a28d8b0 | 876 | .BI "\-Tdata " "org"\c |
0e166a63 | 877 | .TP |
2a28d8b0 | 878 | .BI "\-Ttext " "org"\c |
0e166a63 RP |
879 | Use \c |
880 | .I org\c | |
881 | \& as the starting address for\(em\&respectively\(em\&the | |
882 | \c | |
883 | .B bss\c | |
884 | \&, \c | |
885 | .B data\c | |
886 | \&, or the \c | |
887 | .B text\c | |
888 | \& segment of the output file. | |
889 | \c | |
890 | .I textorg\c | |
891 | \& must be a hexadecimal integer. | |
892 | ||
893 | .TP | |
80165535 | 894 | .BI "\-T " "commandfile" |
0e166a63 RP |
895 | Equivalent to \c |
896 | .B \-c \c | |
897 | .I commandfile\c | |
898 | \&\c | |
899 | \&; supported for compatibility with | |
900 | other tools. | |
901 | ||
902 | .TP | |
903 | .B \-t | |
904 | Prints names of input files as \c | |
905 | .B ld\c | |
906 | \& processes them. | |
907 | ||
908 | .TP | |
2a28d8b0 | 909 | .BI "\-u " "sym" |
0e166a63 RP |
910 | Forces \c |
911 | .I sym\c | |
912 | \& to be entered in the output file as an undefined symbol. | |
913 | This may, for example, trigger linking of additional modules from | |
914 | standard libraries. \c | |
915 | .B \-u\c | |
916 | \& may be repeated with different option | |
917 | arguments to enter additional undefined symbols. | |
918 | ||
919 | .TP | |
920 | .B \-Ur | |
921 | For anything other than C++ programs, this option is equivalent to | |
922 | \c | |
923 | .B \-r\c | |
924 | \&: it generates relocatable output\(em\&i.e., an output file that can in | |
925 | turn serve as input to \c | |
926 | .B ld\c | |
927 | \&. When linking C++ programs, \c | |
80165535 | 928 | .B \-Ur |
0e166a63 RP |
929 | .I will\c |
930 | \& resolve references to constructors, unlike \c | |
931 | .B \-r\c | |
932 | \&. | |
933 | ||
8ddef552 | 934 | .TP |
a82ae15d | 935 | .B \-\-verbose |
8ddef552 DM |
936 | Display the version number for \c |
937 | .B ld | |
938 | and list the supported emulations. | |
de87cdb4 | 939 | Display which input files can and can not be opened. |
8ddef552 | 940 | |
0e166a63 | 941 | .TP |
a82ae15d | 942 | .B \-v, \-V |
0e166a63 RP |
943 | Display the version number for \c |
944 | .B ld\c | |
945 | \&. | |
1f59c7a7 ILT |
946 | The |
947 | .B \-V | |
948 | option also lists the supported emulations. | |
0e166a63 | 949 | |
bf065bfd DM |
950 | .TP |
951 | .B \-\-version | |
952 | Display the version number for \c | |
953 | .B ld | |
954 | and exit. | |
955 | ||
2a28d8b0 DM |
956 | .TP |
957 | .B \-warn\-common | |
958 | Warn when a common symbol is combined with another common symbol or with | |
959 | a symbol definition. Unix linkers allow this somewhat sloppy practice, | |
960 | but linkers on some other operating systems do not. This option allows | |
961 | you to find potential problems from combining global symbols. | |
962 | ||
a89d9f5b ILT |
963 | .TP |
964 | .B \-warn\-constructors | |
965 | Warn if any global constructors are used. This is only useful for a | |
966 | few object file formats. For formats like COFF or ELF, the linker can | |
967 | not detect the use of global constructors. | |
968 | ||
4b7d2399 ILT |
969 | .TP |
970 | .B \-warn\-multiple\-gp | |
971 | Warn if the output file requires multiple global-pointer values. This | |
972 | option is only meaningful for certain processors, such as the Alpha. | |
973 | ||
809ee7e0 ILT |
974 | .TP |
975 | .B \-warn\-once | |
976 | Only warn once for each undefined symbol, rather than once per module | |
977 | which refers to it. | |
978 | ||
458fc056 ILT |
979 | .TP |
980 | .B \-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 section. | |
983 | The address will only be changed if it not explicitly specified; that | |
984 | is, if the SECTIONS command does not specify a start address for the | |
985 | section. | |
986 | ||
ee499d81 ILT |
987 | .TP |
988 | .B \-\-whole\-archive | |
3c8deccc ILT |
989 | For each archive mentioned on the command line after the |
990 | .B \-\-whole\-archive | |
991 | option, include every object file in the archive in the link, rather | |
992 | than searching the archive for the required object files. This is | |
993 | normally used to turn an archive file into a shared library, forcing | |
994 | every object to be included in the resulting shared library. | |
995 | ||
996 | .TP | |
997 | .B \-\-no\-whole\-archive | |
998 | Turn off the effect of the | |
999 | .B \-\-whole\-archive | |
1000 | option for archives which appear later on the command line. | |
ee499d81 | 1001 | |
e3d73386 ILT |
1002 | .TP |
1003 | .BI "--wrap " "symbol" | |
1004 | Use a wrapper function for | |
1005 | .I symbol. | |
1006 | Any undefined reference to | |
1007 | .I symbol | |
1008 | will be resolved to | |
1009 | .BI "__wrap_" "symbol". | |
1010 | Any undefined reference to | |
1011 | .BI "__real_" "symbol" | |
1012 | will be resolved to | |
1013 | .I symbol. | |
1014 | ||
0e166a63 RP |
1015 | .TP |
1016 | .B \-X | |
21a2f026 ILT |
1017 | Delete all temporary local symbols. For most targets, this is all local |
1018 | symbols whose names begin with `\|\c | |
0e166a63 RP |
1019 | .B L\c |
1020 | \|'. | |
1021 | ||
1022 | .TP | |
1023 | .B \-x | |
21a2f026 | 1024 | Delete all local symbols. |
0e166a63 RP |
1025 | |
1026 | .PP | |
1027 | ||
1028 | .SH ENVIRONMENT | |
1029 | \c | |
8ddef552 | 1030 | You can change the behavior of |
0e166a63 | 1031 | .B ld\c |
8ddef552 | 1032 | \& with the environment variable \c |
0e166a63 | 1033 | .B GNUTARGET\c |
8ddef552 | 1034 | \&. |
0e166a63 RP |
1035 | |
1036 | \c | |
1037 | .B GNUTARGET\c | |
1038 | \& determines the input-file object format if you don't | |
1039 | use \c | |
1040 | .B \-b\c | |
1041 | \& (or its synonym \c | |
1042 | .B \-format\c | |
1043 | \&). Its value should be one | |
1044 | of the BFD names for an input format. If there is no | |
1045 | \c | |
1046 | .B GNUTARGET\c | |
1047 | \& in the environment, \c | |
1048 | .B ld\c | |
1049 | \& uses the natural format | |
1050 | of the host. If \c | |
1051 | .B GNUTARGET\c | |
1052 | \& is set to \c | |
1053 | .B default\c | |
1054 | \& then BFD attempts to discover the | |
1055 | input format by examining binary input files; this method often | |
1056 | succeeds, but there are potential ambiguities, since there is no method | |
1057 | of ensuring that the magic number used to flag object-file formats is | |
1058 | unique. However, the configuration procedure for BFD on each system | |
1059 | places the conventional format for that system first in the search-list, | |
1060 | so ambiguities are resolved in favor of convention. | |
1061 | ||
0e166a63 RP |
1062 | .PP |
1063 | ||
1064 | .SH "SEE ALSO" | |
1065 | ||
1066 | .BR objdump ( 1 ) | |
1067 | .br | |
1068 | .br | |
1069 | .RB "`\|" ld "\|' and `\|" binutils "\|'" | |
1070 | entries in | |
1071 | .B info\c | |
1072 | .br | |
1073 | .I | |
1074 | ld: the GNU linker\c | |
1075 | , Steve Chamberlain and Roland Pesch; | |
1076 | .I | |
1077 | The GNU Binary Utilities\c | |
1078 | , Roland H. Pesch. | |
1079 | ||
1080 | .SH COPYING | |
1081 | Copyright (c) 1991, 1992 Free Software Foundation, Inc. | |
1082 | .PP | |
1083 | Permission is granted to make and distribute verbatim copies of | |
1084 | this manual provided the copyright notice and this permission notice | |
1085 | are preserved on all copies. | |
1086 | .PP | |
1087 | Permission is granted to copy and distribute modified versions of this | |
1088 | manual under the conditions for verbatim copying, provided that the | |
1089 | entire resulting derived work is distributed under the terms of a | |
1090 | permission notice identical to this one. | |
1091 | .PP | |
1092 | Permission is granted to copy and distribute translations of this | |
1093 | manual into another language, under the above conditions for modified | |
1094 | versions, except that this permission notice may be included in | |
1095 | translations approved by the Free Software Foundation instead of in | |
1096 | the original English. |