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