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