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