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