1This is ld.info, produced by makeinfo version 6.4 from ld.texi. 2 3This file documents the GNU linker LD (GNU Binutils) version 2.30.90. 4 5 Copyright (C) 1991-2018 Free Software Foundation, Inc. 6 7 Permission is granted to copy, distribute and/or modify this document 8under the terms of the GNU Free Documentation License, Version 1.3 or 9any later version published by the Free Software Foundation; with no 10Invariant Sections, with no Front-Cover Texts, and with no Back-Cover 11Texts. A copy of the license is included in the section entitled "GNU 12Free Documentation License". 13INFO-DIR-SECTION Software development 14START-INFO-DIR-ENTRY 15* Ld: (ld). The GNU linker. 16END-INFO-DIR-ENTRY 17 18 19File: ld.info, Node: Top, Next: Overview, Up: (dir) 20 21LD 22** 23 24This file documents the GNU linker ld (GNU Binutils) version 2.30.90. 25 26 This document is distributed under the terms of the GNU Free 27Documentation License version 1.3. A copy of the license is included in 28the section entitled "GNU Free Documentation License". 29 30* Menu: 31 32* Overview:: Overview 33* Invocation:: Invocation 34* Scripts:: Linker Scripts 35* Machine Dependent:: Machine Dependent Features 36* BFD:: BFD 37 38* Reporting Bugs:: Reporting Bugs 39* MRI:: MRI Compatible Script Files 40* GNU Free Documentation License:: GNU Free Documentation License 41* LD Index:: LD Index 42 43 44File: ld.info, Node: Overview, Next: Invocation, Prev: Top, Up: Top 45 461 Overview 47********** 48 49'ld' combines a number of object and archive files, relocates their data 50and ties up symbol references. Usually the last step in compiling a 51program is to run 'ld'. 52 53 'ld' accepts Linker Command Language files written in a superset of 54AT&T's Link Editor Command Language syntax, to provide explicit and 55total control over the linking process. 56 57 This version of 'ld' uses the general purpose BFD libraries to 58operate on object files. This allows 'ld' to read, combine, and write 59object files in many different formats--for example, COFF or 'a.out'. 60Different formats may be linked together to produce any available kind 61of object file. *Note BFD::, for more information. 62 63 Aside from its flexibility, the GNU linker is more helpful than other 64linkers in providing diagnostic information. Many linkers abandon 65execution immediately upon encountering an error; whenever possible, 66'ld' continues executing, allowing you to identify other errors (or, in 67some cases, to get an output file in spite of the error). 68 69 70File: ld.info, Node: Invocation, Next: Scripts, Prev: Overview, Up: Top 71 722 Invocation 73************ 74 75The GNU linker 'ld' is meant to cover a broad range of situations, and 76to be as compatible as possible with other linkers. As a result, you 77have many choices to control its behavior. 78 79* Menu: 80 81* Options:: Command Line Options 82* Environment:: Environment Variables 83 84 85File: ld.info, Node: Options, Next: Environment, Up: Invocation 86 872.1 Command Line Options 88======================== 89 90The linker supports a plethora of command-line options, but in actual 91practice few of them are used in any particular context. For instance, 92a frequent use of 'ld' is to link standard Unix object files on a 93standard, supported Unix system. On such a system, to link a file 94'hello.o': 95 96 ld -o OUTPUT /lib/crt0.o hello.o -lc 97 98 This tells 'ld' to produce a file called OUTPUT as the result of 99linking the file '/lib/crt0.o' with 'hello.o' and the library 'libc.a', 100which will come from the standard search directories. (See the 101discussion of the '-l' option below.) 102 103 Some of the command-line options to 'ld' may be specified at any 104point in the command line. However, options which refer to files, such 105as '-l' or '-T', cause the file to be read at the point at which the 106option appears in the command line, relative to the object files and 107other file options. Repeating non-file options with a different 108argument will either have no further effect, or override prior 109occurrences (those further to the left on the command line) of that 110option. Options which may be meaningfully specified more than once are 111noted in the descriptions below. 112 113 Non-option arguments are object files or archives which are to be 114linked together. They may follow, precede, or be mixed in with 115command-line options, except that an object file argument may not be 116placed between an option and its argument. 117 118 Usually the linker is invoked with at least one object file, but you 119can specify other forms of binary input files using '-l', '-R', and the 120script command language. If _no_ binary input files at all are 121specified, the linker does not produce any output, and issues the 122message 'No input files'. 123 124 If the linker cannot recognize the format of an object file, it will 125assume that it is a linker script. A script specified in this way 126augments the main linker script used for the link (either the default 127linker script or the one specified by using '-T'). This feature permits 128the linker to link against a file which appears to be an object or an 129archive, but actually merely defines some symbol values, or uses 'INPUT' 130or 'GROUP' to load other objects. Specifying a script in this way 131merely augments the main linker script, with the extra commands placed 132after the main script; use the '-T' option to replace the default linker 133script entirely, but note the effect of the 'INSERT' command. *Note 134Scripts::. 135 136 For options whose names are a single letter, option arguments must 137either follow the option letter without intervening whitespace, or be 138given as separate arguments immediately following the option that 139requires them. 140 141 For options whose names are multiple letters, either one dash or two 142can precede the option name; for example, '-trace-symbol' and 143'--trace-symbol' are equivalent. Note--there is one exception to this 144rule. Multiple letter options that start with a lower case 'o' can only 145be preceded by two dashes. This is to reduce confusion with the '-o' 146option. So for example '-omagic' sets the output file name to 'magic' 147whereas '--omagic' sets the NMAGIC flag on the output. 148 149 Arguments to multiple-letter options must either be separated from 150the option name by an equals sign, or be given as separate arguments 151immediately following the option that requires them. For example, 152'--trace-symbol foo' and '--trace-symbol=foo' are equivalent. Unique 153abbreviations of the names of multiple-letter options are accepted. 154 155 Note--if the linker is being invoked indirectly, via a compiler 156driver (e.g. 'gcc') then all the linker command line options should be 157prefixed by '-Wl,' (or whatever is appropriate for the particular 158compiler driver) like this: 159 160 gcc -Wl,--start-group foo.o bar.o -Wl,--end-group 161 162 This is important, because otherwise the compiler driver program may 163silently drop the linker options, resulting in a bad link. Confusion 164may also arise when passing options that require values through a 165driver, as the use of a space between option and argument acts as a 166separator, and causes the driver to pass only the option to the linker 167and the argument to the compiler. In this case, it is simplest to use 168the joined forms of both single- and multiple-letter options, such as: 169 170 gcc foo.o bar.o -Wl,-eENTRY -Wl,-Map=a.map 171 172 Here is a table of the generic command line switches accepted by the 173GNU linker: 174 175'@FILE' 176 Read command-line options from FILE. The options read are inserted 177 in place of the original @FILE option. If FILE does not exist, or 178 cannot be read, then the option will be treated literally, and not 179 removed. 180 181 Options in FILE are separated by whitespace. A whitespace 182 character may be included in an option by surrounding the entire 183 option in either single or double quotes. Any character (including 184 a backslash) may be included by prefixing the character to be 185 included with a backslash. The FILE may itself contain additional 186 @FILE options; any such options will be processed recursively. 187 188'-a KEYWORD' 189 This option is supported for HP/UX compatibility. The KEYWORD 190 argument must be one of the strings 'archive', 'shared', or 191 'default'. '-aarchive' is functionally equivalent to '-Bstatic', 192 and the other two keywords are functionally equivalent to 193 '-Bdynamic'. This option may be used any number of times. 194 195'--audit AUDITLIB' 196 Adds AUDITLIB to the 'DT_AUDIT' entry of the dynamic section. 197 AUDITLIB is not checked for existence, nor will it use the 198 DT_SONAME specified in the library. If specified multiple times 199 'DT_AUDIT' will contain a colon separated list of audit interfaces 200 to use. If the linker finds an object with an audit entry while 201 searching for shared libraries, it will add a corresponding 202 'DT_DEPAUDIT' entry in the output file. This option is only 203 meaningful on ELF platforms supporting the rtld-audit interface. 204 205'-b INPUT-FORMAT' 206'--format=INPUT-FORMAT' 207 'ld' may be configured to support more than one kind of object 208 file. If your 'ld' is configured this way, you can use the '-b' 209 option to specify the binary format for input object files that 210 follow this option on the command line. Even when 'ld' is 211 configured to support alternative object formats, you don't usually 212 need to specify this, as 'ld' should be configured to expect as a 213 default input format the most usual format on each machine. 214 INPUT-FORMAT is a text string, the name of a particular format 215 supported by the BFD libraries. (You can list the available binary 216 formats with 'objdump -i'.) *Note BFD::. 217 218 You may want to use this option if you are linking files with an 219 unusual binary format. You can also use '-b' to switch formats 220 explicitly (when linking object files of different formats), by 221 including '-b INPUT-FORMAT' before each group of object files in a 222 particular format. 223 224 The default format is taken from the environment variable 225 'GNUTARGET'. *Note Environment::. You can also define the input 226 format from a script, using the command 'TARGET'; see *note Format 227 Commands::. 228 229'-c MRI-COMMANDFILE' 230'--mri-script=MRI-COMMANDFILE' 231 For compatibility with linkers produced by MRI, 'ld' accepts script 232 files written in an alternate, restricted command language, 233 described in *note MRI Compatible Script Files: MRI. Introduce MRI 234 script files with the option '-c'; use the '-T' option to run 235 linker scripts written in the general-purpose 'ld' scripting 236 language. If MRI-CMDFILE does not exist, 'ld' looks for it in the 237 directories specified by any '-L' options. 238 239'-d' 240'-dc' 241'-dp' 242 These three options are equivalent; multiple forms are supported 243 for compatibility with other linkers. They assign space to common 244 symbols even if a relocatable output file is specified (with '-r'). 245 The script command 'FORCE_COMMON_ALLOCATION' has the same effect. 246 *Note Miscellaneous Commands::. 247 248'--depaudit AUDITLIB' 249'-P AUDITLIB' 250 Adds AUDITLIB to the 'DT_DEPAUDIT' entry of the dynamic section. 251 AUDITLIB is not checked for existence, nor will it use the 252 DT_SONAME specified in the library. If specified multiple times 253 'DT_DEPAUDIT' will contain a colon separated list of audit 254 interfaces to use. This option is only meaningful on ELF platforms 255 supporting the rtld-audit interface. The -P option is provided for 256 Solaris compatibility. 257 258'-e ENTRY' 259'--entry=ENTRY' 260 Use ENTRY as the explicit symbol for beginning execution of your 261 program, rather than the default entry point. If there is no 262 symbol named ENTRY, the linker will try to parse ENTRY as a number, 263 and use that as the entry address (the number will be interpreted 264 in base 10; you may use a leading '0x' for base 16, or a leading 265 '0' for base 8). *Note Entry Point::, for a discussion of defaults 266 and other ways of specifying the entry point. 267 268'--exclude-libs LIB,LIB,...' 269 Specifies a list of archive libraries from which symbols should not 270 be automatically exported. The library names may be delimited by 271 commas or colons. Specifying '--exclude-libs ALL' excludes symbols 272 in all archive libraries from automatic export. This option is 273 available only for the i386 PE targeted port of the linker and for 274 ELF targeted ports. For i386 PE, symbols explicitly listed in a 275 .def file are still exported, regardless of this option. For ELF 276 targeted ports, symbols affected by this option will be treated as 277 hidden. 278 279'--exclude-modules-for-implib MODULE,MODULE,...' 280 Specifies a list of object files or archive members, from which 281 symbols should not be automatically exported, but which should be 282 copied wholesale into the import library being generated during the 283 link. The module names may be delimited by commas or colons, and 284 must match exactly the filenames used by 'ld' to open the files; 285 for archive members, this is simply the member name, but for object 286 files the name listed must include and match precisely any path 287 used to specify the input file on the linker's command-line. This 288 option is available only for the i386 PE targeted port of the 289 linker. Symbols explicitly listed in a .def file are still 290 exported, regardless of this option. 291 292'-E' 293'--export-dynamic' 294'--no-export-dynamic' 295 When creating a dynamically linked executable, using the '-E' 296 option or the '--export-dynamic' option causes the linker to add 297 all symbols to the dynamic symbol table. The dynamic symbol table 298 is the set of symbols which are visible from dynamic objects at run 299 time. 300 301 If you do not use either of these options (or use the 302 '--no-export-dynamic' option to restore the default behavior), the 303 dynamic symbol table will normally contain only those symbols which 304 are referenced by some dynamic object mentioned in the link. 305 306 If you use 'dlopen' to load a dynamic object which needs to refer 307 back to the symbols defined by the program, rather than some other 308 dynamic object, then you will probably need to use this option when 309 linking the program itself. 310 311 You can also use the dynamic list to control what symbols should be 312 added to the dynamic symbol table if the output format supports it. 313 See the description of '--dynamic-list'. 314 315 Note that this option is specific to ELF targeted ports. PE 316 targets support a similar function to export all symbols from a DLL 317 or EXE; see the description of '--export-all-symbols' below. 318 319'-EB' 320 Link big-endian objects. This affects the default output format. 321 322'-EL' 323 Link little-endian objects. This affects the default output 324 format. 325 326'-f NAME' 327'--auxiliary=NAME' 328 When creating an ELF shared object, set the internal DT_AUXILIARY 329 field to the specified name. This tells the dynamic linker that 330 the symbol table of the shared object should be used as an 331 auxiliary filter on the symbol table of the shared object NAME. 332 333 If you later link a program against this filter object, then, when 334 you run the program, the dynamic linker will see the DT_AUXILIARY 335 field. If the dynamic linker resolves any symbols from the filter 336 object, it will first check whether there is a definition in the 337 shared object NAME. If there is one, it will be used instead of 338 the definition in the filter object. The shared object NAME need 339 not exist. Thus the shared object NAME may be used to provide an 340 alternative implementation of certain functions, perhaps for 341 debugging or for machine specific performance. 342 343 This option may be specified more than once. The DT_AUXILIARY 344 entries will be created in the order in which they appear on the 345 command line. 346 347'-F NAME' 348'--filter=NAME' 349 When creating an ELF shared object, set the internal DT_FILTER 350 field to the specified name. This tells the dynamic linker that 351 the symbol table of the shared object which is being created should 352 be used as a filter on the symbol table of the shared object NAME. 353 354 If you later link a program against this filter object, then, when 355 you run the program, the dynamic linker will see the DT_FILTER 356 field. The dynamic linker will resolve symbols according to the 357 symbol table of the filter object as usual, but it will actually 358 link to the definitions found in the shared object NAME. Thus the 359 filter object can be used to select a subset of the symbols 360 provided by the object NAME. 361 362 Some older linkers used the '-F' option throughout a compilation 363 toolchain for specifying object-file format for both input and 364 output object files. The GNU linker uses other mechanisms for this 365 purpose: the '-b', '--format', '--oformat' options, the 'TARGET' 366 command in linker scripts, and the 'GNUTARGET' environment 367 variable. The GNU linker will ignore the '-F' option when not 368 creating an ELF shared object. 369 370'-fini=NAME' 371 When creating an ELF executable or shared object, call NAME when 372 the executable or shared object is unloaded, by setting DT_FINI to 373 the address of the function. By default, the linker uses '_fini' 374 as the function to call. 375 376'-g' 377 Ignored. Provided for compatibility with other tools. 378 379'-G VALUE' 380'--gpsize=VALUE' 381 Set the maximum size of objects to be optimized using the GP 382 register to SIZE. This is only meaningful for object file formats 383 such as MIPS ELF that support putting large and small objects into 384 different sections. This is ignored for other object file formats. 385 386'-h NAME' 387'-soname=NAME' 388 When creating an ELF shared object, set the internal DT_SONAME 389 field to the specified name. When an executable is linked with a 390 shared object which has a DT_SONAME field, then when the executable 391 is run the dynamic linker will attempt to load the shared object 392 specified by the DT_SONAME field rather than the using the file 393 name given to the linker. 394 395'-i' 396 Perform an incremental link (same as option '-r'). 397 398'-init=NAME' 399 When creating an ELF executable or shared object, call NAME when 400 the executable or shared object is loaded, by setting DT_INIT to 401 the address of the function. By default, the linker uses '_init' 402 as the function to call. 403 404'-l NAMESPEC' 405'--library=NAMESPEC' 406 Add the archive or object file specified by NAMESPEC to the list of 407 files to link. This option may be used any number of times. If 408 NAMESPEC is of the form ':FILENAME', 'ld' will search the library 409 path for a file called FILENAME, otherwise it will search the 410 library path for a file called 'libNAMESPEC.a'. 411 412 On systems which support shared libraries, 'ld' may also search for 413 files other than 'libNAMESPEC.a'. Specifically, on ELF and SunOS 414 systems, 'ld' will search a directory for a library called 415 'libNAMESPEC.so' before searching for one called 'libNAMESPEC.a'. 416 (By convention, a '.so' extension indicates a shared library.) 417 Note that this behavior does not apply to ':FILENAME', which always 418 specifies a file called FILENAME. 419 420 The linker will search an archive only once, at the location where 421 it is specified on the command line. If the archive defines a 422 symbol which was undefined in some object which appeared before the 423 archive on the command line, the linker will include the 424 appropriate file(s) from the archive. However, an undefined symbol 425 in an object appearing later on the command line will not cause the 426 linker to search the archive again. 427 428 See the '-(' option for a way to force the linker to search 429 archives multiple times. 430 431 You may list the same archive multiple times on the command line. 432 433 This type of archive searching is standard for Unix linkers. 434 However, if you are using 'ld' on AIX, note that it is different 435 from the behaviour of the AIX linker. 436 437'-L SEARCHDIR' 438'--library-path=SEARCHDIR' 439 Add path SEARCHDIR to the list of paths that 'ld' will search for 440 archive libraries and 'ld' control scripts. You may use this 441 option any number of times. The directories are searched in the 442 order in which they are specified on the command line. Directories 443 specified on the command line are searched before the default 444 directories. All '-L' options apply to all '-l' options, 445 regardless of the order in which the options appear. '-L' options 446 do not affect how 'ld' searches for a linker script unless '-T' 447 option is specified. 448 449 If SEARCHDIR begins with '=' or '$SYSROOT', then this prefix will 450 be replaced by the "sysroot prefix", controlled by the '--sysroot' 451 option, or specified when the linker is configured. 452 453 The default set of paths searched (without being specified with 454 '-L') depends on which emulation mode 'ld' is using, and in some 455 cases also on how it was configured. *Note Environment::. 456 457 The paths can also be specified in a link script with the 458 'SEARCH_DIR' command. Directories specified this way are searched 459 at the point in which the linker script appears in the command 460 line. 461 462'-m EMULATION' 463 Emulate the EMULATION linker. You can list the available 464 emulations with the '--verbose' or '-V' options. 465 466 If the '-m' option is not used, the emulation is taken from the 467 'LDEMULATION' environment variable, if that is defined. 468 469 Otherwise, the default emulation depends upon how the linker was 470 configured. 471 472'-M' 473'--print-map' 474 Print a link map to the standard output. A link map provides 475 information about the link, including the following: 476 477 * Where object files are mapped into memory. 478 * How common symbols are allocated. 479 * All archive members included in the link, with a mention of 480 the symbol which caused the archive member to be brought in. 481 * The values assigned to symbols. 482 483 Note - symbols whose values are computed by an expression 484 which involves a reference to a previous value of the same 485 symbol may not have correct result displayed in the link map. 486 This is because the linker discards intermediate results and 487 only retains the final value of an expression. Under such 488 circumstances the linker will display the final value enclosed 489 by square brackets. Thus for example a linker script 490 containing: 491 492 foo = 1 493 foo = foo * 4 494 foo = foo + 8 495 496 will produce the following output in the link map if the '-M' 497 option is used: 498 499 0x00000001 foo = 0x1 500 [0x0000000c] foo = (foo * 0x4) 501 [0x0000000c] foo = (foo + 0x8) 502 503 See *note Expressions:: for more information about expressions 504 in linker scripts. 505 506'-n' 507'--nmagic' 508 Turn off page alignment of sections, and disable linking against 509 shared libraries. If the output format supports Unix style magic 510 numbers, mark the output as 'NMAGIC'. 511 512'-N' 513'--omagic' 514 Set the text and data sections to be readable and writable. Also, 515 do not page-align the data segment, and disable linking against 516 shared libraries. If the output format supports Unix style magic 517 numbers, mark the output as 'OMAGIC'. Note: Although a writable 518 text section is allowed for PE-COFF targets, it does not conform to 519 the format specification published by Microsoft. 520 521'--no-omagic' 522 This option negates most of the effects of the '-N' option. It 523 sets the text section to be read-only, and forces the data segment 524 to be page-aligned. Note - this option does not enable linking 525 against shared libraries. Use '-Bdynamic' for this. 526 527'-o OUTPUT' 528'--output=OUTPUT' 529 Use OUTPUT as the name for the program produced by 'ld'; if this 530 option is not specified, the name 'a.out' is used by default. The 531 script command 'OUTPUT' can also specify the output file name. 532 533'-O LEVEL' 534 If LEVEL is a numeric values greater than zero 'ld' optimizes the 535 output. This might take significantly longer and therefore 536 probably should only be enabled for the final binary. At the 537 moment this option only affects ELF shared library generation. 538 Future releases of the linker may make more use of this option. 539 Also currently there is no difference in the linker's behaviour for 540 different non-zero values of this option. Again this may change 541 with future releases. 542 543'-plugin NAME' 544 Involve a plugin in the linking process. The NAME parameter is the 545 absolute filename of the plugin. Usually this parameter is 546 automatically added by the complier, when using link time 547 optimization, but users can also add their own plugins if they so 548 wish. 549 550 Note that the location of the compiler originated plugins is 551 different from the place where the 'ar', 'nm' and 'ranlib' programs 552 search for their plugins. In order for those commands to make use 553 of a compiler based plugin it must first be copied into the 554 '${libdir}/bfd-plugins' directory. All gcc based linker plugins 555 are backward compatible, so it is sufficient to just copy in the 556 newest one. 557 558'--push-state' 559 The '--push-state' allows to preserve the current state of the 560 flags which govern the input file handling so that they can all be 561 restored with one corresponding '--pop-state' option. 562 563 The option which are covered are: '-Bdynamic', '-Bstatic', '-dn', 564 '-dy', '-call_shared', '-non_shared', '-static', '-N', '-n', 565 '--whole-archive', '--no-whole-archive', '-r', '-Ur', 566 '--copy-dt-needed-entries', '--no-copy-dt-needed-entries', 567 '--as-needed', '--no-as-needed', and '-a'. 568 569 One target for this option are specifications for 'pkg-config'. 570 When used with the '--libs' option all possibly needed libraries 571 are listed and then possibly linked with all the time. It is 572 better to return something as follows: 573 574 -Wl,--push-state,--as-needed -libone -libtwo -Wl,--pop-state 575 576'--pop-state' 577 Undoes the effect of -push-state, restores the previous values of 578 the flags governing input file handling. 579 580'-q' 581'--emit-relocs' 582 Leave relocation sections and contents in fully linked executables. 583 Post link analysis and optimization tools may need this information 584 in order to perform correct modifications of executables. This 585 results in larger executables. 586 587 This option is currently only supported on ELF platforms. 588 589'--force-dynamic' 590 Force the output file to have dynamic sections. This option is 591 specific to VxWorks targets. 592 593'-r' 594'--relocatable' 595 Generate relocatable output--i.e., generate an output file that can 596 in turn serve as input to 'ld'. This is often called "partial 597 linking". As a side effect, in environments that support standard 598 Unix magic numbers, this option also sets the output file's magic 599 number to 'OMAGIC'. If this option is not specified, an absolute 600 file is produced. When linking C++ programs, this option _will 601 not_ resolve references to constructors; to do that, use '-Ur'. 602 603 When an input file does not have the same format as the output 604 file, partial linking is only supported if that input file does not 605 contain any relocations. Different output formats can have further 606 restrictions; for example some 'a.out'-based formats do not support 607 partial linking with input files in other formats at all. 608 609 This option does the same thing as '-i'. 610 611'-R FILENAME' 612'--just-symbols=FILENAME' 613 Read symbol names and their addresses from FILENAME, but do not 614 relocate it or include it in the output. This allows your output 615 file to refer symbolically to absolute locations of memory defined 616 in other programs. You may use this option more than once. 617 618 For compatibility with other ELF linkers, if the '-R' option is 619 followed by a directory name, rather than a file name, it is 620 treated as the '-rpath' option. 621 622'-s' 623'--strip-all' 624 Omit all symbol information from the output file. 625 626'-S' 627'--strip-debug' 628 Omit debugger symbol information (but not all symbols) from the 629 output file. 630 631'--strip-discarded' 632'--no-strip-discarded' 633 Omit (or do not omit) global symbols defined in discarded sections. 634 Enabled by default. 635 636'-t' 637'--trace' 638 Print the names of the input files as 'ld' processes them. 639 640'-T SCRIPTFILE' 641'--script=SCRIPTFILE' 642 Use SCRIPTFILE as the linker script. This script replaces 'ld''s 643 default linker script (rather than adding to it), so COMMANDFILE 644 must specify everything necessary to describe the output file. 645 *Note Scripts::. If SCRIPTFILE does not exist in the current 646 directory, 'ld' looks for it in the directories specified by any 647 preceding '-L' options. Multiple '-T' options accumulate. 648 649'-dT SCRIPTFILE' 650'--default-script=SCRIPTFILE' 651 Use SCRIPTFILE as the default linker script. *Note Scripts::. 652 653 This option is similar to the '--script' option except that 654 processing of the script is delayed until after the rest of the 655 command line has been processed. This allows options placed after 656 the '--default-script' option on the command line to affect the 657 behaviour of the linker script, which can be important when the 658 linker command line cannot be directly controlled by the user. (eg 659 because the command line is being constructed by another tool, such 660 as 'gcc'). 661 662'-u SYMBOL' 663'--undefined=SYMBOL' 664 Force SYMBOL to be entered in the output file as an undefined 665 symbol. Doing this may, for example, trigger linking of additional 666 modules from standard libraries. '-u' may be repeated with 667 different option arguments to enter additional undefined symbols. 668 This option is equivalent to the 'EXTERN' linker script command. 669 670 If this option is being used to force additional modules to be 671 pulled into the link, and if it is an error for the symbol to 672 remain undefined, then the option '--require-defined' should be 673 used instead. 674 675'--require-defined=SYMBOL' 676 Require that SYMBOL is defined in the output file. This option is 677 the same as option '--undefined' except that if SYMBOL is not 678 defined in the output file then the linker will issue an error and 679 exit. The same effect can be achieved in a linker script by using 680 'EXTERN', 'ASSERT' and 'DEFINED' together. This option can be used 681 multiple times to require additional symbols. 682 683'-Ur' 684 For anything other than C++ programs, this option is equivalent to 685 '-r': it generates relocatable output--i.e., an output file that 686 can in turn serve as input to 'ld'. When linking C++ programs, 687 '-Ur' _does_ resolve references to constructors, unlike '-r'. It 688 does not work to use '-Ur' on files that were themselves linked 689 with '-Ur'; once the constructor table has been built, it cannot be 690 added to. Use '-Ur' only for the last partial link, and '-r' for 691 the others. 692 693'--orphan-handling=MODE' 694 Control how orphan sections are handled. An orphan section is one 695 not specifically mentioned in a linker script. *Note Orphan 696 Sections::. 697 698 MODE can have any of the following values: 699 700 'place' 701 Orphan sections are placed into a suitable output section 702 following the strategy described in *note Orphan Sections::. 703 The option '--unique' also affects how sections are placed. 704 705 'discard' 706 All orphan sections are discarded, by placing them in the 707 '/DISCARD/' section (*note Output Section Discarding::). 708 709 'warn' 710 The linker will place the orphan section as for 'place' and 711 also issue a warning. 712 713 'error' 714 The linker will exit with an error if any orphan section is 715 found. 716 717 The default if '--orphan-handling' is not given is 'place'. 718 719'--unique[=SECTION]' 720 Creates a separate output section for every input section matching 721 SECTION, or if the optional wildcard SECTION argument is missing, 722 for every orphan input section. An orphan section is one not 723 specifically mentioned in a linker script. You may use this option 724 multiple times on the command line; It prevents the normal merging 725 of input sections with the same name, overriding output section 726 assignments in a linker script. 727 728'-v' 729'--version' 730'-V' 731 Display the version number for 'ld'. The '-V' option also lists 732 the supported emulations. 733 734'-x' 735'--discard-all' 736 Delete all local symbols. 737 738'-X' 739'--discard-locals' 740 Delete all temporary local symbols. (These symbols start with 741 system-specific local label prefixes, typically '.L' for ELF 742 systems or 'L' for traditional a.out systems.) 743 744'-y SYMBOL' 745'--trace-symbol=SYMBOL' 746 Print the name of each linked file in which SYMBOL appears. This 747 option may be given any number of times. On many systems it is 748 necessary to prepend an underscore. 749 750 This option is useful when you have an undefined symbol in your 751 link but don't know where the reference is coming from. 752 753'-Y PATH' 754 Add PATH to the default library search path. This option exists 755 for Solaris compatibility. 756 757'-z KEYWORD' 758 The recognized keywords are: 759 760 'bndplt' 761 Always generate BND prefix in PLT entries. Supported for 762 Linux/x86_64. 763 764 'call-nop=prefix-addr' 765 'call-nop=suffix-nop' 766 'call-nop=prefix-BYTE' 767 'call-nop=suffix-BYTE' 768 Specify the 1-byte 'NOP' padding when transforming indirect 769 call to a locally defined function, foo, via its GOT slot. 770 'call-nop=prefix-addr' generates '0x67 call foo'. 771 'call-nop=suffix-nop' generates 'call foo 0x90'. 772 'call-nop=prefix-BYTE' generates 'BYTE call foo'. 773 'call-nop=suffix-BYTE' generates 'call foo BYTE'. Supported 774 for i386 and x86_64. 775 776 'combreloc' 777 'nocombreloc' 778 Combine multiple dynamic relocation sections and sort to 779 improve dynamic symbol lookup caching. Do not do this if 780 'nocombreloc'. 781 782 'common' 783 'nocommon' 784 Generate common symbols with STT_COMMON type during a 785 relocatable link. Use STT_OBJECT type if 'nocommon'. 786 787 'common-page-size=VALUE' 788 Set the page size most commonly used to VALUE. Memory image 789 layout will be optimized to minimize memory pages if the 790 system is using pages of this size. 791 792 'defs' 793 Report unresolved symbol references from regular object files. 794 This is done even if the linker is creating a non-symbolic 795 shared library. This option is the inverse of '-z undefs'. 796 797 'dynamic-undefined-weak' 798 'nodynamic-undefined-weak' 799 Make undefined weak symbols dynamic when building a dynamic 800 object, if they are referenced from a regular object file and 801 not forced local by symbol visibility or versioning. Do not 802 make them dynamic if 'nodynamic-undefined-weak'. If neither 803 option is given, a target may default to either option being 804 in force, or make some other selection of undefined weak 805 symbols dynamic. Not all targets support these options. 806 807 'execstack' 808 Marks the object as requiring executable stack. 809 810 'global' 811 This option is only meaningful when building a shared object. 812 It makes the symbols defined by this shared object available 813 for symbol resolution of subsequently loaded libraries. 814 815 'globalaudit' 816 This option is only meaningful when building a dynamic 817 executable. This option marks the executable as requiring 818 global auditing by setting the 'DF_1_GLOBAUDIT' bit in the 819 'DT_FLAGS_1' dynamic tag. Global auditing requires that any 820 auditing library defined via the '--depaudit' or '-P' command 821 line options be run for all dynamic objects loaded by the 822 application. 823 824 'ibtplt' 825 Generate Intel Indirect Branch Tracking (IBT) enabled PLT 826 entries. Supported for Linux/i386 and Linux/x86_64. 827 828 'ibt' 829 Generate GNU_PROPERTY_X86_FEATURE_1_IBT in .note.gnu.property 830 section to indicate compatibility with IBT. This also implies 831 'ibtplt'. Supported for Linux/i386 and Linux/x86_64. 832 833 'initfirst' 834 This option is only meaningful when building a shared object. 835 It marks the object so that its runtime initialization will 836 occur before the runtime initialization of any other objects 837 brought into the process at the same time. Similarly the 838 runtime finalization of the object will occur after the 839 runtime finalization of any other objects. 840 841 'interpose' 842 Specify that the dynamic loader should modify its symbol 843 search order so that symbols in this shared library interpose 844 all other shared libraries not so marked. 845 846 'lazy' 847 When generating an executable or shared library, mark it to 848 tell the dynamic linker to defer function call resolution to 849 the point when the function is called (lazy binding), rather 850 than at load time. Lazy binding is the default. 851 852 'loadfltr' 853 Specify that the object's filters be processed immediately at 854 runtime. 855 856 'max-page-size=VALUE' 857 Set the maximum memory page size supported to VALUE. 858 859 'muldefs' 860 Allow multiple definitions. 861 862 'nocopyreloc' 863 Disable linker generated .dynbss variables used in place of 864 variables defined in shared libraries. May result in dynamic 865 text relocations. 866 867 'nodefaultlib' 868 Specify that the dynamic loader search for dependencies of 869 this object should ignore any default library search paths. 870 871 'nodelete' 872 Specify that the object shouldn't be unloaded at runtime. 873 874 'nodlopen' 875 Specify that the object is not available to 'dlopen'. 876 877 'nodump' 878 Specify that the object can not be dumped by 'dldump'. 879 880 'noexecstack' 881 Marks the object as not requiring executable stack. 882 883 'noextern-protected-data' 884 Don't treat protected data symbols as external when building a 885 shared library. This option overrides the linker backend 886 default. It can be used to work around incorrect relocations 887 against protected data symbols generated by compiler. Updates 888 on protected data symbols by another module aren't visible to 889 the resulting shared library. Supported for i386 and x86-64. 890 891 'noreloc-overflow' 892 Disable relocation overflow check. This can be used to 893 disable relocation overflow check if there will be no dynamic 894 relocation overflow at run-time. Supported for x86_64. 895 896 'now' 897 When generating an executable or shared library, mark it to 898 tell the dynamic linker to resolve all symbols when the 899 program is started, or when the shared library is loaded by 900 dlopen, instead of deferring function call resolution to the 901 point when the function is first called. 902 903 'origin' 904 Specify that the object requires '$ORIGIN' handling in paths. 905 906 'relro' 907 'norelro' 908 Create an ELF 'PT_GNU_RELRO' segment header in the object. 909 This specifies a memory segment that should be made read-only 910 after relocation, if supported. Specifying 'common-page-size' 911 smaller than the system page size will render this protection 912 ineffective. Don't create an ELF 'PT_GNU_RELRO' segment if 913 'norelro'. 914 915 'separate-code' 916 'noseparate-code' 917 Create separate code 'PT_LOAD' segment header in the object. 918 This specifies a memory segment that should contain only 919 instructions and must be in wholly disjoint pages from any 920 other data. Don't create separate code 'PT_LOAD' segment if 921 'noseparate-code' is used. 922 923 'shstk' 924 Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK in 925 .note.gnu.property section to indicate compatibility with 926 Intel Shadow Stack. Supported for Linux/i386 and 927 Linux/x86_64. 928 929 'stack-size=VALUE' 930 Specify a stack size for an ELF 'PT_GNU_STACK' segment. 931 Specifying zero will override any default non-zero sized 932 'PT_GNU_STACK' segment creation. 933 934 'text' 935 'notext' 936 'textoff' 937 Report an error if DT_TEXTREL is set, i.e., if the binary has 938 dynamic relocations in read-only sections. Don't report an 939 error if 'notext' or 'textoff'. 940 941 'undefs' 942 Do not report unresolved symbol references from regular object 943 files, either when creating an executable, or when creating a 944 shared library. This option is the inverse of '-z defs'. 945 946 Other keywords are ignored for Solaris compatibility. 947 948'-( ARCHIVES -)' 949'--start-group ARCHIVES --end-group' 950 The ARCHIVES should be a list of archive files. They may be either 951 explicit file names, or '-l' options. 952 953 The specified archives are searched repeatedly until no new 954 undefined references are created. Normally, an archive is searched 955 only once in the order that it is specified on the command line. 956 If a symbol in that archive is needed to resolve an undefined 957 symbol referred to by an object in an archive that appears later on 958 the command line, the linker would not be able to resolve that 959 reference. By grouping the archives, they all be searched 960 repeatedly until all possible references are resolved. 961 962 Using this option has a significant performance cost. It is best 963 to use it only when there are unavoidable circular references 964 between two or more archives. 965 966'--accept-unknown-input-arch' 967'--no-accept-unknown-input-arch' 968 Tells the linker to accept input files whose architecture cannot be 969 recognised. The assumption is that the user knows what they are 970 doing and deliberately wants to link in these unknown input files. 971 This was the default behaviour of the linker, before release 2.14. 972 The default behaviour from release 2.14 onwards is to reject such 973 input files, and so the '--accept-unknown-input-arch' option has 974 been added to restore the old behaviour. 975 976'--as-needed' 977'--no-as-needed' 978 This option affects ELF DT_NEEDED tags for dynamic libraries 979 mentioned on the command line after the '--as-needed' option. 980 Normally the linker will add a DT_NEEDED tag for each dynamic 981 library mentioned on the command line, regardless of whether the 982 library is actually needed or not. '--as-needed' causes a 983 DT_NEEDED tag to only be emitted for a library that _at that point 984 in the link_ satisfies a non-weak undefined symbol reference from a 985 regular object file or, if the library is not found in the 986 DT_NEEDED lists of other needed libraries, a non-weak undefined 987 symbol reference from another needed dynamic library. Object files 988 or libraries appearing on the command line _after_ the library in 989 question do not affect whether the library is seen as needed. This 990 is similar to the rules for extraction of object files from 991 archives. '--no-as-needed' restores the default behaviour. 992 993'--add-needed' 994'--no-add-needed' 995 These two options have been deprecated because of the similarity of 996 their names to the '--as-needed' and '--no-as-needed' options. 997 They have been replaced by '--copy-dt-needed-entries' and 998 '--no-copy-dt-needed-entries'. 999 1000'-assert KEYWORD' 1001 This option is ignored for SunOS compatibility. 1002 1003'-Bdynamic' 1004'-dy' 1005'-call_shared' 1006 Link against dynamic libraries. This is only meaningful on 1007 platforms for which shared libraries are supported. This option is 1008 normally the default on such platforms. The different variants of 1009 this option are for compatibility with various systems. You may 1010 use this option multiple times on the command line: it affects 1011 library searching for '-l' options which follow it. 1012 1013'-Bgroup' 1014 Set the 'DF_1_GROUP' flag in the 'DT_FLAGS_1' entry in the dynamic 1015 section. This causes the runtime linker to handle lookups in this 1016 object and its dependencies to be performed only inside the group. 1017 '--unresolved-symbols=report-all' is implied. This option is only 1018 meaningful on ELF platforms which support shared libraries. 1019 1020'-Bstatic' 1021'-dn' 1022'-non_shared' 1023'-static' 1024 Do not link against shared libraries. This is only meaningful on 1025 platforms for which shared libraries are supported. The different 1026 variants of this option are for compatibility with various systems. 1027 You may use this option multiple times on the command line: it 1028 affects library searching for '-l' options which follow it. This 1029 option also implies '--unresolved-symbols=report-all'. This option 1030 can be used with '-shared'. Doing so means that a shared library 1031 is being created but that all of the library's external references 1032 must be resolved by pulling in entries from static libraries. 1033 1034'-Bsymbolic' 1035 When creating a shared library, bind references to global symbols 1036 to the definition within the shared library, if any. Normally, it 1037 is possible for a program linked against a shared library to 1038 override the definition within the shared library. This option can 1039 also be used with the '--export-dynamic' option, when creating a 1040 position independent executable, to bind references to global 1041 symbols to the definition within the executable. This option is 1042 only meaningful on ELF platforms which support shared libraries and 1043 position independent executables. 1044 1045'-Bsymbolic-functions' 1046 When creating a shared library, bind references to global function 1047 symbols to the definition within the shared library, if any. This 1048 option can also be used with the '--export-dynamic' option, when 1049 creating a position independent executable, to bind references to 1050 global function symbols to the definition within the executable. 1051 This option is only meaningful on ELF platforms which support 1052 shared libraries and position independent executables. 1053 1054'--dynamic-list=DYNAMIC-LIST-FILE' 1055 Specify the name of a dynamic list file to the linker. This is 1056 typically used when creating shared libraries to specify a list of 1057 global symbols whose references shouldn't be bound to the 1058 definition within the shared library, or creating dynamically 1059 linked executables to specify a list of symbols which should be 1060 added to the symbol table in the executable. This option is only 1061 meaningful on ELF platforms which support shared libraries. 1062 1063 The format of the dynamic list is the same as the version node 1064 without scope and node name. See *note VERSION:: for more 1065 information. 1066 1067'--dynamic-list-data' 1068 Include all global data symbols to the dynamic list. 1069 1070'--dynamic-list-cpp-new' 1071 Provide the builtin dynamic list for C++ operator new and delete. 1072 It is mainly useful for building shared libstdc++. 1073 1074'--dynamic-list-cpp-typeinfo' 1075 Provide the builtin dynamic list for C++ runtime type 1076 identification. 1077 1078'--check-sections' 1079'--no-check-sections' 1080 Asks the linker _not_ to check section addresses after they have 1081 been assigned to see if there are any overlaps. Normally the 1082 linker will perform this check, and if it finds any overlaps it 1083 will produce suitable error messages. The linker does know about, 1084 and does make allowances for sections in overlays. The default 1085 behaviour can be restored by using the command line switch 1086 '--check-sections'. Section overlap is not usually checked for 1087 relocatable links. You can force checking in that case by using 1088 the '--check-sections' option. 1089 1090'--copy-dt-needed-entries' 1091'--no-copy-dt-needed-entries' 1092 This option affects the treatment of dynamic libraries referred to 1093 by DT_NEEDED tags _inside_ ELF dynamic libraries mentioned on the 1094 command line. Normally the linker won't add a DT_NEEDED tag to the 1095 output binary for each library mentioned in a DT_NEEDED tag in an 1096 input dynamic library. With '--copy-dt-needed-entries' specified 1097 on the command line however any dynamic libraries that follow it 1098 will have their DT_NEEDED entries added. The default behaviour can 1099 be restored with '--no-copy-dt-needed-entries'. 1100 1101 This option also has an effect on the resolution of symbols in 1102 dynamic libraries. With '--copy-dt-needed-entries' dynamic 1103 libraries mentioned on the command line will be recursively 1104 searched, following their DT_NEEDED tags to other libraries, in 1105 order to resolve symbols required by the output binary. With the 1106 default setting however the searching of dynamic libraries that 1107 follow it will stop with the dynamic library itself. No DT_NEEDED 1108 links will be traversed to resolve symbols. 1109 1110'--cref' 1111 Output a cross reference table. If a linker map file is being 1112 generated, the cross reference table is printed to the map file. 1113 Otherwise, it is printed on the standard output. 1114 1115 The format of the table is intentionally simple, so that it may be 1116 easily processed by a script if necessary. The symbols are printed 1117 out, sorted by name. For each symbol, a list of file names is 1118 given. If the symbol is defined, the first file listed is the 1119 location of the definition. If the symbol is defined as a common 1120 value then any files where this happens appear next. Finally any 1121 files that reference the symbol are listed. 1122 1123'--no-define-common' 1124 This option inhibits the assignment of addresses to common symbols. 1125 The script command 'INHIBIT_COMMON_ALLOCATION' has the same effect. 1126 *Note Miscellaneous Commands::. 1127 1128 The '--no-define-common' option allows decoupling the decision to 1129 assign addresses to Common symbols from the choice of the output 1130 file type; otherwise a non-Relocatable output type forces assigning 1131 addresses to Common symbols. Using '--no-define-common' allows 1132 Common symbols that are referenced from a shared library to be 1133 assigned addresses only in the main program. This eliminates the 1134 unused duplicate space in the shared library, and also prevents any 1135 possible confusion over resolving to the wrong duplicate when there 1136 are many dynamic modules with specialized search paths for runtime 1137 symbol resolution. 1138 1139'--force-group-allocation' 1140 This option causes the linker to place section group members like 1141 normal input sections, and to delete the section groups. This is 1142 the default behaviour for a final link but this option can be used 1143 to change the behaviour of a relocatable link ('-r'). The script 1144 command 'FORCE_GROUP_ALLOCATION' has the same effect. *Note 1145 Miscellaneous Commands::. 1146 1147'--defsym=SYMBOL=EXPRESSION' 1148 Create a global symbol in the output file, containing the absolute 1149 address given by EXPRESSION. You may use this option as many times 1150 as necessary to define multiple symbols in the command line. A 1151 limited form of arithmetic is supported for the EXPRESSION in this 1152 context: you may give a hexadecimal constant or the name of an 1153 existing symbol, or use '+' and '-' to add or subtract hexadecimal 1154 constants or symbols. If you need more elaborate expressions, 1155 consider using the linker command language from a script (*note 1156 Assignments::). _Note:_ there should be no white space between 1157 SYMBOL, the equals sign ("<=>"), and EXPRESSION. 1158 1159'--demangle[=STYLE]' 1160'--no-demangle' 1161 These options control whether to demangle symbol names in error 1162 messages and other output. When the linker is told to demangle, it 1163 tries to present symbol names in a readable fashion: it strips 1164 leading underscores if they are used by the object file format, and 1165 converts C++ mangled symbol names into user readable names. 1166 Different compilers have different mangling styles. The optional 1167 demangling style argument can be used to choose an appropriate 1168 demangling style for your compiler. The linker will demangle by 1169 default unless the environment variable 'COLLECT_NO_DEMANGLE' is 1170 set. These options may be used to override the default. 1171 1172'-IFILE' 1173'--dynamic-linker=FILE' 1174 Set the name of the dynamic linker. This is only meaningful when 1175 generating dynamically linked ELF executables. The default dynamic 1176 linker is normally correct; don't use this unless you know what you 1177 are doing. 1178 1179'--no-dynamic-linker' 1180 When producing an executable file, omit the request for a dynamic 1181 linker to be used at load-time. This is only meaningful for ELF 1182 executables that contain dynamic relocations, and usually requires 1183 entry point code that is capable of processing these relocations. 1184 1185'--embedded-relocs' 1186 This option is similar to the '--emit-relocs' option except that 1187 the relocs are stored in a target specific section. This option is 1188 only supported by the 'BFIN', 'CR16' and _M68K_ targets. 1189 1190'--disable-multiple-abs-defs' 1191 Do not allow multiple definitions with symbols included in filename 1192 invoked by -R or -just-symbols 1193 1194'--fatal-warnings' 1195'--no-fatal-warnings' 1196 Treat all warnings as errors. The default behaviour can be 1197 restored with the option '--no-fatal-warnings'. 1198 1199'--force-exe-suffix' 1200 Make sure that an output file has a .exe suffix. 1201 1202 If a successfully built fully linked output file does not have a 1203 '.exe' or '.dll' suffix, this option forces the linker to copy the 1204 output file to one of the same name with a '.exe' suffix. This 1205 option is useful when using unmodified Unix makefiles on a 1206 Microsoft Windows host, since some versions of Windows won't run an 1207 image unless it ends in a '.exe' suffix. 1208 1209'--gc-sections' 1210'--no-gc-sections' 1211 Enable garbage collection of unused input sections. It is ignored 1212 on targets that do not support this option. The default behaviour 1213 (of not performing this garbage collection) can be restored by 1214 specifying '--no-gc-sections' on the command line. Note that 1215 garbage collection for COFF and PE format targets is supported, but 1216 the implementation is currently considered to be experimental. 1217 1218 '--gc-sections' decides which input sections are used by examining 1219 symbols and relocations. The section containing the entry symbol 1220 and all sections containing symbols undefined on the command-line 1221 will be kept, as will sections containing symbols referenced by 1222 dynamic objects. Note that when building shared libraries, the 1223 linker must assume that any visible symbol is referenced. Once 1224 this initial set of sections has been determined, the linker 1225 recursively marks as used any section referenced by their 1226 relocations. See '--entry' and '--undefined'. 1227 1228 This option can be set when doing a partial link (enabled with 1229 option '-r'). In this case the root of symbols kept must be 1230 explicitly specified either by an '--entry' or '--undefined' option 1231 or by a 'ENTRY' command in the linker script. 1232 1233'--print-gc-sections' 1234'--no-print-gc-sections' 1235 List all sections removed by garbage collection. The listing is 1236 printed on stderr. This option is only effective if garbage 1237 collection has been enabled via the '--gc-sections') option. The 1238 default behaviour (of not listing the sections that are removed) 1239 can be restored by specifying '--no-print-gc-sections' on the 1240 command line. 1241 1242'--gc-keep-exported' 1243 When '--gc-sections' is enabled, this option prevents garbage 1244 collection of unused input sections that contain global symbols 1245 having default or protected visibility. This option is intended to 1246 be used for executables where unreferenced sections would otherwise 1247 be garbage collected regardless of the external visibility of 1248 contained symbols. Note that this option has no effect when 1249 linking shared objects since it is already the default behaviour. 1250 This option is only supported for ELF format targets. 1251 1252'--print-output-format' 1253 Print the name of the default output format (perhaps influenced by 1254 other command-line options). This is the string that would appear 1255 in an 'OUTPUT_FORMAT' linker script command (*note File 1256 Commands::). 1257 1258'--print-memory-usage' 1259 Print used size, total size and used size of memory regions created 1260 with the *note MEMORY:: command. This is useful on embedded 1261 targets to have a quick view of amount of free memory. The format 1262 of the output has one headline and one line per region. It is both 1263 human readable and easily parsable by tools. Here is an example of 1264 an output: 1265 1266 Memory region Used Size Region Size %age Used 1267 ROM: 256 KB 1 MB 25.00% 1268 RAM: 32 B 2 GB 0.00% 1269 1270'--help' 1271 Print a summary of the command-line options on the standard output 1272 and exit. 1273 1274'--target-help' 1275 Print a summary of all target specific options on the standard 1276 output and exit. 1277 1278'-Map=MAPFILE' 1279 Print a link map to the file MAPFILE. See the description of the 1280 '-M' option, above. 1281 1282'--no-keep-memory' 1283 'ld' normally optimizes for speed over memory usage by caching the 1284 symbol tables of input files in memory. This option tells 'ld' to 1285 instead optimize for memory usage, by rereading the symbol tables 1286 as necessary. This may be required if 'ld' runs out of memory 1287 space while linking a large executable. 1288 1289'--no-undefined' 1290'-z defs' 1291 Report unresolved symbol references from regular object files. 1292 This is done even if the linker is creating a non-symbolic shared 1293 library. The switch '--[no-]allow-shlib-undefined' controls the 1294 behaviour for reporting unresolved references found in shared 1295 libraries being linked in. 1296 1297 The effects of this option can be reverted by using '-z undefs'. 1298 1299'--allow-multiple-definition' 1300'-z muldefs' 1301 Normally when a symbol is defined multiple times, the linker will 1302 report a fatal error. These options allow multiple definitions and 1303 the first definition will be used. 1304 1305'--allow-shlib-undefined' 1306'--no-allow-shlib-undefined' 1307 Allows or disallows undefined symbols in shared libraries. This 1308 switch is similar to '--no-undefined' except that it determines the 1309 behaviour when the undefined symbols are in a shared library rather 1310 than a regular object file. It does not affect how undefined 1311 symbols in regular object files are handled. 1312 1313 The default behaviour is to report errors for any undefined symbols 1314 referenced in shared libraries if the linker is being used to 1315 create an executable, but to allow them if the linker is being used 1316 to create a shared library. 1317 1318 The reasons for allowing undefined symbol references in shared 1319 libraries specified at link time are that: 1320 1321 * A shared library specified at link time may not be the same as 1322 the one that is available at load time, so the symbol might 1323 actually be resolvable at load time. 1324 * There are some operating systems, eg BeOS and HPPA, where 1325 undefined symbols in shared libraries are normal. 1326 1327 The BeOS kernel for example patches shared libraries at load 1328 time to select whichever function is most appropriate for the 1329 current architecture. This is used, for example, to 1330 dynamically select an appropriate memset function. 1331 1332'--no-undefined-version' 1333 Normally when a symbol has an undefined version, the linker will 1334 ignore it. This option disallows symbols with undefined version 1335 and a fatal error will be issued instead. 1336 1337'--default-symver' 1338 Create and use a default symbol version (the soname) for 1339 unversioned exported symbols. 1340 1341'--default-imported-symver' 1342 Create and use a default symbol version (the soname) for 1343 unversioned imported symbols. 1344 1345'--no-warn-mismatch' 1346 Normally 'ld' will give an error if you try to link together input 1347 files that are mismatched for some reason, perhaps because they 1348 have been compiled for different processors or for different 1349 endiannesses. This option tells 'ld' that it should silently 1350 permit such possible errors. This option should only be used with 1351 care, in cases when you have taken some special action that ensures 1352 that the linker errors are inappropriate. 1353 1354'--no-warn-search-mismatch' 1355 Normally 'ld' will give a warning if it finds an incompatible 1356 library during a library search. This option silences the warning. 1357 1358'--no-whole-archive' 1359 Turn off the effect of the '--whole-archive' option for subsequent 1360 archive files. 1361 1362'--noinhibit-exec' 1363 Retain the executable output file whenever it is still usable. 1364 Normally, the linker will not produce an output file if it 1365 encounters errors during the link process; it exits without writing 1366 an output file when it issues any error whatsoever. 1367 1368'-nostdlib' 1369 Only search library directories explicitly specified on the command 1370 line. Library directories specified in linker scripts (including 1371 linker scripts specified on the command line) are ignored. 1372 1373'--oformat=OUTPUT-FORMAT' 1374 'ld' may be configured to support more than one kind of object 1375 file. If your 'ld' is configured this way, you can use the 1376 '--oformat' option to specify the binary format for the output 1377 object file. Even when 'ld' is configured to support alternative 1378 object formats, you don't usually need to specify this, as 'ld' 1379 should be configured to produce as a default output format the most 1380 usual format on each machine. OUTPUT-FORMAT is a text string, the 1381 name of a particular format supported by the BFD libraries. (You 1382 can list the available binary formats with 'objdump -i'.) The 1383 script command 'OUTPUT_FORMAT' can also specify the output format, 1384 but this option overrides it. *Note BFD::. 1385 1386'--out-implib FILE' 1387 Create an import library in FILE corresponding to the executable 1388 the linker is generating (eg. a DLL or ELF program). This import 1389 library (which should be called '*.dll.a' or '*.a' for DLLs) may be 1390 used to link clients against the generated executable; this 1391 behaviour makes it possible to skip a separate import library 1392 creation step (eg. 'dlltool' for DLLs). This option is only 1393 available for the i386 PE and ELF targetted ports of the linker. 1394 1395'-pie' 1396'--pic-executable' 1397 Create a position independent executable. This is currently only 1398 supported on ELF platforms. Position independent executables are 1399 similar to shared libraries in that they are relocated by the 1400 dynamic linker to the virtual address the OS chooses for them 1401 (which can vary between invocations). Like normal dynamically 1402 linked executables they can be executed and symbols defined in the 1403 executable cannot be overridden by shared libraries. 1404 1405'-qmagic' 1406 This option is ignored for Linux compatibility. 1407 1408'-Qy' 1409 This option is ignored for SVR4 compatibility. 1410 1411'--relax' 1412'--no-relax' 1413 An option with machine dependent effects. This option is only 1414 supported on a few targets. *Note 'ld' and the H8/300: H8/300. 1415 *Note 'ld' and Xtensa Processors: Xtensa. *Note 'ld' and the 1416 68HC11 and 68HC12: M68HC11/68HC12. *Note 'ld' and the Altera Nios 1417 II: Nios II. *Note 'ld' and PowerPC 32-bit ELF Support: PowerPC 1418 ELF32. 1419 1420 On some platforms the '--relax' option performs target specific, 1421 global optimizations that become possible when the linker resolves 1422 addressing in the program, such as relaxing address modes, 1423 synthesizing new instructions, selecting shorter version of current 1424 instructions, and combining constant values. 1425 1426 On some platforms these link time global optimizations may make 1427 symbolic debugging of the resulting executable impossible. This is 1428 known to be the case for the Matsushita MN10200 and MN10300 family 1429 of processors. 1430 1431 On platforms where this is not supported, '--relax' is accepted, 1432 but ignored. 1433 1434 On platforms where '--relax' is accepted the option '--no-relax' 1435 can be used to disable the feature. 1436 1437'--retain-symbols-file=FILENAME' 1438 Retain _only_ the symbols listed in the file FILENAME, discarding 1439 all others. FILENAME is simply a flat file, with one symbol name 1440 per line. This option is especially useful in environments (such 1441 as VxWorks) where a large global symbol table is accumulated 1442 gradually, to conserve run-time memory. 1443 1444 '--retain-symbols-file' does _not_ discard undefined symbols, or 1445 symbols needed for relocations. 1446 1447 You may only specify '--retain-symbols-file' once in the command 1448 line. It overrides '-s' and '-S'. 1449 1450'-rpath=DIR' 1451 Add a directory to the runtime library search path. This is used 1452 when linking an ELF executable with shared objects. All '-rpath' 1453 arguments are concatenated and passed to the runtime linker, which 1454 uses them to locate shared objects at runtime. The '-rpath' option 1455 is also used when locating shared objects which are needed by 1456 shared objects explicitly included in the link; see the description 1457 of the '-rpath-link' option. If '-rpath' is not used when linking 1458 an ELF executable, the contents of the environment variable 1459 'LD_RUN_PATH' will be used if it is defined. 1460 1461 The '-rpath' option may also be used on SunOS. By default, on 1462 SunOS, the linker will form a runtime search path out of all the 1463 '-L' options it is given. If a '-rpath' option is used, the 1464 runtime search path will be formed exclusively using the '-rpath' 1465 options, ignoring the '-L' options. This can be useful when using 1466 gcc, which adds many '-L' options which may be on NFS mounted file 1467 systems. 1468 1469 For compatibility with other ELF linkers, if the '-R' option is 1470 followed by a directory name, rather than a file name, it is 1471 treated as the '-rpath' option. 1472 1473'-rpath-link=DIR' 1474 When using ELF or SunOS, one shared library may require another. 1475 This happens when an 'ld -shared' link includes a shared library as 1476 one of the input files. 1477 1478 When the linker encounters such a dependency when doing a 1479 non-shared, non-relocatable link, it will automatically try to 1480 locate the required shared library and include it in the link, if 1481 it is not included explicitly. In such a case, the '-rpath-link' 1482 option specifies the first set of directories to search. The 1483 '-rpath-link' option may specify a sequence of directory names 1484 either by specifying a list of names separated by colons, or by 1485 appearing multiple times. 1486 1487 The tokens $ORIGIN and $LIB can appear in these search directories. 1488 They will be replaced by the full path to the directory containing 1489 the program or shared object in the case of $ORIGIN and either 1490 'lib' - for 32-bit binaries - or 'lib64' - for 64-bit binaries - in 1491 the case of $LIB. 1492 1493 The alternative form of these tokens - ${ORIGIN} and ${LIB} can 1494 also be used. The token $PLATFORM is not supported. 1495 1496 This option should be used with caution as it overrides the search 1497 path that may have been hard compiled into a shared library. In 1498 such a case it is possible to use unintentionally a different 1499 search path than the runtime linker would do. 1500 1501 The linker uses the following search paths to locate required 1502 shared libraries: 1503 1. Any directories specified by '-rpath-link' options. 1504 2. Any directories specified by '-rpath' options. The difference 1505 between '-rpath' and '-rpath-link' is that directories 1506 specified by '-rpath' options are included in the executable 1507 and used at runtime, whereas the '-rpath-link' option is only 1508 effective at link time. Searching '-rpath' in this way is 1509 only supported by native linkers and cross linkers which have 1510 been configured with the '--with-sysroot' option. 1511 3. On an ELF system, for native linkers, if the '-rpath' and 1512 '-rpath-link' options were not used, search the contents of 1513 the environment variable 'LD_RUN_PATH'. 1514 4. On SunOS, if the '-rpath' option was not used, search any 1515 directories specified using '-L' options. 1516 5. For a native linker, search the contents of the environment 1517 variable 'LD_LIBRARY_PATH'. 1518 6. For a native ELF linker, the directories in 'DT_RUNPATH' or 1519 'DT_RPATH' of a shared library are searched for shared 1520 libraries needed by it. The 'DT_RPATH' entries are ignored if 1521 'DT_RUNPATH' entries exist. 1522 7. The default directories, normally '/lib' and '/usr/lib'. 1523 8. For a native linker on an ELF system, if the file 1524 '/etc/ld.so.conf' exists, the list of directories found in 1525 that file. 1526 1527 If the required shared library is not found, the linker will issue 1528 a warning and continue with the link. 1529 1530'-shared' 1531'-Bshareable' 1532 Create a shared library. This is currently only supported on ELF, 1533 XCOFF and SunOS platforms. On SunOS, the linker will automatically 1534 create a shared library if the '-e' option is not used and there 1535 are undefined symbols in the link. 1536 1537'--sort-common' 1538'--sort-common=ascending' 1539'--sort-common=descending' 1540 This option tells 'ld' to sort the common symbols by alignment in 1541 ascending or descending order when it places them in the 1542 appropriate output sections. The symbol alignments considered are 1543 sixteen-byte or larger, eight-byte, four-byte, two-byte, and 1544 one-byte. This is to prevent gaps between symbols due to alignment 1545 constraints. If no sorting order is specified, then descending 1546 order is assumed. 1547 1548'--sort-section=name' 1549 This option will apply 'SORT_BY_NAME' to all wildcard section 1550 patterns in the linker script. 1551 1552'--sort-section=alignment' 1553 This option will apply 'SORT_BY_ALIGNMENT' to all wildcard section 1554 patterns in the linker script. 1555 1556'--spare-dynamic-tags=COUNT' 1557 This option specifies the number of empty slots to leave in the 1558 .dynamic section of ELF shared objects. Empty slots may be needed 1559 by post processing tools, such as the prelinker. The default is 5. 1560 1561'--split-by-file[=SIZE]' 1562 Similar to '--split-by-reloc' but creates a new output section for 1563 each input file when SIZE is reached. SIZE defaults to a size of 1 1564 if not given. 1565 1566'--split-by-reloc[=COUNT]' 1567 Tries to creates extra sections in the output file so that no 1568 single output section in the file contains more than COUNT 1569 relocations. This is useful when generating huge relocatable files 1570 for downloading into certain real time kernels with the COFF object 1571 file format; since COFF cannot represent more than 65535 1572 relocations in a single section. Note that this will fail to work 1573 with object file formats which do not support arbitrary sections. 1574 The linker will not split up individual input sections for 1575 redistribution, so if a single input section contains more than 1576 COUNT relocations one output section will contain that many 1577 relocations. COUNT defaults to a value of 32768. 1578 1579'--stats' 1580 Compute and display statistics about the operation of the linker, 1581 such as execution time and memory usage. 1582 1583'--sysroot=DIRECTORY' 1584 Use DIRECTORY as the location of the sysroot, overriding the 1585 configure-time default. This option is only supported by linkers 1586 that were configured using '--with-sysroot'. 1587 1588'--task-link' 1589 This is used by COFF/PE based targets to create a task-linked 1590 object file where all of the global symbols have been converted to 1591 statics. 1592 1593'--traditional-format' 1594 For some targets, the output of 'ld' is different in some ways from 1595 the output of some existing linker. This switch requests 'ld' to 1596 use the traditional format instead. 1597 1598 For example, on SunOS, 'ld' combines duplicate entries in the 1599 symbol string table. This can reduce the size of an output file 1600 with full debugging information by over 30 percent. Unfortunately, 1601 the SunOS 'dbx' program can not read the resulting program ('gdb' 1602 has no trouble). The '--traditional-format' switch tells 'ld' to 1603 not combine duplicate entries. 1604 1605'--section-start=SECTIONNAME=ORG' 1606 Locate a section in the output file at the absolute address given 1607 by ORG. You may use this option as many times as necessary to 1608 locate multiple sections in the command line. ORG must be a single 1609 hexadecimal integer; for compatibility with other linkers, you may 1610 omit the leading '0x' usually associated with hexadecimal values. 1611 _Note:_ there should be no white space between SECTIONNAME, the 1612 equals sign ("<=>"), and ORG. 1613 1614'-Tbss=ORG' 1615'-Tdata=ORG' 1616'-Ttext=ORG' 1617 Same as '--section-start', with '.bss', '.data' or '.text' as the 1618 SECTIONNAME. 1619 1620'-Ttext-segment=ORG' 1621 When creating an ELF executable, it will set the address of the 1622 first byte of the text segment. 1623 1624'-Trodata-segment=ORG' 1625 When creating an ELF executable or shared object for a target where 1626 the read-only data is in its own segment separate from the 1627 executable text, it will set the address of the first byte of the 1628 read-only data segment. 1629 1630'-Tldata-segment=ORG' 1631 When creating an ELF executable or shared object for x86-64 medium 1632 memory model, it will set the address of the first byte of the 1633 ldata segment. 1634 1635'--unresolved-symbols=METHOD' 1636 Determine how to handle unresolved symbols. There are four 1637 possible values for 'method': 1638 1639 'ignore-all' 1640 Do not report any unresolved symbols. 1641 1642 'report-all' 1643 Report all unresolved symbols. This is the default. 1644 1645 'ignore-in-object-files' 1646 Report unresolved symbols that are contained in shared 1647 libraries, but ignore them if they come from regular object 1648 files. 1649 1650 'ignore-in-shared-libs' 1651 Report unresolved symbols that come from regular object files, 1652 but ignore them if they come from shared libraries. This can 1653 be useful when creating a dynamic binary and it is known that 1654 all the shared libraries that it should be referencing are 1655 included on the linker's command line. 1656 1657 The behaviour for shared libraries on their own can also be 1658 controlled by the '--[no-]allow-shlib-undefined' option. 1659 1660 Normally the linker will generate an error message for each 1661 reported unresolved symbol but the option 1662 '--warn-unresolved-symbols' can change this to a warning. 1663 1664'--dll-verbose' 1665'--verbose[=NUMBER]' 1666 Display the version number for 'ld' and list the linker emulations 1667 supported. Display which input files can and cannot be opened. 1668 Display the linker script being used by the linker. If the 1669 optional NUMBER argument > 1, plugin symbol status will also be 1670 displayed. 1671 1672'--version-script=VERSION-SCRIPTFILE' 1673 Specify the name of a version script to the linker. This is 1674 typically used when creating shared libraries to specify additional 1675 information about the version hierarchy for the library being 1676 created. This option is only fully supported on ELF platforms 1677 which support shared libraries; see *note VERSION::. It is 1678 partially supported on PE platforms, which can use version scripts 1679 to filter symbol visibility in auto-export mode: any symbols marked 1680 'local' in the version script will not be exported. *Note WIN32::. 1681 1682'--warn-common' 1683 Warn when a common symbol is combined with another common symbol or 1684 with a symbol definition. Unix linkers allow this somewhat sloppy 1685 practice, but linkers on some other operating systems do not. This 1686 option allows you to find potential problems from combining global 1687 symbols. Unfortunately, some C libraries use this practice, so you 1688 may get some warnings about symbols in the libraries as well as in 1689 your programs. 1690 1691 There are three kinds of global symbols, illustrated here by C 1692 examples: 1693 1694 'int i = 1;' 1695 A definition, which goes in the initialized data section of 1696 the output file. 1697 1698 'extern int i;' 1699 An undefined reference, which does not allocate space. There 1700 must be either a definition or a common symbol for the 1701 variable somewhere. 1702 1703 'int i;' 1704 A common symbol. If there are only (one or more) common 1705 symbols for a variable, it goes in the uninitialized data area 1706 of the output file. The linker merges multiple common symbols 1707 for the same variable into a single symbol. If they are of 1708 different sizes, it picks the largest size. The linker turns 1709 a common symbol into a declaration, if there is a definition 1710 of the same variable. 1711 1712 The '--warn-common' option can produce five kinds of warnings. 1713 Each warning consists of a pair of lines: the first describes the 1714 symbol just encountered, and the second describes the previous 1715 symbol encountered with the same name. One or both of the two 1716 symbols will be a common symbol. 1717 1718 1. Turning a common symbol into a reference, because there is 1719 already a definition for the symbol. 1720 FILE(SECTION): warning: common of `SYMBOL' 1721 overridden by definition 1722 FILE(SECTION): warning: defined here 1723 1724 2. Turning a common symbol into a reference, because a later 1725 definition for the symbol is encountered. This is the same as 1726 the previous case, except that the symbols are encountered in 1727 a different order. 1728 FILE(SECTION): warning: definition of `SYMBOL' 1729 overriding common 1730 FILE(SECTION): warning: common is here 1731 1732 3. Merging a common symbol with a previous same-sized common 1733 symbol. 1734 FILE(SECTION): warning: multiple common 1735 of `SYMBOL' 1736 FILE(SECTION): warning: previous common is here 1737 1738 4. Merging a common symbol with a previous larger common symbol. 1739 FILE(SECTION): warning: common of `SYMBOL' 1740 overridden by larger common 1741 FILE(SECTION): warning: larger common is here 1742 1743 5. Merging a common symbol with a previous smaller common symbol. 1744 This is the same as the previous case, except that the symbols 1745 are encountered in a different order. 1746 FILE(SECTION): warning: common of `SYMBOL' 1747 overriding smaller common 1748 FILE(SECTION): warning: smaller common is here 1749 1750'--warn-constructors' 1751 Warn if any global constructors are used. This is only useful for 1752 a few object file formats. For formats like COFF or ELF, the 1753 linker can not detect the use of global constructors. 1754 1755'--warn-multiple-gp' 1756 Warn if multiple global pointer values are required in the output 1757 file. This is only meaningful for certain processors, such as the 1758 Alpha. Specifically, some processors put large-valued constants in 1759 a special section. A special register (the global pointer) points 1760 into the middle of this section, so that constants can be loaded 1761 efficiently via a base-register relative addressing mode. Since 1762 the offset in base-register relative mode is fixed and relatively 1763 small (e.g., 16 bits), this limits the maximum size of the constant 1764 pool. Thus, in large programs, it is often necessary to use 1765 multiple global pointer values in order to be able to address all 1766 possible constants. This option causes a warning to be issued 1767 whenever this case occurs. 1768 1769'--warn-once' 1770 Only warn once for each undefined symbol, rather than once per 1771 module which refers to it. 1772 1773'--warn-section-align' 1774 Warn if the address of an output section is changed because of 1775 alignment. Typically, the alignment will be set by an input 1776 section. The address will only be changed if it not explicitly 1777 specified; that is, if the 'SECTIONS' command does not specify a 1778 start address for the section (*note SECTIONS::). 1779 1780'--warn-shared-textrel' 1781 Warn if the linker adds a DT_TEXTREL to a shared object. 1782 1783'--warn-alternate-em' 1784 Warn if an object has alternate ELF machine code. 1785 1786'--warn-unresolved-symbols' 1787 If the linker is going to report an unresolved symbol (see the 1788 option '--unresolved-symbols') it will normally generate an error. 1789 This option makes it generate a warning instead. 1790 1791'--error-unresolved-symbols' 1792 This restores the linker's default behaviour of generating errors 1793 when it is reporting unresolved symbols. 1794 1795'--whole-archive' 1796 For each archive mentioned on the command line after the 1797 '--whole-archive' option, include every object file in the archive 1798 in the link, rather than searching the archive for the required 1799 object files. This is normally used to turn an archive file into a 1800 shared library, forcing every object to be included in the 1801 resulting shared library. This option may be used more than once. 1802 1803 Two notes when using this option from gcc: First, gcc doesn't know 1804 about this option, so you have to use '-Wl,-whole-archive'. 1805 Second, don't forget to use '-Wl,-no-whole-archive' after your list 1806 of archives, because gcc will add its own list of archives to your 1807 link and you may not want this flag to affect those as well. 1808 1809'--wrap=SYMBOL' 1810 Use a wrapper function for SYMBOL. Any undefined reference to 1811 SYMBOL will be resolved to '__wrap_SYMBOL'. Any undefined 1812 reference to '__real_SYMBOL' will be resolved to SYMBOL. 1813 1814 This can be used to provide a wrapper for a system function. The 1815 wrapper function should be called '__wrap_SYMBOL'. If it wishes to 1816 call the system function, it should call '__real_SYMBOL'. 1817 1818 Here is a trivial example: 1819 1820 void * 1821 __wrap_malloc (size_t c) 1822 { 1823 printf ("malloc called with %zu\n", c); 1824 return __real_malloc (c); 1825 } 1826 1827 If you link other code with this file using '--wrap malloc', then 1828 all calls to 'malloc' will call the function '__wrap_malloc' 1829 instead. The call to '__real_malloc' in '__wrap_malloc' will call 1830 the real 'malloc' function. 1831 1832 You may wish to provide a '__real_malloc' function as well, so that 1833 links without the '--wrap' option will succeed. If you do this, 1834 you should not put the definition of '__real_malloc' in the same 1835 file as '__wrap_malloc'; if you do, the assembler may resolve the 1836 call before the linker has a chance to wrap it to 'malloc'. 1837 1838'--eh-frame-hdr' 1839'--no-eh-frame-hdr' 1840 Request ('--eh-frame-hdr') or suppress ('--no-eh-frame-hdr') the 1841 creation of '.eh_frame_hdr' section and ELF 'PT_GNU_EH_FRAME' 1842 segment header. 1843 1844'--no-ld-generated-unwind-info' 1845 Request creation of '.eh_frame' unwind info for linker generated 1846 code sections like PLT. This option is on by default if linker 1847 generated unwind info is supported. 1848 1849'--enable-new-dtags' 1850'--disable-new-dtags' 1851 This linker can create the new dynamic tags in ELF. But the older 1852 ELF systems may not understand them. If you specify 1853 '--enable-new-dtags', the new dynamic tags will be created as 1854 needed and older dynamic tags will be omitted. If you specify 1855 '--disable-new-dtags', no new dynamic tags will be created. By 1856 default, the new dynamic tags are not created. Note that those 1857 options are only available for ELF systems. 1858 1859'--hash-size=NUMBER' 1860 Set the default size of the linker's hash tables to a prime number 1861 close to NUMBER. Increasing this value can reduce the length of 1862 time it takes the linker to perform its tasks, at the expense of 1863 increasing the linker's memory requirements. Similarly reducing 1864 this value can reduce the memory requirements at the expense of 1865 speed. 1866 1867'--hash-style=STYLE' 1868 Set the type of linker's hash table(s). STYLE can be either 'sysv' 1869 for classic ELF '.hash' section, 'gnu' for new style GNU 1870 '.gnu.hash' section or 'both' for both the classic ELF '.hash' and 1871 new style GNU '.gnu.hash' hash tables. The default is 'sysv'. 1872 1873'--compress-debug-sections=none' 1874'--compress-debug-sections=zlib' 1875'--compress-debug-sections=zlib-gnu' 1876'--compress-debug-sections=zlib-gabi' 1877 On ELF platforms, these options control how DWARF debug sections 1878 are compressed using zlib. 1879 1880 '--compress-debug-sections=none' doesn't compress DWARF debug 1881 sections. '--compress-debug-sections=zlib-gnu' compresses DWARF 1882 debug sections and renames them to begin with '.zdebug' instead of 1883 '.debug'. '--compress-debug-sections=zlib-gabi' also compresses 1884 DWARF debug sections, but rather than renaming them it sets the 1885 SHF_COMPRESSED flag in the sections' headers. 1886 1887 The '--compress-debug-sections=zlib' option is an alias for 1888 '--compress-debug-sections=zlib-gabi'. 1889 1890 Note that this option overrides any compression in input debug 1891 sections, so if a binary is linked with 1892 '--compress-debug-sections=none' for example, then any compressed 1893 debug sections in input files will be uncompressed before they are 1894 copied into the output binary. 1895 1896 The default compression behaviour varies depending upon the target 1897 involved and the configure options used to build the toolchain. 1898 The default can be determined by examining the output from the 1899 linker's '--help' option. 1900 1901'--reduce-memory-overheads' 1902 This option reduces memory requirements at ld runtime, at the 1903 expense of linking speed. This was introduced to select the old 1904 O(n^2) algorithm for link map file generation, rather than the new 1905 O(n) algorithm which uses about 40% more memory for symbol storage. 1906 1907 Another effect of the switch is to set the default hash table size 1908 to 1021, which again saves memory at the cost of lengthening the 1909 linker's run time. This is not done however if the '--hash-size' 1910 switch has been used. 1911 1912 The '--reduce-memory-overheads' switch may be also be used to 1913 enable other tradeoffs in future versions of the linker. 1914 1915'--build-id' 1916'--build-id=STYLE' 1917 Request the creation of a '.note.gnu.build-id' ELF note section or 1918 a '.buildid' COFF section. The contents of the note are unique 1919 bits identifying this linked file. STYLE can be 'uuid' to use 128 1920 random bits, 'sha1' to use a 160-bit SHA1 hash on the normative 1921 parts of the output contents, 'md5' to use a 128-bit MD5 hash on 1922 the normative parts of the output contents, or '0xHEXSTRING' to use 1923 a chosen bit string specified as an even number of hexadecimal 1924 digits ('-' and ':' characters between digit pairs are ignored). 1925 If STYLE is omitted, 'sha1' is used. 1926 1927 The 'md5' and 'sha1' styles produces an identifier that is always 1928 the same in an identical output file, but will be unique among all 1929 nonidentical output files. It is not intended to be compared as a 1930 checksum for the file's contents. A linked file may be changed 1931 later by other tools, but the build ID bit string identifying the 1932 original linked file does not change. 1933 1934 Passing 'none' for STYLE disables the setting from any '--build-id' 1935 options earlier on the command line. 1936 19372.1.1 Options Specific to i386 PE Targets 1938----------------------------------------- 1939 1940The i386 PE linker supports the '-shared' option, which causes the 1941output to be a dynamically linked library (DLL) instead of a normal 1942executable. You should name the output '*.dll' when you use this 1943option. In addition, the linker fully supports the standard '*.def' 1944files, which may be specified on the linker command line like an object 1945file (in fact, it should precede archives it exports symbols from, to 1946ensure that they get linked in, just like a normal object file). 1947 1948 In addition to the options common to all targets, the i386 PE linker 1949support additional command line options that are specific to the i386 PE 1950target. Options that take values may be separated from their values by 1951either a space or an equals sign. 1952 1953'--add-stdcall-alias' 1954 If given, symbols with a stdcall suffix (@NN) will be exported 1955 as-is and also with the suffix stripped. [This option is specific 1956 to the i386 PE targeted port of the linker] 1957 1958'--base-file FILE' 1959 Use FILE as the name of a file in which to save the base addresses 1960 of all the relocations needed for generating DLLs with 'dlltool'. 1961 [This is an i386 PE specific option] 1962 1963'--dll' 1964 Create a DLL instead of a regular executable. You may also use 1965 '-shared' or specify a 'LIBRARY' in a given '.def' file. [This 1966 option is specific to the i386 PE targeted port of the linker] 1967 1968'--enable-long-section-names' 1969'--disable-long-section-names' 1970 The PE variants of the COFF object format add an extension that 1971 permits the use of section names longer than eight characters, the 1972 normal limit for COFF. By default, these names are only allowed in 1973 object files, as fully-linked executable images do not carry the 1974 COFF string table required to support the longer names. As a GNU 1975 extension, it is possible to allow their use in executable images 1976 as well, or to (probably pointlessly!) disallow it in object 1977 files, by using these two options. Executable images generated 1978 with these long section names are slightly non-standard, carrying 1979 as they do a string table, and may generate confusing output when 1980 examined with non-GNU PE-aware tools, such as file viewers and 1981 dumpers. However, GDB relies on the use of PE long section names 1982 to find Dwarf-2 debug information sections in an executable image 1983 at runtime, and so if neither option is specified on the 1984 command-line, 'ld' will enable long section names, overriding the 1985 default and technically correct behaviour, when it finds the 1986 presence of debug information while linking an executable image and 1987 not stripping symbols. [This option is valid for all PE targeted 1988 ports of the linker] 1989 1990'--enable-stdcall-fixup' 1991'--disable-stdcall-fixup' 1992 If the link finds a symbol that it cannot resolve, it will attempt 1993 to do "fuzzy linking" by looking for another defined symbol that 1994 differs only in the format of the symbol name (cdecl vs stdcall) 1995 and will resolve that symbol by linking to the match. For example, 1996 the undefined symbol '_foo' might be linked to the function 1997 '_foo@12', or the undefined symbol '_bar@16' might be linked to the 1998 function '_bar'. When the linker does this, it prints a warning, 1999 since it normally should have failed to link, but sometimes import 2000 libraries generated from third-party dlls may need this feature to 2001 be usable. If you specify '--enable-stdcall-fixup', this feature 2002 is fully enabled and warnings are not printed. If you specify 2003 '--disable-stdcall-fixup', this feature is disabled and such 2004 mismatches are considered to be errors. [This option is specific 2005 to the i386 PE targeted port of the linker] 2006 2007'--leading-underscore' 2008'--no-leading-underscore' 2009 For most targets default symbol-prefix is an underscore and is 2010 defined in target's description. By this option it is possible to 2011 disable/enable the default underscore symbol-prefix. 2012 2013'--export-all-symbols' 2014 If given, all global symbols in the objects used to build a DLL 2015 will be exported by the DLL. Note that this is the default if there 2016 otherwise wouldn't be any exported symbols. When symbols are 2017 explicitly exported via DEF files or implicitly exported via 2018 function attributes, the default is to not export anything else 2019 unless this option is given. Note that the symbols 'DllMain@12', 2020 'DllEntryPoint@0', 'DllMainCRTStartup@12', and 'impure_ptr' will 2021 not be automatically exported. Also, symbols imported from other 2022 DLLs will not be re-exported, nor will symbols specifying the DLL's 2023 internal layout such as those beginning with '_head_' or ending 2024 with '_iname'. In addition, no symbols from 'libgcc', 'libstd++', 2025 'libmingw32', or 'crtX.o' will be exported. Symbols whose names 2026 begin with '__rtti_' or '__builtin_' will not be exported, to help 2027 with C++ DLLs. Finally, there is an extensive list of 2028 cygwin-private symbols that are not exported (obviously, this 2029 applies on when building DLLs for cygwin targets). These 2030 cygwin-excludes are: '_cygwin_dll_entry@12', 2031 '_cygwin_crt0_common@8', '_cygwin_noncygwin_dll_entry@12', 2032 '_fmode', '_impure_ptr', 'cygwin_attach_dll', 'cygwin_premain0', 2033 'cygwin_premain1', 'cygwin_premain2', 'cygwin_premain3', and 2034 'environ'. [This option is specific to the i386 PE targeted port 2035 of the linker] 2036 2037'--exclude-symbols SYMBOL,SYMBOL,...' 2038 Specifies a list of symbols which should not be automatically 2039 exported. The symbol names may be delimited by commas or colons. 2040 [This option is specific to the i386 PE targeted port of the 2041 linker] 2042 2043'--exclude-all-symbols' 2044 Specifies no symbols should be automatically exported. [This 2045 option is specific to the i386 PE targeted port of the linker] 2046 2047'--file-alignment' 2048 Specify the file alignment. Sections in the file will always begin 2049 at file offsets which are multiples of this number. This defaults 2050 to 512. [This option is specific to the i386 PE targeted port of 2051 the linker] 2052 2053'--heap RESERVE' 2054'--heap RESERVE,COMMIT' 2055 Specify the number of bytes of memory to reserve (and optionally 2056 commit) to be used as heap for this program. The default is 1MB 2057 reserved, 4K committed. [This option is specific to the i386 PE 2058 targeted port of the linker] 2059 2060'--image-base VALUE' 2061 Use VALUE as the base address of your program or dll. This is the 2062 lowest memory location that will be used when your program or dll 2063 is loaded. To reduce the need to relocate and improve performance 2064 of your dlls, each should have a unique base address and not 2065 overlap any other dlls. The default is 0x400000 for executables, 2066 and 0x10000000 for dlls. [This option is specific to the i386 PE 2067 targeted port of the linker] 2068 2069'--kill-at' 2070 If given, the stdcall suffixes (@NN) will be stripped from symbols 2071 before they are exported. [This option is specific to the i386 PE 2072 targeted port of the linker] 2073 2074'--large-address-aware' 2075 If given, the appropriate bit in the "Characteristics" field of the 2076 COFF header is set to indicate that this executable supports 2077 virtual addresses greater than 2 gigabytes. This should be used in 2078 conjunction with the /3GB or /USERVA=VALUE megabytes switch in the 2079 "[operating systems]" section of the BOOT.INI. Otherwise, this bit 2080 has no effect. [This option is specific to PE targeted ports of 2081 the linker] 2082 2083'--disable-large-address-aware' 2084 Reverts the effect of a previous '--large-address-aware' option. 2085 This is useful if '--large-address-aware' is always set by the 2086 compiler driver (e.g. Cygwin gcc) and the executable does not 2087 support virtual addresses greater than 2 gigabytes. [This option 2088 is specific to PE targeted ports of the linker] 2089 2090'--major-image-version VALUE' 2091 Sets the major number of the "image version". Defaults to 1. 2092 [This option is specific to the i386 PE targeted port of the 2093 linker] 2094 2095'--major-os-version VALUE' 2096 Sets the major number of the "os version". Defaults to 4. [This 2097 option is specific to the i386 PE targeted port of the linker] 2098 2099'--major-subsystem-version VALUE' 2100 Sets the major number of the "subsystem version". Defaults to 4. 2101 [This option is specific to the i386 PE targeted port of the 2102 linker] 2103 2104'--minor-image-version VALUE' 2105 Sets the minor number of the "image version". Defaults to 0. 2106 [This option is specific to the i386 PE targeted port of the 2107 linker] 2108 2109'--minor-os-version VALUE' 2110 Sets the minor number of the "os version". Defaults to 0. [This 2111 option is specific to the i386 PE targeted port of the linker] 2112 2113'--minor-subsystem-version VALUE' 2114 Sets the minor number of the "subsystem version". Defaults to 0. 2115 [This option is specific to the i386 PE targeted port of the 2116 linker] 2117 2118'--output-def FILE' 2119 The linker will create the file FILE which will contain a DEF file 2120 corresponding to the DLL the linker is generating. This DEF file 2121 (which should be called '*.def') may be used to create an import 2122 library with 'dlltool' or may be used as a reference to 2123 automatically or implicitly exported symbols. [This option is 2124 specific to the i386 PE targeted port of the linker] 2125 2126'--enable-auto-image-base' 2127'--enable-auto-image-base=VALUE' 2128 Automatically choose the image base for DLLs, optionally starting 2129 with base VALUE, unless one is specified using the '--image-base' 2130 argument. By using a hash generated from the dllname to create 2131 unique image bases for each DLL, in-memory collisions and 2132 relocations which can delay program execution are avoided. [This 2133 option is specific to the i386 PE targeted port of the linker] 2134 2135'--disable-auto-image-base' 2136 Do not automatically generate a unique image base. If there is no 2137 user-specified image base ('--image-base') then use the platform 2138 default. [This option is specific to the i386 PE targeted port of 2139 the linker] 2140 2141'--dll-search-prefix STRING' 2142 When linking dynamically to a dll without an import library, search 2143 for '<string><basename>.dll' in preference to 'lib<basename>.dll'. 2144 This behaviour allows easy distinction between DLLs built for the 2145 various "subplatforms": native, cygwin, uwin, pw, etc. For 2146 instance, cygwin DLLs typically use '--dll-search-prefix=cyg'. 2147 [This option is specific to the i386 PE targeted port of the 2148 linker] 2149 2150'--enable-auto-import' 2151 Do sophisticated linking of '_symbol' to '__imp__symbol' for DATA 2152 imports from DLLs, thus making it possible to bypass the dllimport 2153 mechanism on the user side and to reference unmangled symbol names. 2154 [This option is specific to the i386 PE targeted port of the 2155 linker] 2156 2157 The following remarks pertain to the original implementation of the 2158 feature and are obsolete nowadays for Cygwin and MinGW targets. 2159 2160 Note: Use of the 'auto-import' extension will cause the text 2161 section of the image file to be made writable. This does not 2162 conform to the PE-COFF format specification published by Microsoft. 2163 2164 Note - use of the 'auto-import' extension will also cause read only 2165 data which would normally be placed into the .rdata section to be 2166 placed into the .data section instead. This is in order to work 2167 around a problem with consts that is described here: 2168 http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html 2169 2170 Using 'auto-import' generally will 'just work' - but sometimes you 2171 may see this message: 2172 2173 "variable '<var>' can't be auto-imported. Please read the 2174 documentation for ld's '--enable-auto-import' for details." 2175 2176 This message occurs when some (sub)expression accesses an address 2177 ultimately given by the sum of two constants (Win32 import tables 2178 only allow one). Instances where this may occur include accesses 2179 to member fields of struct variables imported from a DLL, as well 2180 as using a constant index into an array variable imported from a 2181 DLL. Any multiword variable (arrays, structs, long long, etc) may 2182 trigger this error condition. However, regardless of the exact 2183 data type of the offending exported variable, ld will always detect 2184 it, issue the warning, and exit. 2185 2186 There are several ways to address this difficulty, regardless of 2187 the data type of the exported variable: 2188 2189 One way is to use -enable-runtime-pseudo-reloc switch. This leaves 2190 the task of adjusting references in your client code for runtime 2191 environment, so this method works only when runtime environment 2192 supports this feature. 2193 2194 A second solution is to force one of the 'constants' to be a 2195 variable - that is, unknown and un-optimizable at compile time. 2196 For arrays, there are two possibilities: a) make the indexee (the 2197 array's address) a variable, or b) make the 'constant' index a 2198 variable. Thus: 2199 2200 extern type extern_array[]; 2201 extern_array[1] --> 2202 { volatile type *t=extern_array; t[1] } 2203 2204 or 2205 2206 extern type extern_array[]; 2207 extern_array[1] --> 2208 { volatile int t=1; extern_array[t] } 2209 2210 For structs (and most other multiword data types) the only option 2211 is to make the struct itself (or the long long, or the ...) 2212 variable: 2213 2214 extern struct s extern_struct; 2215 extern_struct.field --> 2216 { volatile struct s *t=&extern_struct; t->field } 2217 2218 or 2219 2220 extern long long extern_ll; 2221 extern_ll --> 2222 { volatile long long * local_ll=&extern_ll; *local_ll } 2223 2224 A third method of dealing with this difficulty is to abandon 2225 'auto-import' for the offending symbol and mark it with 2226 '__declspec(dllimport)'. However, in practice that requires using 2227 compile-time #defines to indicate whether you are building a DLL, 2228 building client code that will link to the DLL, or merely 2229 building/linking to a static library. In making the choice between 2230 the various methods of resolving the 'direct address with constant 2231 offset' problem, you should consider typical real-world usage: 2232 2233 Original: 2234 --foo.h 2235 extern int arr[]; 2236 --foo.c 2237 #include "foo.h" 2238 void main(int argc, char **argv){ 2239 printf("%d\n",arr[1]); 2240 } 2241 2242 Solution 1: 2243 --foo.h 2244 extern int arr[]; 2245 --foo.c 2246 #include "foo.h" 2247 void main(int argc, char **argv){ 2248 /* This workaround is for win32 and cygwin; do not "optimize" */ 2249 volatile int *parr = arr; 2250 printf("%d\n",parr[1]); 2251 } 2252 2253 Solution 2: 2254 --foo.h 2255 /* Note: auto-export is assumed (no __declspec(dllexport)) */ 2256 #if (defined(_WIN32) || defined(__CYGWIN__)) && \ 2257 !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) 2258 #define FOO_IMPORT __declspec(dllimport) 2259 #else 2260 #define FOO_IMPORT 2261 #endif 2262 extern FOO_IMPORT int arr[]; 2263 --foo.c 2264 #include "foo.h" 2265 void main(int argc, char **argv){ 2266 printf("%d\n",arr[1]); 2267 } 2268 2269 A fourth way to avoid this problem is to re-code your library to 2270 use a functional interface rather than a data interface for the 2271 offending variables (e.g. set_foo() and get_foo() accessor 2272 functions). 2273 2274'--disable-auto-import' 2275 Do not attempt to do sophisticated linking of '_symbol' to 2276 '__imp__symbol' for DATA imports from DLLs. [This option is 2277 specific to the i386 PE targeted port of the linker] 2278 2279'--enable-runtime-pseudo-reloc' 2280 If your code contains expressions described in -enable-auto-import 2281 section, that is, DATA imports from DLL with non-zero offset, this 2282 switch will create a vector of 'runtime pseudo relocations' which 2283 can be used by runtime environment to adjust references to such 2284 data in your client code. [This option is specific to the i386 PE 2285 targeted port of the linker] 2286 2287'--disable-runtime-pseudo-reloc' 2288 Do not create pseudo relocations for non-zero offset DATA imports 2289 from DLLs. [This option is specific to the i386 PE targeted port 2290 of the linker] 2291 2292'--enable-extra-pe-debug' 2293 Show additional debug info related to auto-import symbol thunking. 2294 [This option is specific to the i386 PE targeted port of the 2295 linker] 2296 2297'--section-alignment' 2298 Sets the section alignment. Sections in memory will always begin 2299 at addresses which are a multiple of this number. Defaults to 2300 0x1000. [This option is specific to the i386 PE targeted port of 2301 the linker] 2302 2303'--stack RESERVE' 2304'--stack RESERVE,COMMIT' 2305 Specify the number of bytes of memory to reserve (and optionally 2306 commit) to be used as stack for this program. The default is 2MB 2307 reserved, 4K committed. [This option is specific to the i386 PE 2308 targeted port of the linker] 2309 2310'--subsystem WHICH' 2311'--subsystem WHICH:MAJOR' 2312'--subsystem WHICH:MAJOR.MINOR' 2313 Specifies the subsystem under which your program will execute. The 2314 legal values for WHICH are 'native', 'windows', 'console', 'posix', 2315 and 'xbox'. You may optionally set the subsystem version also. 2316 Numeric values are also accepted for WHICH. [This option is 2317 specific to the i386 PE targeted port of the linker] 2318 2319 The following options set flags in the 'DllCharacteristics' field 2320 of the PE file header: [These options are specific to PE targeted 2321 ports of the linker] 2322 2323'--high-entropy-va' 2324 Image is compatible with 64-bit address space layout randomization 2325 (ASLR). 2326 2327'--dynamicbase' 2328 The image base address may be relocated using address space layout 2329 randomization (ASLR). This feature was introduced with MS Windows 2330 Vista for i386 PE targets. 2331 2332'--forceinteg' 2333 Code integrity checks are enforced. 2334 2335'--nxcompat' 2336 The image is compatible with the Data Execution Prevention. This 2337 feature was introduced with MS Windows XP SP2 for i386 PE targets. 2338 2339'--no-isolation' 2340 Although the image understands isolation, do not isolate the image. 2341 2342'--no-seh' 2343 The image does not use SEH. No SE handler may be called from this 2344 image. 2345 2346'--no-bind' 2347 Do not bind this image. 2348 2349'--wdmdriver' 2350 The driver uses the MS Windows Driver Model. 2351 2352'--tsaware' 2353 The image is Terminal Server aware. 2354 2355'--insert-timestamp' 2356'--no-insert-timestamp' 2357 Insert a real timestamp into the image. This is the default 2358 behaviour as it matches legacy code and it means that the image 2359 will work with other, proprietary tools. The problem with this 2360 default is that it will result in slightly different images being 2361 produced each time the same sources are linked. The option 2362 '--no-insert-timestamp' can be used to insert a zero value for the 2363 timestamp, this ensuring that binaries produced from identical 2364 sources will compare identically. 2365 23662.1.2 Options specific to C6X uClinux targets 2367--------------------------------------------- 2368 2369The C6X uClinux target uses a binary format called DSBT to support 2370shared libraries. Each shared library in the system needs to have a 2371unique index; all executables use an index of 0. 2372 2373'--dsbt-size SIZE' 2374 This option sets the number of entries in the DSBT of the current 2375 executable or shared library to SIZE. The default is to create a 2376 table with 64 entries. 2377 2378'--dsbt-index INDEX' 2379 This option sets the DSBT index of the current executable or shared 2380 library to INDEX. The default is 0, which is appropriate for 2381 generating executables. If a shared library is generated with a 2382 DSBT index of 0, the 'R_C6000_DSBT_INDEX' relocs are copied into 2383 the output file. 2384 2385 The '--no-merge-exidx-entries' switch disables the merging of 2386 adjacent exidx entries in frame unwind info. 2387 23882.1.3 Options specific to Motorola 68HC11 and 68HC12 targets 2389------------------------------------------------------------ 2390 2391The 68HC11 and 68HC12 linkers support specific options to control the 2392memory bank switching mapping and trampoline code generation. 2393 2394'--no-trampoline' 2395 This option disables the generation of trampoline. By default a 2396 trampoline is generated for each far function which is called using 2397 a 'jsr' instruction (this happens when a pointer to a far function 2398 is taken). 2399 2400'--bank-window NAME' 2401 This option indicates to the linker the name of the memory region 2402 in the 'MEMORY' specification that describes the memory bank 2403 window. The definition of such region is then used by the linker 2404 to compute paging and addresses within the memory window. 2405 24062.1.4 Options specific to Motorola 68K target 2407--------------------------------------------- 2408 2409The following options are supported to control handling of GOT 2410generation when linking for 68K targets. 2411 2412'--got=TYPE' 2413 This option tells the linker which GOT generation scheme to use. 2414 TYPE should be one of 'single', 'negative', 'multigot' or 'target'. 2415 For more information refer to the Info entry for 'ld'. 2416 24172.1.5 Options specific to MIPS targets 2418-------------------------------------- 2419 2420The following options are supported to control microMIPS instruction 2421generation and branch relocation checks for ISA mode transitions when 2422linking for MIPS targets. 2423 2424'--insn32' 2425'--no-insn32' 2426 These options control the choice of microMIPS instructions used in 2427 code generated by the linker, such as that in the PLT or lazy 2428 binding stubs, or in relaxation. If '--insn32' is used, then the 2429 linker only uses 32-bit instruction encodings. By default or if 2430 '--no-insn32' is used, all instruction encodings are used, 2431 including 16-bit ones where possible. 2432 2433'--ignore-branch-isa' 2434'--no-ignore-branch-isa' 2435 These options control branch relocation checks for invalid ISA mode 2436 transitions. If '--ignore-branch-isa' is used, then the linker 2437 accepts any branch relocations and any ISA mode transition required 2438 is lost in relocation calculation, except for some cases of 'BAL' 2439 instructions which meet relaxation conditions and are converted to 2440 equivalent 'JALX' instructions as the associated relocation is 2441 calculated. By default or if '--no-ignore-branch-isa' is used a 2442 check is made causing the loss of an ISA mode transition to produce 2443 an error. 2444 2445 2446File: ld.info, Node: Environment, Prev: Options, Up: Invocation 2447 24482.2 Environment Variables 2449========================= 2450 2451You can change the behaviour of 'ld' with the environment variables 2452'GNUTARGET', 'LDEMULATION' and 'COLLECT_NO_DEMANGLE'. 2453 2454 'GNUTARGET' determines the input-file object format if you don't use 2455'-b' (or its synonym '--format'). Its value should be one of the BFD 2456names for an input format (*note BFD::). If there is no 'GNUTARGET' in 2457the environment, 'ld' uses the natural format of the target. If 2458'GNUTARGET' is set to 'default' then BFD attempts to discover the input 2459format by examining binary input files; this method often succeeds, but 2460there are potential ambiguities, since there is no method of ensuring 2461that the magic number used to specify object-file formats is unique. 2462However, the configuration procedure for BFD on each system places the 2463conventional format for that system first in the search-list, so 2464ambiguities are resolved in favor of convention. 2465 2466 'LDEMULATION' determines the default emulation if you don't use the 2467'-m' option. The emulation can affect various aspects of linker 2468behaviour, particularly the default linker script. You can list the 2469available emulations with the '--verbose' or '-V' options. If the '-m' 2470option is not used, and the 'LDEMULATION' environment variable is not 2471defined, the default emulation depends upon how the linker was 2472configured. 2473 2474 Normally, the linker will default to demangling symbols. However, if 2475'COLLECT_NO_DEMANGLE' is set in the environment, then it will default to 2476not demangling symbols. This environment variable is used in a similar 2477fashion by the 'gcc' linker wrapper program. The default may be 2478overridden by the '--demangle' and '--no-demangle' options. 2479 2480 2481File: ld.info, Node: Scripts, Next: Machine Dependent, Prev: Invocation, Up: Top 2482 24833 Linker Scripts 2484**************** 2485 2486Every link is controlled by a "linker script". This script is written 2487in the linker command language. 2488 2489 The main purpose of the linker script is to describe how the sections 2490in the input files should be mapped into the output file, and to control 2491the memory layout of the output file. Most linker scripts do nothing 2492more than this. However, when necessary, the linker script can also 2493direct the linker to perform many other operations, using the commands 2494described below. 2495 2496 The linker always uses a linker script. If you do not supply one 2497yourself, the linker will use a default script that is compiled into the 2498linker executable. You can use the '--verbose' command line option to 2499display the default linker script. Certain command line options, such 2500as '-r' or '-N', will affect the default linker script. 2501 2502 You may supply your own linker script by using the '-T' command line 2503option. When you do this, your linker script will replace the default 2504linker script. 2505 2506 You may also use linker scripts implicitly by naming them as input 2507files to the linker, as though they were files to be linked. *Note 2508Implicit Linker Scripts::. 2509 2510* Menu: 2511 2512* Basic Script Concepts:: Basic Linker Script Concepts 2513* Script Format:: Linker Script Format 2514* Simple Example:: Simple Linker Script Example 2515* Simple Commands:: Simple Linker Script Commands 2516* Assignments:: Assigning Values to Symbols 2517* SECTIONS:: SECTIONS Command 2518* MEMORY:: MEMORY Command 2519* PHDRS:: PHDRS Command 2520* VERSION:: VERSION Command 2521* Expressions:: Expressions in Linker Scripts 2522* Implicit Linker Scripts:: Implicit Linker Scripts 2523 2524 2525File: ld.info, Node: Basic Script Concepts, Next: Script Format, Up: Scripts 2526 25273.1 Basic Linker Script Concepts 2528================================ 2529 2530We need to define some basic concepts and vocabulary in order to 2531describe the linker script language. 2532 2533 The linker combines input files into a single output file. The 2534output file and each input file are in a special data format known as an 2535"object file format". Each file is called an "object file". The output 2536file is often called an "executable", but for our purposes we will also 2537call it an object file. Each object file has, among other things, a 2538list of "sections". We sometimes refer to a section in an input file as 2539an "input section"; similarly, a section in the output file is an 2540"output section". 2541 2542 Each section in an object file has a name and a size. Most sections 2543also have an associated block of data, known as the "section contents". 2544A section may be marked as "loadable", which means that the contents 2545should be loaded into memory when the output file is run. A section 2546with no contents may be "allocatable", which means that an area in 2547memory should be set aside, but nothing in particular should be loaded 2548there (in some cases this memory must be zeroed out). A section which 2549is neither loadable nor allocatable typically contains some sort of 2550debugging information. 2551 2552 Every loadable or allocatable output section has two addresses. The 2553first is the "VMA", or virtual memory address. This is the address the 2554section will have when the output file is run. The second is the "LMA", 2555or load memory address. This is the address at which the section will 2556be loaded. In most cases the two addresses will be the same. An 2557example of when they might be different is when a data section is loaded 2558into ROM, and then copied into RAM when the program starts up (this 2559technique is often used to initialize global variables in a ROM based 2560system). In this case the ROM address would be the LMA, and the RAM 2561address would be the VMA. 2562 2563 You can see the sections in an object file by using the 'objdump' 2564program with the '-h' option. 2565 2566 Every object file also has a list of "symbols", known as the "symbol 2567table". A symbol may be defined or undefined. Each symbol has a name, 2568and each defined symbol has an address, among other information. If you 2569compile a C or C++ program into an object file, you will get a defined 2570symbol for every defined function and global or static variable. Every 2571undefined function or global variable which is referenced in the input 2572file will become an undefined symbol. 2573 2574 You can see the symbols in an object file by using the 'nm' program, 2575or by using the 'objdump' program with the '-t' option. 2576 2577 2578File: ld.info, Node: Script Format, Next: Simple Example, Prev: Basic Script Concepts, Up: Scripts 2579 25803.2 Linker Script Format 2581======================== 2582 2583Linker scripts are text files. 2584 2585 You write a linker script as a series of commands. Each command is 2586either a keyword, possibly followed by arguments, or an assignment to a 2587symbol. You may separate commands using semicolons. Whitespace is 2588generally ignored. 2589 2590 Strings such as file or format names can normally be entered 2591directly. If the file name contains a character such as a comma which 2592would otherwise serve to separate file names, you may put the file name 2593in double quotes. There is no way to use a double quote character in a 2594file name. 2595 2596 You may include comments in linker scripts just as in C, delimited by 2597'/*' and '*/'. As in C, comments are syntactically equivalent to 2598whitespace. 2599 2600 2601File: ld.info, Node: Simple Example, Next: Simple Commands, Prev: Script Format, Up: Scripts 2602 26033.3 Simple Linker Script Example 2604================================ 2605 2606Many linker scripts are fairly simple. 2607 2608 The simplest possible linker script has just one command: 'SECTIONS'. 2609You use the 'SECTIONS' command to describe the memory layout of the 2610output file. 2611 2612 The 'SECTIONS' command is a powerful command. Here we will describe 2613a simple use of it. Let's assume your program consists only of code, 2614initialized data, and uninitialized data. These will be in the '.text', 2615'.data', and '.bss' sections, respectively. Let's assume further that 2616these are the only sections which appear in your input files. 2617 2618 For this example, let's say that the code should be loaded at address 26190x10000, and that the data should start at address 0x8000000. Here is a 2620linker script which will do that: 2621 SECTIONS 2622 { 2623 . = 0x10000; 2624 .text : { *(.text) } 2625 . = 0x8000000; 2626 .data : { *(.data) } 2627 .bss : { *(.bss) } 2628 } 2629 2630 You write the 'SECTIONS' command as the keyword 'SECTIONS', followed 2631by a series of symbol assignments and output section descriptions 2632enclosed in curly braces. 2633 2634 The first line inside the 'SECTIONS' command of the above example 2635sets the value of the special symbol '.', which is the location counter. 2636If you do not specify the address of an output section in some other way 2637(other ways are described later), the address is set from the current 2638value of the location counter. The location counter is then incremented 2639by the size of the output section. At the start of the 'SECTIONS' 2640command, the location counter has the value '0'. 2641 2642 The second line defines an output section, '.text'. The colon is 2643required syntax which may be ignored for now. Within the curly braces 2644after the output section name, you list the names of the input sections 2645which should be placed into this output section. The '*' is a wildcard 2646which matches any file name. The expression '*(.text)' means all 2647'.text' input sections in all input files. 2648 2649 Since the location counter is '0x10000' when the output section 2650'.text' is defined, the linker will set the address of the '.text' 2651section in the output file to be '0x10000'. 2652 2653 The remaining lines define the '.data' and '.bss' sections in the 2654output file. The linker will place the '.data' output section at 2655address '0x8000000'. After the linker places the '.data' output 2656section, the value of the location counter will be '0x8000000' plus the 2657size of the '.data' output section. The effect is that the linker will 2658place the '.bss' output section immediately after the '.data' output 2659section in memory. 2660 2661 The linker will ensure that each output section has the required 2662alignment, by increasing the location counter if necessary. In this 2663example, the specified addresses for the '.text' and '.data' sections 2664will probably satisfy any alignment constraints, but the linker may have 2665to create a small gap between the '.data' and '.bss' sections. 2666 2667 That's it! That's a simple and complete linker script. 2668 2669 2670File: ld.info, Node: Simple Commands, Next: Assignments, Prev: Simple Example, Up: Scripts 2671 26723.4 Simple Linker Script Commands 2673================================= 2674 2675In this section we describe the simple linker script commands. 2676 2677* Menu: 2678 2679* Entry Point:: Setting the entry point 2680* File Commands:: Commands dealing with files 2681* Format Commands:: Commands dealing with object file formats 2682 2683* REGION_ALIAS:: Assign alias names to memory regions 2684* Miscellaneous Commands:: Other linker script commands 2685 2686 2687File: ld.info, Node: Entry Point, Next: File Commands, Up: Simple Commands 2688 26893.4.1 Setting the Entry Point 2690----------------------------- 2691 2692The first instruction to execute in a program is called the "entry 2693point". You can use the 'ENTRY' linker script command to set the entry 2694point. The argument is a symbol name: 2695 ENTRY(SYMBOL) 2696 2697 There are several ways to set the entry point. The linker will set 2698the entry point by trying each of the following methods in order, and 2699stopping when one of them succeeds: 2700 * the '-e' ENTRY command-line option; 2701 * the 'ENTRY(SYMBOL)' command in a linker script; 2702 * the value of a target specific symbol, if it is defined; For many 2703 targets this is 'start', but PE and BeOS based systems for example 2704 check a list of possible entry symbols, matching the first one 2705 found. 2706 * the address of the first byte of the '.text' section, if present; 2707 * The address '0'. 2708 2709 2710File: ld.info, Node: File Commands, Next: Format Commands, Prev: Entry Point, Up: Simple Commands 2711 27123.4.2 Commands Dealing with Files 2713--------------------------------- 2714 2715Several linker script commands deal with files. 2716 2717'INCLUDE FILENAME' 2718 Include the linker script FILENAME at this point. The file will be 2719 searched for in the current directory, and in any directory 2720 specified with the '-L' option. You can nest calls to 'INCLUDE' up 2721 to 10 levels deep. 2722 2723 You can place 'INCLUDE' directives at the top level, in 'MEMORY' or 2724 'SECTIONS' commands, or in output section descriptions. 2725 2726'INPUT(FILE, FILE, ...)' 2727'INPUT(FILE FILE ...)' 2728 The 'INPUT' command directs the linker to include the named files 2729 in the link, as though they were named on the command line. 2730 2731 For example, if you always want to include 'subr.o' any time you do 2732 a link, but you can't be bothered to put it on every link command 2733 line, then you can put 'INPUT (subr.o)' in your linker script. 2734 2735 In fact, if you like, you can list all of your input files in the 2736 linker script, and then invoke the linker with nothing but a '-T' 2737 option. 2738 2739 In case a "sysroot prefix" is configured, and the filename starts 2740 with the '/' character, and the script being processed was located 2741 inside the "sysroot prefix", the filename will be looked for in the 2742 "sysroot prefix". Otherwise, the linker will try to open the file 2743 in the current directory. If it is not found, the linker will 2744 search through the archive library search path. The "sysroot 2745 prefix" can also be forced by specifying '=' as the first character 2746 in the filename path, or prefixing the filename path with 2747 '$SYSROOT'. See also the description of '-L' in *note Command Line 2748 Options: Options. 2749 2750 If you use 'INPUT (-lFILE)', 'ld' will transform the name to 2751 'libFILE.a', as with the command line argument '-l'. 2752 2753 When you use the 'INPUT' command in an implicit linker script, the 2754 files will be included in the link at the point at which the linker 2755 script file is included. This can affect archive searching. 2756 2757'GROUP(FILE, FILE, ...)' 2758'GROUP(FILE FILE ...)' 2759 The 'GROUP' command is like 'INPUT', except that the named files 2760 should all be archives, and they are searched repeatedly until no 2761 new undefined references are created. See the description of '-(' 2762 in *note Command Line Options: Options. 2763 2764'AS_NEEDED(FILE, FILE, ...)' 2765'AS_NEEDED(FILE FILE ...)' 2766 This construct can appear only inside of the 'INPUT' or 'GROUP' 2767 commands, among other filenames. The files listed will be handled 2768 as if they appear directly in the 'INPUT' or 'GROUP' commands, with 2769 the exception of ELF shared libraries, that will be added only when 2770 they are actually needed. This construct essentially enables 2771 '--as-needed' option for all the files listed inside of it and 2772 restores previous '--as-needed' resp. '--no-as-needed' setting 2773 afterwards. 2774 2775'OUTPUT(FILENAME)' 2776 The 'OUTPUT' command names the output file. Using 2777 'OUTPUT(FILENAME)' in the linker script is exactly like using '-o 2778 FILENAME' on the command line (*note Command Line Options: 2779 Options.). If both are used, the command line option takes 2780 precedence. 2781 2782 You can use the 'OUTPUT' command to define a default name for the 2783 output file other than the usual default of 'a.out'. 2784 2785'SEARCH_DIR(PATH)' 2786 The 'SEARCH_DIR' command adds PATH to the list of paths where 'ld' 2787 looks for archive libraries. Using 'SEARCH_DIR(PATH)' is exactly 2788 like using '-L PATH' on the command line (*note Command Line 2789 Options: Options.). If both are used, then the linker will search 2790 both paths. Paths specified using the command line option are 2791 searched first. 2792 2793'STARTUP(FILENAME)' 2794 The 'STARTUP' command is just like the 'INPUT' command, except that 2795 FILENAME will become the first input file to be linked, as though 2796 it were specified first on the command line. This may be useful 2797 when using a system in which the entry point is always the start of 2798 the first file. 2799 2800 2801File: ld.info, Node: Format Commands, Next: REGION_ALIAS, Prev: File Commands, Up: Simple Commands 2802 28033.4.3 Commands Dealing with Object File Formats 2804----------------------------------------------- 2805 2806A couple of linker script commands deal with object file formats. 2807 2808'OUTPUT_FORMAT(BFDNAME)' 2809'OUTPUT_FORMAT(DEFAULT, BIG, LITTLE)' 2810 The 'OUTPUT_FORMAT' command names the BFD format to use for the 2811 output file (*note BFD::). Using 'OUTPUT_FORMAT(BFDNAME)' is 2812 exactly like using '--oformat BFDNAME' on the command line (*note 2813 Command Line Options: Options.). If both are used, the command 2814 line option takes precedence. 2815 2816 You can use 'OUTPUT_FORMAT' with three arguments to use different 2817 formats based on the '-EB' and '-EL' command line options. This 2818 permits the linker script to set the output format based on the 2819 desired endianness. 2820 2821 If neither '-EB' nor '-EL' are used, then the output format will be 2822 the first argument, DEFAULT. If '-EB' is used, the output format 2823 will be the second argument, BIG. If '-EL' is used, the output 2824 format will be the third argument, LITTLE. 2825 2826 For example, the default linker script for the MIPS ELF target uses 2827 this command: 2828 OUTPUT_FORMAT(elf32-bigmips, elf32-bigmips, elf32-littlemips) 2829 This says that the default format for the output file is 2830 'elf32-bigmips', but if the user uses the '-EL' command line 2831 option, the output file will be created in the 'elf32-littlemips' 2832 format. 2833 2834'TARGET(BFDNAME)' 2835 The 'TARGET' command names the BFD format to use when reading input 2836 files. It affects subsequent 'INPUT' and 'GROUP' commands. This 2837 command is like using '-b BFDNAME' on the command line (*note 2838 Command Line Options: Options.). If the 'TARGET' command is used 2839 but 'OUTPUT_FORMAT' is not, then the last 'TARGET' command is also 2840 used to set the format for the output file. *Note BFD::. 2841 2842 2843File: ld.info, Node: REGION_ALIAS, Next: Miscellaneous Commands, Prev: Format Commands, Up: Simple Commands 2844 28453.4.4 Assign alias names to memory regions 2846------------------------------------------ 2847 2848Alias names can be added to existing memory regions created with the 2849*note MEMORY:: command. Each name corresponds to at most one memory 2850region. 2851 2852 REGION_ALIAS(ALIAS, REGION) 2853 2854 The 'REGION_ALIAS' function creates an alias name ALIAS for the 2855memory region REGION. This allows a flexible mapping of output sections 2856to memory regions. An example follows. 2857 2858 Suppose we have an application for embedded systems which come with 2859various memory storage devices. All have a general purpose, volatile 2860memory 'RAM' that allows code execution or data storage. Some may have 2861a read-only, non-volatile memory 'ROM' that allows code execution and 2862read-only data access. The last variant is a read-only, non-volatile 2863memory 'ROM2' with read-only data access and no code execution 2864capability. We have four output sections: 2865 2866 * '.text' program code; 2867 * '.rodata' read-only data; 2868 * '.data' read-write initialized data; 2869 * '.bss' read-write zero initialized data. 2870 2871 The goal is to provide a linker command file that contains a system 2872independent part defining the output sections and a system dependent 2873part mapping the output sections to the memory regions available on the 2874system. Our embedded systems come with three different memory setups 2875'A', 'B' and 'C': 2876Section Variant A Variant B Variant C 2877.text RAM ROM ROM 2878.rodata RAM ROM ROM2 2879.data RAM RAM/ROM RAM/ROM2 2880.bss RAM RAM RAM 2881 The notation 'RAM/ROM' or 'RAM/ROM2' means that this section is 2882loaded into region 'ROM' or 'ROM2' respectively. Please note that the 2883load address of the '.data' section starts in all three variants at the 2884end of the '.rodata' section. 2885 2886 The base linker script that deals with the output sections follows. 2887It includes the system dependent 'linkcmds.memory' file that describes 2888the memory layout: 2889 INCLUDE linkcmds.memory 2890 2891 SECTIONS 2892 { 2893 .text : 2894 { 2895 *(.text) 2896 } > REGION_TEXT 2897 .rodata : 2898 { 2899 *(.rodata) 2900 rodata_end = .; 2901 } > REGION_RODATA 2902 .data : AT (rodata_end) 2903 { 2904 data_start = .; 2905 *(.data) 2906 } > REGION_DATA 2907 data_size = SIZEOF(.data); 2908 data_load_start = LOADADDR(.data); 2909 .bss : 2910 { 2911 *(.bss) 2912 } > REGION_BSS 2913 } 2914 2915 Now we need three different 'linkcmds.memory' files to define memory 2916regions and alias names. The content of 'linkcmds.memory' for the three 2917variants 'A', 'B' and 'C': 2918'A' 2919 Here everything goes into the 'RAM'. 2920 MEMORY 2921 { 2922 RAM : ORIGIN = 0, LENGTH = 4M 2923 } 2924 2925 REGION_ALIAS("REGION_TEXT", RAM); 2926 REGION_ALIAS("REGION_RODATA", RAM); 2927 REGION_ALIAS("REGION_DATA", RAM); 2928 REGION_ALIAS("REGION_BSS", RAM); 2929'B' 2930 Program code and read-only data go into the 'ROM'. Read-write data 2931 goes into the 'RAM'. An image of the initialized data is loaded 2932 into the 'ROM' and will be copied during system start into the 2933 'RAM'. 2934 MEMORY 2935 { 2936 ROM : ORIGIN = 0, LENGTH = 3M 2937 RAM : ORIGIN = 0x10000000, LENGTH = 1M 2938 } 2939 2940 REGION_ALIAS("REGION_TEXT", ROM); 2941 REGION_ALIAS("REGION_RODATA", ROM); 2942 REGION_ALIAS("REGION_DATA", RAM); 2943 REGION_ALIAS("REGION_BSS", RAM); 2944'C' 2945 Program code goes into the 'ROM'. Read-only data goes into the 2946 'ROM2'. Read-write data goes into the 'RAM'. An image of the 2947 initialized data is loaded into the 'ROM2' and will be copied 2948 during system start into the 'RAM'. 2949 MEMORY 2950 { 2951 ROM : ORIGIN = 0, LENGTH = 2M 2952 ROM2 : ORIGIN = 0x10000000, LENGTH = 1M 2953 RAM : ORIGIN = 0x20000000, LENGTH = 1M 2954 } 2955 2956 REGION_ALIAS("REGION_TEXT", ROM); 2957 REGION_ALIAS("REGION_RODATA", ROM2); 2958 REGION_ALIAS("REGION_DATA", RAM); 2959 REGION_ALIAS("REGION_BSS", RAM); 2960 2961 It is possible to write a common system initialization routine to 2962copy the '.data' section from 'ROM' or 'ROM2' into the 'RAM' if 2963necessary: 2964 #include <string.h> 2965 2966 extern char data_start []; 2967 extern char data_size []; 2968 extern char data_load_start []; 2969 2970 void copy_data(void) 2971 { 2972 if (data_start != data_load_start) 2973 { 2974 memcpy(data_start, data_load_start, (size_t) data_size); 2975 } 2976 } 2977 2978 2979File: ld.info, Node: Miscellaneous Commands, Prev: REGION_ALIAS, Up: Simple Commands 2980 29813.4.5 Other Linker Script Commands 2982---------------------------------- 2983 2984There are a few other linker scripts commands. 2985 2986'ASSERT(EXP, MESSAGE)' 2987 Ensure that EXP is non-zero. If it is zero, then exit the linker 2988 with an error code, and print MESSAGE. 2989 2990 Note that assertions are checked before the final stages of linking 2991 take place. This means that expressions involving symbols PROVIDEd 2992 inside section definitions will fail if the user has not set values 2993 for those symbols. The only exception to this rule is PROVIDEd 2994 symbols that just reference dot. Thus an assertion like this: 2995 2996 .stack : 2997 { 2998 PROVIDE (__stack = .); 2999 PROVIDE (__stack_size = 0x100); 3000 ASSERT ((__stack > (_end + __stack_size)), "Error: No room left for the stack"); 3001 } 3002 3003 will fail if '__stack_size' is not defined elsewhere. Symbols 3004 PROVIDEd outside of section definitions are evaluated earlier, so 3005 they can be used inside ASSERTions. Thus: 3006 3007 PROVIDE (__stack_size = 0x100); 3008 .stack : 3009 { 3010 PROVIDE (__stack = .); 3011 ASSERT ((__stack > (_end + __stack_size)), "Error: No room left for the stack"); 3012 } 3013 3014 will work. 3015 3016'EXTERN(SYMBOL SYMBOL ...)' 3017 Force SYMBOL to be entered in the output file as an undefined 3018 symbol. Doing this may, for example, trigger linking of additional 3019 modules from standard libraries. You may list several SYMBOLs for 3020 each 'EXTERN', and you may use 'EXTERN' multiple times. This 3021 command has the same effect as the '-u' command-line option. 3022 3023'FORCE_COMMON_ALLOCATION' 3024 This command has the same effect as the '-d' command-line option: 3025 to make 'ld' assign space to common symbols even if a relocatable 3026 output file is specified ('-r'). 3027 3028'INHIBIT_COMMON_ALLOCATION' 3029 This command has the same effect as the '--no-define-common' 3030 command-line option: to make 'ld' omit the assignment of addresses 3031 to common symbols even for a non-relocatable output file. 3032 3033'FORCE_GROUP_ALLOCATION' 3034 This command has the same effect as the '--force-group-allocation' 3035 command-line option: to make 'ld' place section group members like 3036 normal input sections, and to delete the section groups even if a 3037 relocatable output file is specified ('-r'). 3038 3039'INSERT [ AFTER | BEFORE ] OUTPUT_SECTION' 3040 This command is typically used in a script specified by '-T' to 3041 augment the default 'SECTIONS' with, for example, overlays. It 3042 inserts all prior linker script statements after (or before) 3043 OUTPUT_SECTION, and also causes '-T' to not override the default 3044 linker script. The exact insertion point is as for orphan 3045 sections. *Note Location Counter::. The insertion happens after 3046 the linker has mapped input sections to output sections. Prior to 3047 the insertion, since '-T' scripts are parsed before the default 3048 linker script, statements in the '-T' script occur before the 3049 default linker script statements in the internal linker 3050 representation of the script. In particular, input section 3051 assignments will be made to '-T' output sections before those in 3052 the default script. Here is an example of how a '-T' script using 3053 'INSERT' might look: 3054 3055 SECTIONS 3056 { 3057 OVERLAY : 3058 { 3059 .ov1 { ov1*(.text) } 3060 .ov2 { ov2*(.text) } 3061 } 3062 } 3063 INSERT AFTER .text; 3064 3065'NOCROSSREFS(SECTION SECTION ...)' 3066 This command may be used to tell 'ld' to issue an error about any 3067 references among certain output sections. 3068 3069 In certain types of programs, particularly on embedded systems when 3070 using overlays, when one section is loaded into memory, another 3071 section will not be. Any direct references between the two 3072 sections would be errors. For example, it would be an error if 3073 code in one section called a function defined in the other section. 3074 3075 The 'NOCROSSREFS' command takes a list of output section names. If 3076 'ld' detects any cross references between the sections, it reports 3077 an error and returns a non-zero exit status. Note that the 3078 'NOCROSSREFS' command uses output section names, not input section 3079 names. 3080 3081'NOCROSSREFS_TO(TOSECTION FROMSECTION ...)' 3082 This command may be used to tell 'ld' to issue an error about any 3083 references to one section from a list of other sections. 3084 3085 The 'NOCROSSREFS' command is useful when ensuring that two or more 3086 output sections are entirely independent but there are situations 3087 where a one-way dependency is needed. For example, in a multi-core 3088 application there may be shared code that can be called from each 3089 core but for safety must never call back. 3090 3091 The 'NOCROSSREFS_TO' command takes a list of output section names. 3092 The first section can not be referenced from any of the other 3093 sections. If 'ld' detects any references to the first section from 3094 any of the other sections, it reports an error and returns a 3095 non-zero exit status. Note that the 'NOCROSSREFS_TO' command uses 3096 output section names, not input section names. 3097 3098'OUTPUT_ARCH(BFDARCH)' 3099 Specify a particular output machine architecture. The argument is 3100 one of the names used by the BFD library (*note BFD::). You can 3101 see the architecture of an object file by using the 'objdump' 3102 program with the '-f' option. 3103 3104'LD_FEATURE(STRING)' 3105 This command may be used to modify 'ld' behavior. If STRING is 3106 '"SANE_EXPR"' then absolute symbols and numbers in a script are 3107 simply treated as numbers everywhere. *Note Expression Section::. 3108 3109 3110File: ld.info, Node: Assignments, Next: SECTIONS, Prev: Simple Commands, Up: Scripts 3111 31123.5 Assigning Values to Symbols 3113=============================== 3114 3115You may assign a value to a symbol in a linker script. This will define 3116the symbol and place it into the symbol table with a global scope. 3117 3118* Menu: 3119 3120* Simple Assignments:: Simple Assignments 3121* HIDDEN:: HIDDEN 3122* PROVIDE:: PROVIDE 3123* PROVIDE_HIDDEN:: PROVIDE_HIDDEN 3124* Source Code Reference:: How to use a linker script defined symbol in source code 3125 3126 3127File: ld.info, Node: Simple Assignments, Next: HIDDEN, Up: Assignments 3128 31293.5.1 Simple Assignments 3130------------------------ 3131 3132You may assign to a symbol using any of the C assignment operators: 3133 3134'SYMBOL = EXPRESSION ;' 3135'SYMBOL += EXPRESSION ;' 3136'SYMBOL -= EXPRESSION ;' 3137'SYMBOL *= EXPRESSION ;' 3138'SYMBOL /= EXPRESSION ;' 3139'SYMBOL <<= EXPRESSION ;' 3140'SYMBOL >>= EXPRESSION ;' 3141'SYMBOL &= EXPRESSION ;' 3142'SYMBOL |= EXPRESSION ;' 3143 3144 The first case will define SYMBOL to the value of EXPRESSION. In the 3145other cases, SYMBOL must already be defined, and the value will be 3146adjusted accordingly. 3147 3148 The special symbol name '.' indicates the location counter. You may 3149only use this within a 'SECTIONS' command. *Note Location Counter::. 3150 3151 The semicolon after EXPRESSION is required. 3152 3153 Expressions are defined below; see *note Expressions::. 3154 3155 You may write symbol assignments as commands in their own right, or 3156as statements within a 'SECTIONS' command, or as part of an output 3157section description in a 'SECTIONS' command. 3158 3159 The section of the symbol will be set from the section of the 3160expression; for more information, see *note Expression Section::. 3161 3162 Here is an example showing the three different places that symbol 3163assignments may be used: 3164 3165 floating_point = 0; 3166 SECTIONS 3167 { 3168 .text : 3169 { 3170 *(.text) 3171 _etext = .; 3172 } 3173 _bdata = (. + 3) & ~ 3; 3174 .data : { *(.data) } 3175 } 3176In this example, the symbol 'floating_point' will be defined as zero. 3177The symbol '_etext' will be defined as the address following the last 3178'.text' input section. The symbol '_bdata' will be defined as the 3179address following the '.text' output section aligned upward to a 4 byte 3180boundary. 3181 3182 3183File: ld.info, Node: HIDDEN, Next: PROVIDE, Prev: Simple Assignments, Up: Assignments 3184 31853.5.2 HIDDEN 3186------------ 3187 3188For ELF targeted ports, define a symbol that will be hidden and won't be 3189exported. The syntax is 'HIDDEN(SYMBOL = EXPRESSION)'. 3190 3191 Here is the example from *note Simple Assignments::, rewritten to use 3192'HIDDEN': 3193 3194 HIDDEN(floating_point = 0); 3195 SECTIONS 3196 { 3197 .text : 3198 { 3199 *(.text) 3200 HIDDEN(_etext = .); 3201 } 3202 HIDDEN(_bdata = (. + 3) & ~ 3); 3203 .data : { *(.data) } 3204 } 3205In this case none of the three symbols will be visible outside this 3206module. 3207 3208 3209File: ld.info, Node: PROVIDE, Next: PROVIDE_HIDDEN, Prev: HIDDEN, Up: Assignments 3210 32113.5.3 PROVIDE 3212------------- 3213 3214In some cases, it is desirable for a linker script to define a symbol 3215only if it is referenced and is not defined by any object included in 3216the link. For example, traditional linkers defined the symbol 'etext'. 3217However, ANSI C requires that the user be able to use 'etext' as a 3218function name without encountering an error. The 'PROVIDE' keyword may 3219be used to define a symbol, such as 'etext', only if it is referenced 3220but not defined. The syntax is 'PROVIDE(SYMBOL = EXPRESSION)'. 3221 3222 Here is an example of using 'PROVIDE' to define 'etext': 3223 SECTIONS 3224 { 3225 .text : 3226 { 3227 *(.text) 3228 _etext = .; 3229 PROVIDE(etext = .); 3230 } 3231 } 3232 3233 In this example, if the program defines '_etext' (with a leading 3234underscore), the linker will give a multiple definition error. If, on 3235the other hand, the program defines 'etext' (with no leading 3236underscore), the linker will silently use the definition in the program. 3237If the program references 'etext' but does not define it, the linker 3238will use the definition in the linker script. 3239 3240 Note - the 'PROVIDE' directive considers a common symbol to be 3241defined, even though such a symbol could be combined with the symbol 3242that the 'PROVIDE' would create. This is particularly important when 3243considering constructor and destructor list symbols such as 3244'__CTOR_LIST__' as these are often defined as common symbols. 3245 3246 3247File: ld.info, Node: PROVIDE_HIDDEN, Next: Source Code Reference, Prev: PROVIDE, Up: Assignments 3248 32493.5.4 PROVIDE_HIDDEN 3250-------------------- 3251 3252Similar to 'PROVIDE'. For ELF targeted ports, the symbol will be hidden 3253and won't be exported. 3254 3255 3256File: ld.info, Node: Source Code Reference, Prev: PROVIDE_HIDDEN, Up: Assignments 3257 32583.5.5 Source Code Reference 3259--------------------------- 3260 3261Accessing a linker script defined variable from source code is not 3262intuitive. In particular a linker script symbol is not equivalent to a 3263variable declaration in a high level language, it is instead a symbol 3264that does not have a value. 3265 3266 Before going further, it is important to note that compilers often 3267transform names in the source code into different names when they are 3268stored in the symbol table. For example, Fortran compilers commonly 3269prepend or append an underscore, and C++ performs extensive 'name 3270mangling'. Therefore there might be a discrepancy between the name of a 3271variable as it is used in source code and the name of the same variable 3272as it is defined in a linker script. For example in C a linker script 3273variable might be referred to as: 3274 3275 extern int foo; 3276 3277 But in the linker script it might be defined as: 3278 3279 _foo = 1000; 3280 3281 In the remaining examples however it is assumed that no name 3282transformation has taken place. 3283 3284 When a symbol is declared in a high level language such as C, two 3285things happen. The first is that the compiler reserves enough space in 3286the program's memory to hold the _value_ of the symbol. The second is 3287that the compiler creates an entry in the program's symbol table which 3288holds the symbol's _address_. ie the symbol table contains the address 3289of the block of memory holding the symbol's value. So for example the 3290following C declaration, at file scope: 3291 3292 int foo = 1000; 3293 3294 creates an entry called 'foo' in the symbol table. This entry holds 3295the address of an 'int' sized block of memory where the number 1000 is 3296initially stored. 3297 3298 When a program references a symbol the compiler generates code that 3299first accesses the symbol table to find the address of the symbol's 3300memory block and then code to read the value from that memory block. 3301So: 3302 3303 foo = 1; 3304 3305 looks up the symbol 'foo' in the symbol table, gets the address 3306associated with this symbol and then writes the value 1 into that 3307address. Whereas: 3308 3309 int * a = & foo; 3310 3311 looks up the symbol 'foo' in the symbol table, gets its address and 3312then copies this address into the block of memory associated with the 3313variable 'a'. 3314 3315 Linker scripts symbol declarations, by contrast, create an entry in 3316the symbol table but do not assign any memory to them. Thus they are an 3317address without a value. So for example the linker script definition: 3318 3319 foo = 1000; 3320 3321 creates an entry in the symbol table called 'foo' which holds the 3322address of memory location 1000, but nothing special is stored at 3323address 1000. This means that you cannot access the _value_ of a linker 3324script defined symbol - it has no value - all you can do is access the 3325_address_ of a linker script defined symbol. 3326 3327 Hence when you are using a linker script defined symbol in source 3328code you should always take the address of the symbol, and never attempt 3329to use its value. For example suppose you want to copy the contents of 3330a section of memory called .ROM into a section called .FLASH and the 3331linker script contains these declarations: 3332 3333 start_of_ROM = .ROM; 3334 end_of_ROM = .ROM + sizeof (.ROM); 3335 start_of_FLASH = .FLASH; 3336 3337 Then the C source code to perform the copy would be: 3338 3339 extern char start_of_ROM, end_of_ROM, start_of_FLASH; 3340 3341 memcpy (& start_of_FLASH, & start_of_ROM, & end_of_ROM - & start_of_ROM); 3342 3343 Note the use of the '&' operators. These are correct. Alternatively 3344the symbols can be treated as the names of vectors or arrays and then 3345the code will again work as expected: 3346 3347 extern char start_of_ROM[], end_of_ROM[], start_of_FLASH[]; 3348 3349 memcpy (start_of_FLASH, start_of_ROM, end_of_ROM - start_of_ROM); 3350 3351 Note how using this method does not require the use of '&' operators. 3352 3353 3354File: ld.info, Node: SECTIONS, Next: MEMORY, Prev: Assignments, Up: Scripts 3355 33563.6 SECTIONS Command 3357==================== 3358 3359The 'SECTIONS' command tells the linker how to map input sections into 3360output sections, and how to place the output sections in memory. 3361 3362 The format of the 'SECTIONS' command is: 3363 SECTIONS 3364 { 3365 SECTIONS-COMMAND 3366 SECTIONS-COMMAND 3367 ... 3368 } 3369 3370 Each SECTIONS-COMMAND may of be one of the following: 3371 3372 * an 'ENTRY' command (*note Entry command: Entry Point.) 3373 * a symbol assignment (*note Assignments::) 3374 * an output section description 3375 * an overlay description 3376 3377 The 'ENTRY' command and symbol assignments are permitted inside the 3378'SECTIONS' command for convenience in using the location counter in 3379those commands. This can also make the linker script easier to 3380understand because you can use those commands at meaningful points in 3381the layout of the output file. 3382 3383 Output section descriptions and overlay descriptions are described 3384below. 3385 3386 If you do not use a 'SECTIONS' command in your linker script, the 3387linker will place each input section into an identically named output 3388section in the order that the sections are first encountered in the 3389input files. If all input sections are present in the first file, for 3390example, the order of sections in the output file will match the order 3391in the first input file. The first section will be at address zero. 3392 3393* Menu: 3394 3395* Output Section Description:: Output section description 3396* Output Section Name:: Output section name 3397* Output Section Address:: Output section address 3398* Input Section:: Input section description 3399* Output Section Data:: Output section data 3400* Output Section Keywords:: Output section keywords 3401* Output Section Discarding:: Output section discarding 3402* Output Section Attributes:: Output section attributes 3403* Overlay Description:: Overlay description 3404 3405 3406File: ld.info, Node: Output Section Description, Next: Output Section Name, Up: SECTIONS 3407 34083.6.1 Output Section Description 3409-------------------------------- 3410 3411The full description of an output section looks like this: 3412 SECTION [ADDRESS] [(TYPE)] : 3413 [AT(LMA)] 3414 [ALIGN(SECTION_ALIGN) | ALIGN_WITH_INPUT] 3415 [SUBALIGN(SUBSECTION_ALIGN)] 3416 [CONSTRAINT] 3417 { 3418 OUTPUT-SECTION-COMMAND 3419 OUTPUT-SECTION-COMMAND 3420 ... 3421 } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP] [,] 3422 3423 Most output sections do not use most of the optional section 3424attributes. 3425 3426 The whitespace around SECTION is required, so that the section name 3427is unambiguous. The colon and the curly braces are also required. The 3428comma at the end may be required if a FILLEXP is used and the next 3429SECTIONS-COMMAND looks like a continuation of the expression. The line 3430breaks and other white space are optional. 3431 3432 Each OUTPUT-SECTION-COMMAND may be one of the following: 3433 3434 * a symbol assignment (*note Assignments::) 3435 * an input section description (*note Input Section::) 3436 * data values to include directly (*note Output Section Data::) 3437 * a special output section keyword (*note Output Section Keywords::) 3438 3439 3440File: ld.info, Node: Output Section Name, Next: Output Section Address, Prev: Output Section Description, Up: SECTIONS 3441 34423.6.2 Output Section Name 3443------------------------- 3444 3445The name of the output section is SECTION. SECTION must meet the 3446constraints of your output format. In formats which only support a 3447limited number of sections, such as 'a.out', the name must be one of the 3448names supported by the format ('a.out', for example, allows only 3449'.text', '.data' or '.bss'). If the output format supports any number 3450of sections, but with numbers and not names (as is the case for Oasys), 3451the name should be supplied as a quoted numeric string. A section name 3452may consist of any sequence of characters, but a name which contains any 3453unusual characters such as commas must be quoted. 3454 3455 The output section name '/DISCARD/' is special; *note Output Section 3456Discarding::. 3457 3458 3459File: ld.info, Node: Output Section Address, Next: Input Section, Prev: Output Section Name, Up: SECTIONS 3460 34613.6.3 Output Section Address 3462---------------------------- 3463 3464The ADDRESS is an expression for the VMA (the virtual memory address) of 3465the output section. This address is optional, but if it is provided 3466then the output address will be set exactly as specified. 3467 3468 If the output address is not specified then one will be chosen for 3469the section, based on the heuristic below. This address will be 3470adjusted to fit the alignment requirement of the output section. The 3471alignment requirement is the strictest alignment of any input section 3472contained within the output section. 3473 3474 The output section address heuristic is as follows: 3475 3476 * If an output memory REGION is set for the section then it is added 3477 to this region and its address will be the next free address in 3478 that region. 3479 3480 * If the MEMORY command has been used to create a list of memory 3481 regions then the first region which has attributes compatible with 3482 the section is selected to contain it. The section's output 3483 address will be the next free address in that region; *note 3484 MEMORY::. 3485 3486 * If no memory regions were specified, or none match the section then 3487 the output address will be based on the current value of the 3488 location counter. 3489 3490For example: 3491 3492 .text . : { *(.text) } 3493 3494and 3495 3496 .text : { *(.text) } 3497 3498are subtly different. The first will set the address of the '.text' 3499output section to the current value of the location counter. The second 3500will set it to the current value of the location counter aligned to the 3501strictest alignment of any of the '.text' input sections. 3502 3503 The ADDRESS may be an arbitrary expression; *note Expressions::. For 3504example, if you want to align the section on a 0x10 byte boundary, so 3505that the lowest four bits of the section address are zero, you could do 3506something like this: 3507 .text ALIGN(0x10) : { *(.text) } 3508This works because 'ALIGN' returns the current location counter aligned 3509upward to the specified value. 3510 3511 Specifying ADDRESS for a section will change the value of the 3512location counter, provided that the section is non-empty. (Empty 3513sections are ignored). 3514 3515 3516File: ld.info, Node: Input Section, Next: Output Section Data, Prev: Output Section Address, Up: SECTIONS 3517 35183.6.4 Input Section Description 3519------------------------------- 3520 3521The most common output section command is an input section description. 3522 3523 The input section description is the most basic linker script 3524operation. You use output sections to tell the linker how to lay out 3525your program in memory. You use input section descriptions to tell the 3526linker how to map the input files into your memory layout. 3527 3528* Menu: 3529 3530* Input Section Basics:: Input section basics 3531* Input Section Wildcards:: Input section wildcard patterns 3532* Input Section Common:: Input section for common symbols 3533* Input Section Keep:: Input section and garbage collection 3534* Input Section Example:: Input section example 3535 3536 3537File: ld.info, Node: Input Section Basics, Next: Input Section Wildcards, Up: Input Section 3538 35393.6.4.1 Input Section Basics 3540............................ 3541 3542An input section description consists of a file name optionally followed 3543by a list of section names in parentheses. 3544 3545 The file name and the section name may be wildcard patterns, which we 3546describe further below (*note Input Section Wildcards::). 3547 3548 The most common input section description is to include all input 3549sections with a particular name in the output section. For example, to 3550include all input '.text' sections, you would write: 3551 *(.text) 3552Here the '*' is a wildcard which matches any file name. To exclude a 3553list of files from matching the file name wildcard, EXCLUDE_FILE may be 3554used to match all files except the ones specified in the EXCLUDE_FILE 3555list. For example: 3556 EXCLUDE_FILE (*crtend.o *otherfile.o) *(.ctors) 3557will cause all .ctors sections from all files except 'crtend.o' and 3558'otherfile.o' to be included. The EXCLUDE_FILE can also be placed 3559inside the section list, for example: 3560 *(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors) 3561The result of this is identically to the previous example. Supporting 3562two syntaxes for EXCLUDE_FILE is useful if the section list contains 3563more than one section, as described below. 3564 3565 There are two ways to include more than one section: 3566 *(.text .rdata) 3567 *(.text) *(.rdata) 3568The difference between these is the order in which the '.text' and 3569'.rdata' input sections will appear in the output section. In the first 3570example, they will be intermingled, appearing in the same order as they 3571are found in the linker input. In the second example, all '.text' input 3572sections will appear first, followed by all '.rdata' input sections. 3573 3574 When using EXCLUDE_FILE with more than one section, if the exclusion 3575is within the section list then the exclusion only applies to the 3576immediately following section, for example: 3577 *(EXCLUDE_FILE (*somefile.o) .text .rdata) 3578will cause all '.text' sections from all files except 'somefile.o' to be 3579included, while all '.rdata' sections from all files, including 3580'somefile.o', will be included. To exclude the '.rdata' sections from 3581'somefile.o' the example could be modified to: 3582 *(EXCLUDE_FILE (*somefile.o) .text EXCLUDE_FILE (*somefile.o) .rdata) 3583Alternatively, placing the EXCLUDE_FILE outside of the section list, 3584before the input file selection, will cause the exclusion to apply for 3585all sections. Thus the previous example can be rewritten as: 3586 EXCLUDE_FILE (*somefile.o) *(.text .rdata) 3587 3588 You can specify a file name to include sections from a particular 3589file. You would do this if one or more of your files contain special 3590data that needs to be at a particular location in memory. For example: 3591 data.o(.data) 3592 3593 To refine the sections that are included based on the section flags 3594of an input section, INPUT_SECTION_FLAGS may be used. 3595 3596 Here is a simple example for using Section header flags for ELF 3597sections: 3598 3599 SECTIONS { 3600 .text : { INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS) *(.text) } 3601 .text2 : { INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) } 3602 } 3603 3604 In this example, the output section '.text' will be comprised of any 3605input section matching the name *(.text) whose section header flags 3606'SHF_MERGE' and 'SHF_STRINGS' are set. The output section '.text2' will 3607be comprised of any input section matching the name *(.text) whose 3608section header flag 'SHF_WRITE' is clear. 3609 3610 You can also specify files within archives by writing a pattern 3611matching the archive, a colon, then the pattern matching the file, with 3612no whitespace around the colon. 3613 3614'archive:file' 3615 matches file within archive 3616'archive:' 3617 matches the whole archive 3618':file' 3619 matches file but not one in an archive 3620 3621 Either one or both of 'archive' and 'file' can contain shell 3622wildcards. On DOS based file systems, the linker will assume that a 3623single letter followed by a colon is a drive specifier, so 'c:myfile.o' 3624is a simple file specification, not 'myfile.o' within an archive called 3625'c'. 'archive:file' filespecs may also be used within an 'EXCLUDE_FILE' 3626list, but may not appear in other linker script contexts. For instance, 3627you cannot extract a file from an archive by using 'archive:file' in an 3628'INPUT' command. 3629 3630 If you use a file name without a list of sections, then all sections 3631in the input file will be included in the output section. This is not 3632commonly done, but it may by useful on occasion. For example: 3633 data.o 3634 3635 When you use a file name which is not an 'archive:file' specifier and 3636does not contain any wild card characters, the linker will first see if 3637you also specified the file name on the linker command line or in an 3638'INPUT' command. If you did not, the linker will attempt to open the 3639file as an input file, as though it appeared on the command line. Note 3640that this differs from an 'INPUT' command, because the linker will not 3641search for the file in the archive search path. 3642 3643 3644File: ld.info, Node: Input Section Wildcards, Next: Input Section Common, Prev: Input Section Basics, Up: Input Section 3645 36463.6.4.2 Input Section Wildcard Patterns 3647....................................... 3648 3649In an input section description, either the file name or the section 3650name or both may be wildcard patterns. 3651 3652 The file name of '*' seen in many examples is a simple wildcard 3653pattern for the file name. 3654 3655 The wildcard patterns are like those used by the Unix shell. 3656 3657'*' 3658 matches any number of characters 3659'?' 3660 matches any single character 3661'[CHARS]' 3662 matches a single instance of any of the CHARS; the '-' character 3663 may be used to specify a range of characters, as in '[a-z]' to 3664 match any lower case letter 3665'\' 3666 quotes the following character 3667 3668 When a file name is matched with a wildcard, the wildcard characters 3669will not match a '/' character (used to separate directory names on 3670Unix). A pattern consisting of a single '*' character is an exception; 3671it will always match any file name, whether it contains a '/' or not. 3672In a section name, the wildcard characters will match a '/' character. 3673 3674 File name wildcard patterns only match files which are explicitly 3675specified on the command line or in an 'INPUT' command. The linker does 3676not search directories to expand wildcards. 3677 3678 If a file name matches more than one wildcard pattern, or if a file 3679name appears explicitly and is also matched by a wildcard pattern, the 3680linker will use the first match in the linker script. For example, this 3681sequence of input section descriptions is probably in error, because the 3682'data.o' rule will not be used: 3683 .data : { *(.data) } 3684 .data1 : { data.o(.data) } 3685 3686 Normally, the linker will place files and sections matched by 3687wildcards in the order in which they are seen during the link. You can 3688change this by using the 'SORT_BY_NAME' keyword, which appears before a 3689wildcard pattern in parentheses (e.g., 'SORT_BY_NAME(.text*)'). When 3690the 'SORT_BY_NAME' keyword is used, the linker will sort the files or 3691sections into ascending order by name before placing them in the output 3692file. 3693 3694 'SORT_BY_ALIGNMENT' is very similar to 'SORT_BY_NAME'. The 3695difference is 'SORT_BY_ALIGNMENT' will sort sections into descending 3696order by alignment before placing them in the output file. Larger 3697alignments are placed before smaller alignments in order to reduce the 3698amount of padding necessary. 3699 3700 'SORT_BY_INIT_PRIORITY' is very similar to 'SORT_BY_NAME'. The 3701difference is 'SORT_BY_INIT_PRIORITY' will sort sections into ascending 3702order by numerical value of the GCC init_priority attribute encoded in 3703the section name before placing them in the output file. 3704 3705 'SORT' is an alias for 'SORT_BY_NAME'. 3706 3707 When there are nested section sorting commands in linker script, 3708there can be at most 1 level of nesting for section sorting commands. 3709 3710 1. 'SORT_BY_NAME' ('SORT_BY_ALIGNMENT' (wildcard section pattern)). 3711 It will sort the input sections by name first, then by alignment if 3712 two sections have the same name. 3713 2. 'SORT_BY_ALIGNMENT' ('SORT_BY_NAME' (wildcard section pattern)). 3714 It will sort the input sections by alignment first, then by name if 3715 two sections have the same alignment. 3716 3. 'SORT_BY_NAME' ('SORT_BY_NAME' (wildcard section pattern)) is 3717 treated the same as 'SORT_BY_NAME' (wildcard section pattern). 3718 4. 'SORT_BY_ALIGNMENT' ('SORT_BY_ALIGNMENT' (wildcard section 3719 pattern)) is treated the same as 'SORT_BY_ALIGNMENT' (wildcard 3720 section pattern). 3721 5. All other nested section sorting commands are invalid. 3722 3723 When both command line section sorting option and linker script 3724section sorting command are used, section sorting command always takes 3725precedence over the command line option. 3726 3727 If the section sorting command in linker script isn't nested, the 3728command line option will make the section sorting command to be treated 3729as nested sorting command. 3730 3731 1. 'SORT_BY_NAME' (wildcard section pattern ) with '--sort-sections 3732 alignment' is equivalent to 'SORT_BY_NAME' ('SORT_BY_ALIGNMENT' 3733 (wildcard section pattern)). 3734 2. 'SORT_BY_ALIGNMENT' (wildcard section pattern) with '--sort-section 3735 name' is equivalent to 'SORT_BY_ALIGNMENT' ('SORT_BY_NAME' 3736 (wildcard section pattern)). 3737 3738 If the section sorting command in linker script is nested, the 3739command line option will be ignored. 3740 3741 'SORT_NONE' disables section sorting by ignoring the command line 3742section sorting option. 3743 3744 If you ever get confused about where input sections are going, use 3745the '-M' linker option to generate a map file. The map file shows 3746precisely how input sections are mapped to output sections. 3747 3748 This example shows how wildcard patterns might be used to partition 3749files. This linker script directs the linker to place all '.text' 3750sections in '.text' and all '.bss' sections in '.bss'. The linker will 3751place the '.data' section from all files beginning with an upper case 3752character in '.DATA'; for all other files, the linker will place the 3753'.data' section in '.data'. 3754 SECTIONS { 3755 .text : { *(.text) } 3756 .DATA : { [A-Z]*(.data) } 3757 .data : { *(.data) } 3758 .bss : { *(.bss) } 3759 } 3760 3761 3762File: ld.info, Node: Input Section Common, Next: Input Section Keep, Prev: Input Section Wildcards, Up: Input Section 3763 37643.6.4.3 Input Section for Common Symbols 3765........................................ 3766 3767A special notation is needed for common symbols, because in many object 3768file formats common symbols do not have a particular input section. The 3769linker treats common symbols as though they are in an input section 3770named 'COMMON'. 3771 3772 You may use file names with the 'COMMON' section just as with any 3773other input sections. You can use this to place common symbols from a 3774particular input file in one section while common symbols from other 3775input files are placed in another section. 3776 3777 In most cases, common symbols in input files will be placed in the 3778'.bss' section in the output file. For example: 3779 .bss { *(.bss) *(COMMON) } 3780 3781 Some object file formats have more than one type of common symbol. 3782For example, the MIPS ELF object file format distinguishes standard 3783common symbols and small common symbols. In this case, the linker will 3784use a different special section name for other types of common symbols. 3785In the case of MIPS ELF, the linker uses 'COMMON' for standard common 3786symbols and '.scommon' for small common symbols. This permits you to 3787map the different types of common symbols into memory at different 3788locations. 3789 3790 You will sometimes see '[COMMON]' in old linker scripts. This 3791notation is now considered obsolete. It is equivalent to '*(COMMON)'. 3792 3793 3794File: ld.info, Node: Input Section Keep, Next: Input Section Example, Prev: Input Section Common, Up: Input Section 3795 37963.6.4.4 Input Section and Garbage Collection 3797............................................ 3798 3799When link-time garbage collection is in use ('--gc-sections'), it is 3800often useful to mark sections that should not be eliminated. This is 3801accomplished by surrounding an input section's wildcard entry with 3802'KEEP()', as in 'KEEP(*(.init))' or 'KEEP(SORT_BY_NAME(*)(.ctors))'. 3803 3804 3805File: ld.info, Node: Input Section Example, Prev: Input Section Keep, Up: Input Section 3806 38073.6.4.5 Input Section Example 3808............................. 3809 3810The following example is a complete linker script. It tells the linker 3811to read all of the sections from file 'all.o' and place them at the 3812start of output section 'outputa' which starts at location '0x10000'. 3813All of section '.input1' from file 'foo.o' follows immediately, in the 3814same output section. All of section '.input2' from 'foo.o' goes into 3815output section 'outputb', followed by section '.input1' from 'foo1.o'. 3816All of the remaining '.input1' and '.input2' sections from any files are 3817written to output section 'outputc'. 3818 3819 SECTIONS { 3820 outputa 0x10000 : 3821 { 3822 all.o 3823 foo.o (.input1) 3824 } 3825 outputb : 3826 { 3827 foo.o (.input2) 3828 foo1.o (.input1) 3829 } 3830 outputc : 3831 { 3832 *(.input1) 3833 *(.input2) 3834 } 3835 } 3836 3837 If an output section's name is the same as the input section's name 3838and is representable as a C identifier, then the linker will 3839automatically *note PROVIDE:: two symbols: __start_SECNAME and 3840__stop_SECNAME, where SECNAME is the name of the section. These 3841indicate the start address and end address of the output section 3842respectively. Note: most section names are not representable as C 3843identifiers because they contain a '.' character. 3844 3845 3846File: ld.info, Node: Output Section Data, Next: Output Section Keywords, Prev: Input Section, Up: SECTIONS 3847 38483.6.5 Output Section Data 3849------------------------- 3850 3851You can include explicit bytes of data in an output section by using 3852'BYTE', 'SHORT', 'LONG', 'QUAD', or 'SQUAD' as an output section 3853command. Each keyword is followed by an expression in parentheses 3854providing the value to store (*note Expressions::). The value of the 3855expression is stored at the current value of the location counter. 3856 3857 The 'BYTE', 'SHORT', 'LONG', and 'QUAD' commands store one, two, 3858four, and eight bytes (respectively). After storing the bytes, the 3859location counter is incremented by the number of bytes stored. 3860 3861 For example, this will store the byte 1 followed by the four byte 3862value of the symbol 'addr': 3863 BYTE(1) 3864 LONG(addr) 3865 3866 When using a 64 bit host or target, 'QUAD' and 'SQUAD' are the same; 3867they both store an 8 byte, or 64 bit, value. When both host and target 3868are 32 bits, an expression is computed as 32 bits. In this case 'QUAD' 3869stores a 32 bit value zero extended to 64 bits, and 'SQUAD' stores a 32 3870bit value sign extended to 64 bits. 3871 3872 If the object file format of the output file has an explicit 3873endianness, which is the normal case, the value will be stored in that 3874endianness. When the object file format does not have an explicit 3875endianness, as is true of, for example, S-records, the value will be 3876stored in the endianness of the first input object file. 3877 3878 Note--these commands only work inside a section description and not 3879between them, so the following will produce an error from the linker: 3880 SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } } 3881 whereas this will work: 3882 SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } } 3883 3884 You may use the 'FILL' command to set the fill pattern for the 3885current section. It is followed by an expression in parentheses. Any 3886otherwise unspecified regions of memory within the section (for example, 3887gaps left due to the required alignment of input sections) are filled 3888with the value of the expression, repeated as necessary. A 'FILL' 3889statement covers memory locations after the point at which it occurs in 3890the section definition; by including more than one 'FILL' statement, you 3891can have different fill patterns in different parts of an output 3892section. 3893 3894 This example shows how to fill unspecified regions of memory with the 3895value '0x90': 3896 FILL(0x90909090) 3897 3898 The 'FILL' command is similar to the '=FILLEXP' output section 3899attribute, but it only affects the part of the section following the 3900'FILL' command, rather than the entire section. If both are used, the 3901'FILL' command takes precedence. *Note Output Section Fill::, for 3902details on the fill expression. 3903 3904 3905File: ld.info, Node: Output Section Keywords, Next: Output Section Discarding, Prev: Output Section Data, Up: SECTIONS 3906 39073.6.6 Output Section Keywords 3908----------------------------- 3909 3910There are a couple of keywords which can appear as output section 3911commands. 3912 3913'CREATE_OBJECT_SYMBOLS' 3914 The command tells the linker to create a symbol for each input 3915 file. The name of each symbol will be the name of the 3916 corresponding input file. The section of each symbol will be the 3917 output section in which the 'CREATE_OBJECT_SYMBOLS' command 3918 appears. 3919 3920 This is conventional for the a.out object file format. It is not 3921 normally used for any other object file format. 3922 3923'CONSTRUCTORS' 3924 When linking using the a.out object file format, the linker uses an 3925 unusual set construct to support C++ global constructors and 3926 destructors. When linking object file formats which do not support 3927 arbitrary sections, such as ECOFF and XCOFF, the linker will 3928 automatically recognize C++ global constructors and destructors by 3929 name. For these object file formats, the 'CONSTRUCTORS' command 3930 tells the linker to place constructor information in the output 3931 section where the 'CONSTRUCTORS' command appears. The 3932 'CONSTRUCTORS' command is ignored for other object file formats. 3933 3934 The symbol '__CTOR_LIST__' marks the start of the global 3935 constructors, and the symbol '__CTOR_END__' marks the end. 3936 Similarly, '__DTOR_LIST__' and '__DTOR_END__' mark the start and 3937 end of the global destructors. The first word in the list is the 3938 number of entries, followed by the address of each constructor or 3939 destructor, followed by a zero word. The compiler must arrange to 3940 actually run the code. For these object file formats GNU C++ 3941 normally calls constructors from a subroutine '__main'; a call to 3942 '__main' is automatically inserted into the startup code for 3943 'main'. GNU C++ normally runs destructors either by using 3944 'atexit', or directly from the function 'exit'. 3945 3946 For object file formats such as 'COFF' or 'ELF' which support 3947 arbitrary section names, GNU C++ will normally arrange to put the 3948 addresses of global constructors and destructors into the '.ctors' 3949 and '.dtors' sections. Placing the following sequence into your 3950 linker script will build the sort of table which the GNU C++ 3951 runtime code expects to see. 3952 3953 __CTOR_LIST__ = .; 3954 LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 3955 *(.ctors) 3956 LONG(0) 3957 __CTOR_END__ = .; 3958 __DTOR_LIST__ = .; 3959 LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 3960 *(.dtors) 3961 LONG(0) 3962 __DTOR_END__ = .; 3963 3964 If you are using the GNU C++ support for initialization priority, 3965 which provides some control over the order in which global 3966 constructors are run, you must sort the constructors at link time 3967 to ensure that they are executed in the correct order. When using 3968 the 'CONSTRUCTORS' command, use 'SORT_BY_NAME(CONSTRUCTORS)' 3969 instead. When using the '.ctors' and '.dtors' sections, use 3970 '*(SORT_BY_NAME(.ctors))' and '*(SORT_BY_NAME(.dtors))' instead of 3971 just '*(.ctors)' and '*(.dtors)'. 3972 3973 Normally the compiler and linker will handle these issues 3974 automatically, and you will not need to concern yourself with them. 3975 However, you may need to consider this if you are using C++ and 3976 writing your own linker scripts. 3977 3978 3979File: ld.info, Node: Output Section Discarding, Next: Output Section Attributes, Prev: Output Section Keywords, Up: SECTIONS 3980 39813.6.7 Output Section Discarding 3982------------------------------- 3983 3984The linker will not normally create output sections with no contents. 3985This is for convenience when referring to input sections that may or may 3986not be present in any of the input files. For example: 3987 .foo : { *(.foo) } 3988will only create a '.foo' section in the output file if there is a 3989'.foo' section in at least one input file, and if the input sections are 3990not all empty. Other link script directives that allocate space in an 3991output section will also create the output section. So too will 3992assignments to dot even if the assignment does not create space, except 3993for '. = 0', '. = . + 0', '. = sym', '. = . + sym' and '. = ALIGN (. != 39940, expr, 1)' when 'sym' is an absolute symbol of value 0 defined in the 3995script. This allows you to force output of an empty section with '. = 3996.'. 3997 3998 The linker will ignore address assignments (*note Output Section 3999Address::) on discarded output sections, except when the linker script 4000defines symbols in the output section. In that case the linker will 4001obey the address assignments, possibly advancing dot even though the 4002section is discarded. 4003 4004 The special output section name '/DISCARD/' may be used to discard 4005input sections. Any input sections which are assigned to an output 4006section named '/DISCARD/' are not included in the output file. 4007 4008 4009File: ld.info, Node: Output Section Attributes, Next: Overlay Description, Prev: Output Section Discarding, Up: SECTIONS 4010 40113.6.8 Output Section Attributes 4012------------------------------- 4013 4014We showed above that the full description of an output section looked 4015like this: 4016 4017 SECTION [ADDRESS] [(TYPE)] : 4018 [AT(LMA)] 4019 [ALIGN(SECTION_ALIGN)] 4020 [SUBALIGN(SUBSECTION_ALIGN)] 4021 [CONSTRAINT] 4022 { 4023 OUTPUT-SECTION-COMMAND 4024 OUTPUT-SECTION-COMMAND 4025 ... 4026 } [>REGION] [AT>LMA_REGION] [:PHDR :PHDR ...] [=FILLEXP] 4027 4028 We've already described SECTION, ADDRESS, and OUTPUT-SECTION-COMMAND. 4029In this section we will describe the remaining section attributes. 4030 4031* Menu: 4032 4033* Output Section Type:: Output section type 4034* Output Section LMA:: Output section LMA 4035* Forced Output Alignment:: Forced Output Alignment 4036* Forced Input Alignment:: Forced Input Alignment 4037* Output Section Constraint:: Output section constraint 4038* Output Section Region:: Output section region 4039* Output Section Phdr:: Output section phdr 4040* Output Section Fill:: Output section fill 4041 4042 4043File: ld.info, Node: Output Section Type, Next: Output Section LMA, Up: Output Section Attributes 4044 40453.6.8.1 Output Section Type 4046........................... 4047 4048Each output section may have a type. The type is a keyword in 4049parentheses. The following types are defined: 4050 4051'NOLOAD' 4052 The section should be marked as not loadable, so that it will not 4053 be loaded into memory when the program is run. 4054'DSECT' 4055'COPY' 4056'INFO' 4057'OVERLAY' 4058 These type names are supported for backward compatibility, and are 4059 rarely used. They all have the same effect: the section should be 4060 marked as not allocatable, so that no memory is allocated for the 4061 section when the program is run. 4062 4063 The linker normally sets the attributes of an output section based on 4064the input sections which map into it. You can override this by using 4065the section type. For example, in the script sample below, the 'ROM' 4066section is addressed at memory location '0' and does not need to be 4067loaded when the program is run. 4068 SECTIONS { 4069 ROM 0 (NOLOAD) : { ... } 4070 ... 4071 } 4072 4073 4074File: ld.info, Node: Output Section LMA, Next: Forced Output Alignment, Prev: Output Section Type, Up: Output Section Attributes 4075 40763.6.8.2 Output Section LMA 4077.......................... 4078 4079Every section has a virtual address (VMA) and a load address (LMA); see 4080*note Basic Script Concepts::. The virtual address is specified by the 4081*note Output Section Address:: described earlier. The load address is 4082specified by the 'AT' or 'AT>' keywords. Specifying a load address is 4083optional. 4084 4085 The 'AT' keyword takes an expression as an argument. This specifies 4086the exact load address of the section. The 'AT>' keyword takes the name 4087of a memory region as an argument. *Note MEMORY::. The load address of 4088the section is set to the next free address in the region, aligned to 4089the section's alignment requirements. 4090 4091 If neither 'AT' nor 'AT>' is specified for an allocatable section, 4092the linker will use the following heuristic to determine the load 4093address: 4094 4095 * If the section has a specific VMA address, then this is used as the 4096 LMA address as well. 4097 4098 * If the section is not allocatable then its LMA is set to its VMA. 4099 4100 * Otherwise if a memory region can be found that is compatible with 4101 the current section, and this region contains at least one section, 4102 then the LMA is set so the difference between the VMA and LMA is 4103 the same as the difference between the VMA and LMA of the last 4104 section in the located region. 4105 4106 * If no memory regions have been declared then a default region that 4107 covers the entire address space is used in the previous step. 4108 4109 * If no suitable region could be found, or there was no previous 4110 section then the LMA is set equal to the VMA. 4111 4112 This feature is designed to make it easy to build a ROM image. For 4113example, the following linker script creates three output sections: one 4114called '.text', which starts at '0x1000', one called '.mdata', which is 4115loaded at the end of the '.text' section even though its VMA is 4116'0x2000', and one called '.bss' to hold uninitialized data at address 4117'0x3000'. The symbol '_data' is defined with the value '0x2000', which 4118shows that the location counter holds the VMA value, not the LMA value. 4119 4120 SECTIONS 4121 { 4122 .text 0x1000 : { *(.text) _etext = . ; } 4123 .mdata 0x2000 : 4124 AT ( ADDR (.text) + SIZEOF (.text) ) 4125 { _data = . ; *(.data); _edata = . ; } 4126 .bss 0x3000 : 4127 { _bstart = . ; *(.bss) *(COMMON) ; _bend = . ;} 4128 } 4129 4130 The run-time initialization code for use with a program generated 4131with this linker script would include something like the following, to 4132copy the initialized data from the ROM image to its runtime address. 4133Notice how this code takes advantage of the symbols defined by the 4134linker script. 4135 4136 extern char _etext, _data, _edata, _bstart, _bend; 4137 char *src = &_etext; 4138 char *dst = &_data; 4139 4140 /* ROM has data at end of text; copy it. */ 4141 while (dst < &_edata) 4142 *dst++ = *src++; 4143 4144 /* Zero bss. */ 4145 for (dst = &_bstart; dst< &_bend; dst++) 4146 *dst = 0; 4147 4148 4149File: ld.info, Node: Forced Output Alignment, Next: Forced Input Alignment, Prev: Output Section LMA, Up: Output Section Attributes 4150 41513.6.8.3 Forced Output Alignment 4152............................... 4153 4154You can increase an output section's alignment by using ALIGN. As an 4155alternative you can enforce that the difference between the VMA and LMA 4156remains intact throughout this output section with the ALIGN_WITH_INPUT 4157attribute. 4158 4159 4160File: ld.info, Node: Forced Input Alignment, Next: Output Section Constraint, Prev: Forced Output Alignment, Up: Output Section Attributes 4161 41623.6.8.4 Forced Input Alignment 4163.............................. 4164 4165You can force input section alignment within an output section by using 4166SUBALIGN. The value specified overrides any alignment given by input 4167sections, whether larger or smaller. 4168 4169 4170File: ld.info, Node: Output Section Constraint, Next: Output Section Region, Prev: Forced Input Alignment, Up: Output Section Attributes 4171 41723.6.8.5 Output Section Constraint 4173................................. 4174 4175You can specify that an output section should only be created if all of 4176its input sections are read-only or all of its input sections are 4177read-write by using the keyword 'ONLY_IF_RO' and 'ONLY_IF_RW' 4178respectively. 4179 4180 4181File: ld.info, Node: Output Section Region, Next: Output Section Phdr, Prev: Output Section Constraint, Up: Output Section Attributes 4182 41833.6.8.6 Output Section Region 4184............................. 4185 4186You can assign a section to a previously defined region of memory by 4187using '>REGION'. *Note MEMORY::. 4188 4189 Here is a simple example: 4190 MEMORY { rom : ORIGIN = 0x1000, LENGTH = 0x1000 } 4191 SECTIONS { ROM : { *(.text) } >rom } 4192 4193 4194File: ld.info, Node: Output Section Phdr, Next: Output Section Fill, Prev: Output Section Region, Up: Output Section Attributes 4195 41963.6.8.7 Output Section Phdr 4197........................... 4198 4199You can assign a section to a previously defined program segment by 4200using ':PHDR'. *Note PHDRS::. If a section is assigned to one or more 4201segments, then all subsequent allocated sections will be assigned to 4202those segments as well, unless they use an explicitly ':PHDR' modifier. 4203You can use ':NONE' to tell the linker to not put the section in any 4204segment at all. 4205 4206 Here is a simple example: 4207 PHDRS { text PT_LOAD ; } 4208 SECTIONS { .text : { *(.text) } :text } 4209 4210 4211File: ld.info, Node: Output Section Fill, Prev: Output Section Phdr, Up: Output Section Attributes 4212 42133.6.8.8 Output Section Fill 4214........................... 4215 4216You can set the fill pattern for an entire section by using '=FILLEXP'. 4217FILLEXP is an expression (*note Expressions::). Any otherwise 4218unspecified regions of memory within the output section (for example, 4219gaps left due to the required alignment of input sections) will be 4220filled with the value, repeated as necessary. If the fill expression is 4221a simple hex number, ie. a string of hex digit starting with '0x' and 4222without a trailing 'k' or 'M', then an arbitrarily long sequence of hex 4223digits can be used to specify the fill pattern; Leading zeros become 4224part of the pattern too. For all other cases, including extra 4225parentheses or a unary '+', the fill pattern is the four least 4226significant bytes of the value of the expression. In all cases, the 4227number is big-endian. 4228 4229 You can also change the fill value with a 'FILL' command in the 4230output section commands; (*note Output Section Data::). 4231 4232 Here is a simple example: 4233 SECTIONS { .text : { *(.text) } =0x90909090 } 4234 4235 4236File: ld.info, Node: Overlay Description, Prev: Output Section Attributes, Up: SECTIONS 4237 42383.6.9 Overlay Description 4239------------------------- 4240 4241An overlay description provides an easy way to describe sections which 4242are to be loaded as part of a single memory image but are to be run at 4243the same memory address. At run time, some sort of overlay manager will 4244copy the overlaid sections in and out of the runtime memory address as 4245required, perhaps by simply manipulating addressing bits. This approach 4246can be useful, for example, when a certain region of memory is faster 4247than another. 4248 4249 Overlays are described using the 'OVERLAY' command. The 'OVERLAY' 4250command is used within a 'SECTIONS' command, like an output section 4251description. The full syntax of the 'OVERLAY' command is as follows: 4252 OVERLAY [START] : [NOCROSSREFS] [AT ( LDADDR )] 4253 { 4254 SECNAME1 4255 { 4256 OUTPUT-SECTION-COMMAND 4257 OUTPUT-SECTION-COMMAND 4258 ... 4259 } [:PHDR...] [=FILL] 4260 SECNAME2 4261 { 4262 OUTPUT-SECTION-COMMAND 4263 OUTPUT-SECTION-COMMAND 4264 ... 4265 } [:PHDR...] [=FILL] 4266 ... 4267 } [>REGION] [:PHDR...] [=FILL] [,] 4268 4269 Everything is optional except 'OVERLAY' (a keyword), and each section 4270must have a name (SECNAME1 and SECNAME2 above). The section definitions 4271within the 'OVERLAY' construct are identical to those within the general 4272'SECTIONS' construct (*note SECTIONS::), except that no addresses and no 4273memory regions may be defined for sections within an 'OVERLAY'. 4274 4275 The comma at the end may be required if a FILL is used and the next 4276SECTIONS-COMMAND looks like a continuation of the expression. 4277 4278 The sections are all defined with the same starting address. The 4279load addresses of the sections are arranged such that they are 4280consecutive in memory starting at the load address used for the 4281'OVERLAY' as a whole (as with normal section definitions, the load 4282address is optional, and defaults to the start address; the start 4283address is also optional, and defaults to the current value of the 4284location counter). 4285 4286 If the 'NOCROSSREFS' keyword is used, and there are any references 4287among the sections, the linker will report an error. Since the sections 4288all run at the same address, it normally does not make sense for one 4289section to refer directly to another. *Note NOCROSSREFS: Miscellaneous 4290Commands. 4291 4292 For each section within the 'OVERLAY', the linker automatically 4293provides two symbols. The symbol '__load_start_SECNAME' is defined as 4294the starting load address of the section. The symbol 4295'__load_stop_SECNAME' is defined as the final load address of the 4296section. Any characters within SECNAME which are not legal within C 4297identifiers are removed. C (or assembler) code may use these symbols to 4298move the overlaid sections around as necessary. 4299 4300 At the end of the overlay, the value of the location counter is set 4301to the start address of the overlay plus the size of the largest 4302section. 4303 4304 Here is an example. Remember that this would appear inside a 4305'SECTIONS' construct. 4306 OVERLAY 0x1000 : AT (0x4000) 4307 { 4308 .text0 { o1/*.o(.text) } 4309 .text1 { o2/*.o(.text) } 4310 } 4311This will define both '.text0' and '.text1' to start at address 0x1000. 4312'.text0' will be loaded at address 0x4000, and '.text1' will be loaded 4313immediately after '.text0'. The following symbols will be defined if 4314referenced: '__load_start_text0', '__load_stop_text0', 4315'__load_start_text1', '__load_stop_text1'. 4316 4317 C code to copy overlay '.text1' into the overlay area might look like 4318the following. 4319 4320 extern char __load_start_text1, __load_stop_text1; 4321 memcpy ((char *) 0x1000, &__load_start_text1, 4322 &__load_stop_text1 - &__load_start_text1); 4323 4324 Note that the 'OVERLAY' command is just syntactic sugar, since 4325everything it does can be done using the more basic commands. The above 4326example could have been written identically as follows. 4327 4328 .text0 0x1000 : AT (0x4000) { o1/*.o(.text) } 4329 PROVIDE (__load_start_text0 = LOADADDR (.text0)); 4330 PROVIDE (__load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0)); 4331 .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) } 4332 PROVIDE (__load_start_text1 = LOADADDR (.text1)); 4333 PROVIDE (__load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1)); 4334 . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1)); 4335 4336 4337File: ld.info, Node: MEMORY, Next: PHDRS, Prev: SECTIONS, Up: Scripts 4338 43393.7 MEMORY Command 4340================== 4341 4342The linker's default configuration permits allocation of all available 4343memory. You can override this by using the 'MEMORY' command. 4344 4345 The 'MEMORY' command describes the location and size of blocks of 4346memory in the target. You can use it to describe which memory regions 4347may be used by the linker, and which memory regions it must avoid. You 4348can then assign sections to particular memory regions. The linker will 4349set section addresses based on the memory regions, and will warn about 4350regions that become too full. The linker will not shuffle sections 4351around to fit into the available regions. 4352 4353 A linker script may contain many uses of the 'MEMORY' command, 4354however, all memory blocks defined are treated as if they were specified 4355inside a single 'MEMORY' command. The syntax for 'MEMORY' is: 4356 MEMORY 4357 { 4358 NAME [(ATTR)] : ORIGIN = ORIGIN, LENGTH = LEN 4359 ... 4360 } 4361 4362 The NAME is a name used in the linker script to refer to the region. 4363The region name has no meaning outside of the linker script. Region 4364names are stored in a separate name space, and will not conflict with 4365symbol names, file names, or section names. Each memory region must 4366have a distinct name within the 'MEMORY' command. However you can add 4367later alias names to existing memory regions with the *note 4368REGION_ALIAS:: command. 4369 4370 The ATTR string is an optional list of attributes that specify 4371whether to use a particular memory region for an input section which is 4372not explicitly mapped in the linker script. As described in *note 4373SECTIONS::, if you do not specify an output section for some input 4374section, the linker will create an output section with the same name as 4375the input section. If you define region attributes, the linker will use 4376them to select the memory region for the output section that it creates. 4377 4378 The ATTR string must consist only of the following characters: 4379'R' 4380 Read-only section 4381'W' 4382 Read/write section 4383'X' 4384 Executable section 4385'A' 4386 Allocatable section 4387'I' 4388 Initialized section 4389'L' 4390 Same as 'I' 4391'!' 4392 Invert the sense of any of the attributes that follow 4393 4394 If a unmapped section matches any of the listed attributes other than 4395'!', it will be placed in the memory region. The '!' attribute reverses 4396this test, so that an unmapped section will be placed in the memory 4397region only if it does not match any of the listed attributes. 4398 4399 The ORIGIN is an numerical expression for the start address of the 4400memory region. The expression must evaluate to a constant and it cannot 4401involve any symbols. The keyword 'ORIGIN' may be abbreviated to 'org' 4402or 'o' (but not, for example, 'ORG'). 4403 4404 The LEN is an expression for the size in bytes of the memory region. 4405As with the ORIGIN expression, the expression must be numerical only and 4406must evaluate to a constant. The keyword 'LENGTH' may be abbreviated to 4407'len' or 'l'. 4408 4409 In the following example, we specify that there are two memory 4410regions available for allocation: one starting at '0' for 256 kilobytes, 4411and the other starting at '0x40000000' for four megabytes. The linker 4412will place into the 'rom' memory region every section which is not 4413explicitly mapped into a memory region, and is either read-only or 4414executable. The linker will place other sections which are not 4415explicitly mapped into a memory region into the 'ram' memory region. 4416 4417 MEMORY 4418 { 4419 rom (rx) : ORIGIN = 0, LENGTH = 256K 4420 ram (!rx) : org = 0x40000000, l = 4M 4421 } 4422 4423 Once you define a memory region, you can direct the linker to place 4424specific output sections into that memory region by using the '>REGION' 4425output section attribute. For example, if you have a memory region 4426named 'mem', you would use '>mem' in the output section definition. 4427*Note Output Section Region::. If no address was specified for the 4428output section, the linker will set the address to the next available 4429address within the memory region. If the combined output sections 4430directed to a memory region are too large for the region, the linker 4431will issue an error message. 4432 4433 It is possible to access the origin and length of a memory in an 4434expression via the 'ORIGIN(MEMORY)' and 'LENGTH(MEMORY)' functions: 4435 4436 _fstack = ORIGIN(ram) + LENGTH(ram) - 4; 4437 4438 4439File: ld.info, Node: PHDRS, Next: VERSION, Prev: MEMORY, Up: Scripts 4440 44413.8 PHDRS Command 4442================= 4443 4444The ELF object file format uses "program headers", also knows as 4445"segments". The program headers describe how the program should be 4446loaded into memory. You can print them out by using the 'objdump' 4447program with the '-p' option. 4448 4449 When you run an ELF program on a native ELF system, the system loader 4450reads the program headers in order to figure out how to load the 4451program. This will only work if the program headers are set correctly. 4452This manual does not describe the details of how the system loader 4453interprets program headers; for more information, see the ELF ABI. 4454 4455 The linker will create reasonable program headers by default. 4456However, in some cases, you may need to specify the program headers more 4457precisely. You may use the 'PHDRS' command for this purpose. When the 4458linker sees the 'PHDRS' command in the linker script, it will not create 4459any program headers other than the ones specified. 4460 4461 The linker only pays attention to the 'PHDRS' command when generating 4462an ELF output file. In other cases, the linker will simply ignore 4463'PHDRS'. 4464 4465 This is the syntax of the 'PHDRS' command. The words 'PHDRS', 4466'FILEHDR', 'AT', and 'FLAGS' are keywords. 4467 4468 PHDRS 4469 { 4470 NAME TYPE [ FILEHDR ] [ PHDRS ] [ AT ( ADDRESS ) ] 4471 [ FLAGS ( FLAGS ) ] ; 4472 } 4473 4474 The NAME is used only for reference in the 'SECTIONS' command of the 4475linker script. It is not put into the output file. Program header 4476names are stored in a separate name space, and will not conflict with 4477symbol names, file names, or section names. Each program header must 4478have a distinct name. The headers are processed in order and it is 4479usual for them to map to sections in ascending load address order. 4480 4481 Certain program header types describe segments of memory which the 4482system loader will load from the file. In the linker script, you 4483specify the contents of these segments by placing allocatable output 4484sections in the segments. You use the ':PHDR' output section attribute 4485to place a section in a particular segment. *Note Output Section 4486Phdr::. 4487 4488 It is normal to put certain sections in more than one segment. This 4489merely implies that one segment of memory contains another. You may 4490repeat ':PHDR', using it once for each segment which should contain the 4491section. 4492 4493 If you place a section in one or more segments using ':PHDR', then 4494the linker will place all subsequent allocatable sections which do not 4495specify ':PHDR' in the same segments. This is for convenience, since 4496generally a whole set of contiguous sections will be placed in a single 4497segment. You can use ':NONE' to override the default segment and tell 4498the linker to not put the section in any segment at all. 4499 4500 You may use the 'FILEHDR' and 'PHDRS' keywords after the program 4501header type to further describe the contents of the segment. The 4502'FILEHDR' keyword means that the segment should include the ELF file 4503header. The 'PHDRS' keyword means that the segment should include the 4504ELF program headers themselves. If applied to a loadable segment 4505('PT_LOAD'), all prior loadable segments must have one of these 4506keywords. 4507 4508 The TYPE may be one of the following. The numbers indicate the value 4509of the keyword. 4510 4511'PT_NULL' (0) 4512 Indicates an unused program header. 4513 4514'PT_LOAD' (1) 4515 Indicates that this program header describes a segment to be loaded 4516 from the file. 4517 4518'PT_DYNAMIC' (2) 4519 Indicates a segment where dynamic linking information can be found. 4520 4521'PT_INTERP' (3) 4522 Indicates a segment where the name of the program interpreter may 4523 be found. 4524 4525'PT_NOTE' (4) 4526 Indicates a segment holding note information. 4527 4528'PT_SHLIB' (5) 4529 A reserved program header type, defined but not specified by the 4530 ELF ABI. 4531 4532'PT_PHDR' (6) 4533 Indicates a segment where the program headers may be found. 4534 4535'PT_TLS' (7) 4536 Indicates a segment containing thread local storage. 4537 4538EXPRESSION 4539 An expression giving the numeric type of the program header. This 4540 may be used for types not defined above. 4541 4542 You can specify that a segment should be loaded at a particular 4543address in memory by using an 'AT' expression. This is identical to the 4544'AT' command used as an output section attribute (*note Output Section 4545LMA::). The 'AT' command for a program header overrides the output 4546section attribute. 4547 4548 The linker will normally set the segment flags based on the sections 4549which comprise the segment. You may use the 'FLAGS' keyword to 4550explicitly specify the segment flags. The value of FLAGS must be an 4551integer. It is used to set the 'p_flags' field of the program header. 4552 4553 Here is an example of 'PHDRS'. This shows a typical set of program 4554headers used on a native ELF system. 4555 4556 PHDRS 4557 { 4558 headers PT_PHDR PHDRS ; 4559 interp PT_INTERP ; 4560 text PT_LOAD FILEHDR PHDRS ; 4561 data PT_LOAD ; 4562 dynamic PT_DYNAMIC ; 4563 } 4564 4565 SECTIONS 4566 { 4567 . = SIZEOF_HEADERS; 4568 .interp : { *(.interp) } :text :interp 4569 .text : { *(.text) } :text 4570 .rodata : { *(.rodata) } /* defaults to :text */ 4571 ... 4572 . = . + 0x1000; /* move to a new page in memory */ 4573 .data : { *(.data) } :data 4574 .dynamic : { *(.dynamic) } :data :dynamic 4575 ... 4576 } 4577 4578 4579File: ld.info, Node: VERSION, Next: Expressions, Prev: PHDRS, Up: Scripts 4580 45813.9 VERSION Command 4582=================== 4583 4584The linker supports symbol versions when using ELF. Symbol versions are 4585only useful when using shared libraries. The dynamic linker can use 4586symbol versions to select a specific version of a function when it runs 4587a program that may have been linked against an earlier version of the 4588shared library. 4589 4590 You can include a version script directly in the main linker script, 4591or you can supply the version script as an implicit linker script. You 4592can also use the '--version-script' linker option. 4593 4594 The syntax of the 'VERSION' command is simply 4595 VERSION { version-script-commands } 4596 4597 The format of the version script commands is identical to that used 4598by Sun's linker in Solaris 2.5. The version script defines a tree of 4599version nodes. You specify the node names and interdependencies in the 4600version script. You can specify which symbols are bound to which 4601version nodes, and you can reduce a specified set of symbols to local 4602scope so that they are not globally visible outside of the shared 4603library. 4604 4605 The easiest way to demonstrate the version script language is with a 4606few examples. 4607 4608 VERS_1.1 { 4609 global: 4610 foo1; 4611 local: 4612 old*; 4613 original*; 4614 new*; 4615 }; 4616 4617 VERS_1.2 { 4618 foo2; 4619 } VERS_1.1; 4620 4621 VERS_2.0 { 4622 bar1; bar2; 4623 extern "C++" { 4624 ns::*; 4625 "f(int, double)"; 4626 }; 4627 } VERS_1.2; 4628 4629 This example version script defines three version nodes. The first 4630version node defined is 'VERS_1.1'; it has no other dependencies. The 4631script binds the symbol 'foo1' to 'VERS_1.1'. It reduces a number of 4632symbols to local scope so that they are not visible outside of the 4633shared library; this is done using wildcard patterns, so that any symbol 4634whose name begins with 'old', 'original', or 'new' is matched. The 4635wildcard patterns available are the same as those used in the shell when 4636matching filenames (also known as "globbing"). However, if you specify 4637the symbol name inside double quotes, then the name is treated as 4638literal, rather than as a glob pattern. 4639 4640 Next, the version script defines node 'VERS_1.2'. This node depends 4641upon 'VERS_1.1'. The script binds the symbol 'foo2' to the version node 4642'VERS_1.2'. 4643 4644 Finally, the version script defines node 'VERS_2.0'. This node 4645depends upon 'VERS_1.2'. The scripts binds the symbols 'bar1' and 4646'bar2' are bound to the version node 'VERS_2.0'. 4647 4648 When the linker finds a symbol defined in a library which is not 4649specifically bound to a version node, it will effectively bind it to an 4650unspecified base version of the library. You can bind all otherwise 4651unspecified symbols to a given version node by using 'global: *;' 4652somewhere in the version script. Note that it's slightly crazy to use 4653wildcards in a global spec except on the last version node. Global 4654wildcards elsewhere run the risk of accidentally adding symbols to the 4655set exported for an old version. That's wrong since older versions 4656ought to have a fixed set of symbols. 4657 4658 The names of the version nodes have no specific meaning other than 4659what they might suggest to the person reading them. The '2.0' version 4660could just as well have appeared in between '1.1' and '1.2'. However, 4661this would be a confusing way to write a version script. 4662 4663 Node name can be omitted, provided it is the only version node in the 4664version script. Such version script doesn't assign any versions to 4665symbols, only selects which symbols will be globally visible out and 4666which won't. 4667 4668 { global: foo; bar; local: *; }; 4669 4670 When you link an application against a shared library that has 4671versioned symbols, the application itself knows which version of each 4672symbol it requires, and it also knows which version nodes it needs from 4673each shared library it is linked against. Thus at runtime, the dynamic 4674loader can make a quick check to make sure that the libraries you have 4675linked against do in fact supply all of the version nodes that the 4676application will need to resolve all of the dynamic symbols. In this 4677way it is possible for the dynamic linker to know with certainty that 4678all external symbols that it needs will be resolvable without having to 4679search for each symbol reference. 4680 4681 The symbol versioning is in effect a much more sophisticated way of 4682doing minor version checking that SunOS does. The fundamental problem 4683that is being addressed here is that typically references to external 4684functions are bound on an as-needed basis, and are not all bound when 4685the application starts up. If a shared library is out of date, a 4686required interface may be missing; when the application tries to use 4687that interface, it may suddenly and unexpectedly fail. With symbol 4688versioning, the user will get a warning when they start their program if 4689the libraries being used with the application are too old. 4690 4691 There are several GNU extensions to Sun's versioning approach. The 4692first of these is the ability to bind a symbol to a version node in the 4693source file where the symbol is defined instead of in the versioning 4694script. This was done mainly to reduce the burden on the library 4695maintainer. You can do this by putting something like: 4696 __asm__(".symver original_foo,foo@VERS_1.1"); 4697in the C source file. This renames the function 'original_foo' to be an 4698alias for 'foo' bound to the version node 'VERS_1.1'. The 'local:' 4699directive can be used to prevent the symbol 'original_foo' from being 4700exported. A '.symver' directive takes precedence over a version script. 4701 4702 The second GNU extension is to allow multiple versions of the same 4703function to appear in a given shared library. In this way you can make 4704an incompatible change to an interface without increasing the major 4705version number of the shared library, while still allowing applications 4706linked against the old interface to continue to function. 4707 4708 To do this, you must use multiple '.symver' directives in the source 4709file. Here is an example: 4710 4711 __asm__(".symver original_foo,foo@"); 4712 __asm__(".symver old_foo,foo@VERS_1.1"); 4713 __asm__(".symver old_foo1,foo@VERS_1.2"); 4714 __asm__(".symver new_foo,foo@@VERS_2.0"); 4715 4716 In this example, 'foo@' represents the symbol 'foo' bound to the 4717unspecified base version of the symbol. The source file that contains 4718this example would define 4 C functions: 'original_foo', 'old_foo', 4719'old_foo1', and 'new_foo'. 4720 4721 When you have multiple definitions of a given symbol, there needs to 4722be some way to specify a default version to which external references to 4723this symbol will be bound. You can do this with the 'foo@@VERS_2.0' 4724type of '.symver' directive. You can only declare one version of a 4725symbol as the default in this manner; otherwise you would effectively 4726have multiple definitions of the same symbol. 4727 4728 If you wish to bind a reference to a specific version of the symbol 4729within the shared library, you can use the aliases of convenience (i.e., 4730'old_foo'), or you can use the '.symver' directive to specifically bind 4731to an external version of the function in question. 4732 4733 You can also specify the language in the version script: 4734 4735 VERSION extern "lang" { version-script-commands } 4736 4737 The supported 'lang's are 'C', 'C++', and 'Java'. The linker will 4738iterate over the list of symbols at the link time and demangle them 4739according to 'lang' before matching them to the patterns specified in 4740'version-script-commands'. The default 'lang' is 'C'. 4741 4742 Demangled names may contains spaces and other special characters. As 4743described above, you can use a glob pattern to match demangled names, or 4744you can use a double-quoted string to match the string exactly. In the 4745latter case, be aware that minor differences (such as differing 4746whitespace) between the version script and the demangler output will 4747cause a mismatch. As the exact string generated by the demangler might 4748change in the future, even if the mangled name does not, you should 4749check that all of your version directives are behaving as you expect 4750when you upgrade. 4751 4752 4753File: ld.info, Node: Expressions, Next: Implicit Linker Scripts, Prev: VERSION, Up: Scripts 4754 47553.10 Expressions in Linker Scripts 4756================================== 4757 4758The syntax for expressions in the linker script language is identical to 4759that of C expressions. All expressions are evaluated as integers. All 4760expressions are evaluated in the same size, which is 32 bits if both the 4761host and target are 32 bits, and is otherwise 64 bits. 4762 4763 You can use and set symbol values in expressions. 4764 4765 The linker defines several special purpose builtin functions for use 4766in expressions. 4767 4768* Menu: 4769 4770* Constants:: Constants 4771* Symbolic Constants:: Symbolic constants 4772* Symbols:: Symbol Names 4773* Orphan Sections:: Orphan Sections 4774* Location Counter:: The Location Counter 4775* Operators:: Operators 4776* Evaluation:: Evaluation 4777* Expression Section:: The Section of an Expression 4778* Builtin Functions:: Builtin Functions 4779 4780 4781File: ld.info, Node: Constants, Next: Symbolic Constants, Up: Expressions 4782 47833.10.1 Constants 4784---------------- 4785 4786All constants are integers. 4787 4788 As in C, the linker considers an integer beginning with '0' to be 4789octal, and an integer beginning with '0x' or '0X' to be hexadecimal. 4790Alternatively the linker accepts suffixes of 'h' or 'H' for hexadecimal, 4791'o' or 'O' for octal, 'b' or 'B' for binary and 'd' or 'D' for decimal. 4792Any integer value without a prefix or a suffix is considered to be 4793decimal. 4794 4795 In addition, you can use the suffixes 'K' and 'M' to scale a constant 4796by '1024' or '1024*1024' respectively. For example, the following all 4797refer to the same quantity: 4798 4799 _fourk_1 = 4K; 4800 _fourk_2 = 4096; 4801 _fourk_3 = 0x1000; 4802 _fourk_4 = 10000o; 4803 4804 Note - the 'K' and 'M' suffixes cannot be used in conjunction with 4805the base suffixes mentioned above. 4806 4807 4808File: ld.info, Node: Symbolic Constants, Next: Symbols, Prev: Constants, Up: Expressions 4809 48103.10.2 Symbolic Constants 4811------------------------- 4812 4813It is possible to refer to target specific constants via the use of the 4814'CONSTANT(NAME)' operator, where NAME is one of: 4815 4816'MAXPAGESIZE' 4817 The target's maximum page size. 4818 4819'COMMONPAGESIZE' 4820 The target's default page size. 4821 4822 So for example: 4823 4824 .text ALIGN (CONSTANT (MAXPAGESIZE)) : { *(.text) } 4825 4826 will create a text section aligned to the largest page boundary 4827supported by the target. 4828 4829 4830File: ld.info, Node: Symbols, Next: Orphan Sections, Prev: Symbolic Constants, Up: Expressions 4831 48323.10.3 Symbol Names 4833------------------- 4834 4835Unless quoted, symbol names start with a letter, underscore, or period 4836and may include letters, digits, underscores, periods, and hyphens. 4837Unquoted symbol names must not conflict with any keywords. You can 4838specify a symbol which contains odd characters or has the same name as a 4839keyword by surrounding the symbol name in double quotes: 4840 "SECTION" = 9; 4841 "with a space" = "also with a space" + 10; 4842 4843 Since symbols can contain many non-alphabetic characters, it is 4844safest to delimit symbols with spaces. For example, 'A-B' is one 4845symbol, whereas 'A - B' is an expression involving subtraction. 4846 4847 4848File: ld.info, Node: Orphan Sections, Next: Location Counter, Prev: Symbols, Up: Expressions 4849 48503.10.4 Orphan Sections 4851---------------------- 4852 4853Orphan sections are sections present in the input files which are not 4854explicitly placed into the output file by the linker script. The linker 4855will still copy these sections into the output file by either finding, 4856or creating a suitable output section in which to place the orphaned 4857input section. 4858 4859 If the name of an orphaned input section exactly matches the name of 4860an existing output section, then the orphaned input section will be 4861placed at the end of that output section. 4862 4863 If there is no output section with a matching name then new output 4864sections will be created. Each new output section will have the same 4865name as the orphan section placed within it. If there are multiple 4866orphan sections with the same name, these will all be combined into one 4867new output section. 4868 4869 If new output sections are created to hold orphaned input sections, 4870then the linker must decide where to place these new output sections in 4871relation to existing output sections. On most modern targets, the 4872linker attempts to place orphan sections after sections of the same 4873attribute, such as code vs data, loadable vs non-loadable, etc. If no 4874sections with matching attributes are found, or your target lacks this 4875support, the orphan section is placed at the end of the file. 4876 4877 The command line options '--orphan-handling' and '--unique' (*note 4878Command Line Options: Options.) can be used to control which output 4879sections an orphan is placed in. 4880 4881 4882File: ld.info, Node: Location Counter, Next: Operators, Prev: Orphan Sections, Up: Expressions 4883 48843.10.5 The Location Counter 4885--------------------------- 4886 4887The special linker variable "dot" '.' always contains the current output 4888location counter. Since the '.' always refers to a location in an 4889output section, it may only appear in an expression within a 'SECTIONS' 4890command. The '.' symbol may appear anywhere that an ordinary symbol is 4891allowed in an expression. 4892 4893 Assigning a value to '.' will cause the location counter to be moved. 4894This may be used to create holes in the output section. The location 4895counter may not be moved backwards inside an output section, and may not 4896be moved backwards outside of an output section if so doing creates 4897areas with overlapping LMAs. 4898 4899 SECTIONS 4900 { 4901 output : 4902 { 4903 file1(.text) 4904 . = . + 1000; 4905 file2(.text) 4906 . += 1000; 4907 file3(.text) 4908 } = 0x12345678; 4909 } 4910In the previous example, the '.text' section from 'file1' is located at 4911the beginning of the output section 'output'. It is followed by a 1000 4912byte gap. Then the '.text' section from 'file2' appears, also with a 49131000 byte gap following before the '.text' section from 'file3'. The 4914notation '= 0x12345678' specifies what data to write in the gaps (*note 4915Output Section Fill::). 4916 4917 Note: '.' actually refers to the byte offset from the start of the 4918current containing object. Normally this is the 'SECTIONS' statement, 4919whose start address is 0, hence '.' can be used as an absolute address. 4920If '.' is used inside a section description however, it refers to the 4921byte offset from the start of that section, not an absolute address. 4922Thus in a script like this: 4923 4924 SECTIONS 4925 { 4926 . = 0x100 4927 .text: { 4928 *(.text) 4929 . = 0x200 4930 } 4931 . = 0x500 4932 .data: { 4933 *(.data) 4934 . += 0x600 4935 } 4936 } 4937 4938 The '.text' section will be assigned a starting address of 0x100 and 4939a size of exactly 0x200 bytes, even if there is not enough data in the 4940'.text' input sections to fill this area. (If there is too much data, 4941an error will be produced because this would be an attempt to move '.' 4942backwards). The '.data' section will start at 0x500 and it will have an 4943extra 0x600 bytes worth of space after the end of the values from the 4944'.data' input sections and before the end of the '.data' output section 4945itself. 4946 4947 Setting symbols to the value of the location counter outside of an 4948output section statement can result in unexpected values if the linker 4949needs to place orphan sections. For example, given the following: 4950 4951 SECTIONS 4952 { 4953 start_of_text = . ; 4954 .text: { *(.text) } 4955 end_of_text = . ; 4956 4957 start_of_data = . ; 4958 .data: { *(.data) } 4959 end_of_data = . ; 4960 } 4961 4962 If the linker needs to place some input section, e.g. '.rodata', not 4963mentioned in the script, it might choose to place that section between 4964'.text' and '.data'. You might think the linker should place '.rodata' 4965on the blank line in the above script, but blank lines are of no 4966particular significance to the linker. As well, the linker doesn't 4967associate the above symbol names with their sections. Instead, it 4968assumes that all assignments or other statements belong to the previous 4969output section, except for the special case of an assignment to '.'. 4970I.e., the linker will place the orphan '.rodata' section as if the 4971script was written as follows: 4972 4973 SECTIONS 4974 { 4975 start_of_text = . ; 4976 .text: { *(.text) } 4977 end_of_text = . ; 4978 4979 start_of_data = . ; 4980 .rodata: { *(.rodata) } 4981 .data: { *(.data) } 4982 end_of_data = . ; 4983 } 4984 4985 This may or may not be the script author's intention for the value of 4986'start_of_data'. One way to influence the orphan section placement is 4987to assign the location counter to itself, as the linker assumes that an 4988assignment to '.' is setting the start address of a following output 4989section and thus should be grouped with that section. So you could 4990write: 4991 4992 SECTIONS 4993 { 4994 start_of_text = . ; 4995 .text: { *(.text) } 4996 end_of_text = . ; 4997 4998 . = . ; 4999 start_of_data = . ; 5000 .data: { *(.data) } 5001 end_of_data = . ; 5002 } 5003 5004 Now, the orphan '.rodata' section will be placed between 5005'end_of_text' and 'start_of_data'. 5006 5007 5008File: ld.info, Node: Operators, Next: Evaluation, Prev: Location Counter, Up: Expressions 5009 50103.10.6 Operators 5011---------------- 5012 5013The linker recognizes the standard C set of arithmetic operators, with 5014the standard bindings and precedence levels: 5015 precedence associativity Operators Notes 5016 (highest) 5017 1 left ! - ~ (1) 5018 2 left * / % 5019 3 left + - 5020 4 left >> << 5021 5 left == != > < <= >= 5022 6 left & 5023 7 left | 5024 8 left && 5025 9 left || 5026 10 right ? : 5027 11 right &= += -= *= /= (2) 5028 (lowest) 5029 Notes: (1) Prefix operators (2) *Note Assignments::. 5030 5031 5032File: ld.info, Node: Evaluation, Next: Expression Section, Prev: Operators, Up: Expressions 5033 50343.10.7 Evaluation 5035----------------- 5036 5037The linker evaluates expressions lazily. It only computes the value of 5038an expression when absolutely necessary. 5039 5040 The linker needs some information, such as the value of the start 5041address of the first section, and the origins and lengths of memory 5042regions, in order to do any linking at all. These values are computed 5043as soon as possible when the linker reads in the linker script. 5044 5045 However, other values (such as symbol values) are not known or needed 5046until after storage allocation. Such values are evaluated later, when 5047other information (such as the sizes of output sections) is available 5048for use in the symbol assignment expression. 5049 5050 The sizes of sections cannot be known until after allocation, so 5051assignments dependent upon these are not performed until after 5052allocation. 5053 5054 Some expressions, such as those depending upon the location counter 5055'.', must be evaluated during section allocation. 5056 5057 If the result of an expression is required, but the value is not 5058available, then an error results. For example, a script like the 5059following 5060 SECTIONS 5061 { 5062 .text 9+this_isnt_constant : 5063 { *(.text) } 5064 } 5065will cause the error message 'non constant expression for initial 5066address'. 5067 5068 5069File: ld.info, Node: Expression Section, Next: Builtin Functions, Prev: Evaluation, Up: Expressions 5070 50713.10.8 The Section of an Expression 5072----------------------------------- 5073 5074Addresses and symbols may be section relative, or absolute. A section 5075relative symbol is relocatable. If you request relocatable output using 5076the '-r' option, a further link operation may change the value of a 5077section relative symbol. On the other hand, an absolute symbol will 5078retain the same value throughout any further link operations. 5079 5080 Some terms in linker expressions are addresses. This is true of 5081section relative symbols and for builtin functions that return an 5082address, such as 'ADDR', 'LOADADDR', 'ORIGIN' and 'SEGMENT_START'. 5083Other terms are simply numbers, or are builtin functions that return a 5084non-address value, such as 'LENGTH'. One complication is that unless 5085you set 'LD_FEATURE ("SANE_EXPR")' (*note Miscellaneous Commands::), 5086numbers and absolute symbols are treated differently depending on their 5087location, for compatibility with older versions of 'ld'. Expressions 5088appearing outside an output section definition treat all numbers as 5089absolute addresses. Expressions appearing inside an output section 5090definition treat absolute symbols as numbers. If 'LD_FEATURE 5091("SANE_EXPR")' is given, then absolute symbols and numbers are simply 5092treated as numbers everywhere. 5093 5094 In the following simple example, 5095 5096 SECTIONS 5097 { 5098 . = 0x100; 5099 __executable_start = 0x100; 5100 .data : 5101 { 5102 . = 0x10; 5103 __data_start = 0x10; 5104 *(.data) 5105 } 5106 ... 5107 } 5108 5109 both '.' and '__executable_start' are set to the absolute address 51100x100 in the first two assignments, then both '.' and '__data_start' are 5111set to 0x10 relative to the '.data' section in the second two 5112assignments. 5113 5114 For expressions involving numbers, relative addresses and absolute 5115addresses, ld follows these rules to evaluate terms: 5116 5117 * Unary operations on an absolute address or number, and binary 5118 operations on two absolute addresses or two numbers, or between one 5119 absolute address and a number, apply the operator to the value(s). 5120 * Unary operations on a relative address, and binary operations on 5121 two relative addresses in the same section or between one relative 5122 address and a number, apply the operator to the offset part of the 5123 address(es). 5124 * Other binary operations, that is, between two relative addresses 5125 not in the same section, or between a relative address and an 5126 absolute address, first convert any non-absolute term to an 5127 absolute address before applying the operator. 5128 5129 The result section of each sub-expression is as follows: 5130 5131 * An operation involving only numbers results in a number. 5132 * The result of comparisons, '&&' and '||' is also a number. 5133 * The result of other binary arithmetic and logical operations on two 5134 relative addresses in the same section or two absolute addresses 5135 (after above conversions) is also a number when 'LD_FEATURE 5136 ("SANE_EXPR")' or inside an output section definition but an 5137 absolute address otherwise. 5138 * The result of other operations on relative addresses or one 5139 relative address and a number, is a relative address in the same 5140 section as the relative operand(s). 5141 * The result of other operations on absolute addresses (after above 5142 conversions) is an absolute address. 5143 5144 You can use the builtin function 'ABSOLUTE' to force an expression to 5145be absolute when it would otherwise be relative. For example, to create 5146an absolute symbol set to the address of the end of the output section 5147'.data': 5148 SECTIONS 5149 { 5150 .data : { *(.data) _edata = ABSOLUTE(.); } 5151 } 5152If 'ABSOLUTE' were not used, '_edata' would be relative to the '.data' 5153section. 5154 5155 Using 'LOADADDR' also forces an expression absolute, since this 5156particular builtin function returns an absolute address. 5157 5158 5159File: ld.info, Node: Builtin Functions, Prev: Expression Section, Up: Expressions 5160 51613.10.9 Builtin Functions 5162------------------------ 5163 5164The linker script language includes a number of builtin functions for 5165use in linker script expressions. 5166 5167'ABSOLUTE(EXP)' 5168 Return the absolute (non-relocatable, as opposed to non-negative) 5169 value of the expression EXP. Primarily useful to assign an 5170 absolute value to a symbol within a section definition, where 5171 symbol values are normally section relative. *Note Expression 5172 Section::. 5173 5174'ADDR(SECTION)' 5175 Return the address (VMA) of the named SECTION. Your script must 5176 previously have defined the location of that section. In the 5177 following example, 'start_of_output_1', 'symbol_1' and 'symbol_2' 5178 are assigned equivalent values, except that 'symbol_1' will be 5179 relative to the '.output1' section while the other two will be 5180 absolute: 5181 SECTIONS { ... 5182 .output1 : 5183 { 5184 start_of_output_1 = ABSOLUTE(.); 5185 ... 5186 } 5187 .output : 5188 { 5189 symbol_1 = ADDR(.output1); 5190 symbol_2 = start_of_output_1; 5191 } 5192 ... } 5193 5194'ALIGN(ALIGN)' 5195'ALIGN(EXP,ALIGN)' 5196 Return the location counter ('.') or arbitrary expression aligned 5197 to the next ALIGN boundary. The single operand 'ALIGN' doesn't 5198 change the value of the location counter--it just does arithmetic 5199 on it. The two operand 'ALIGN' allows an arbitrary expression to 5200 be aligned upwards ('ALIGN(ALIGN)' is equivalent to 5201 'ALIGN(ABSOLUTE(.), ALIGN)'). 5202 5203 Here is an example which aligns the output '.data' section to the 5204 next '0x2000' byte boundary after the preceding section and sets a 5205 variable within the section to the next '0x8000' boundary after the 5206 input sections: 5207 SECTIONS { ... 5208 .data ALIGN(0x2000): { 5209 *(.data) 5210 variable = ALIGN(0x8000); 5211 } 5212 ... } 5213 The first use of 'ALIGN' in this example specifies the location of 5214 a section because it is used as the optional ADDRESS attribute of a 5215 section definition (*note Output Section Address::). The second 5216 use of 'ALIGN' is used to defines the value of a symbol. 5217 5218 The builtin function 'NEXT' is closely related to 'ALIGN'. 5219 5220'ALIGNOF(SECTION)' 5221 Return the alignment in bytes of the named SECTION, if that section 5222 has been allocated. If the section has not been allocated when 5223 this is evaluated, the linker will report an error. In the 5224 following example, the alignment of the '.output' section is stored 5225 as the first value in that section. 5226 SECTIONS{ ... 5227 .output { 5228 LONG (ALIGNOF (.output)) 5229 ... 5230 } 5231 ... } 5232 5233'BLOCK(EXP)' 5234 This is a synonym for 'ALIGN', for compatibility with older linker 5235 scripts. It is most often seen when setting the address of an 5236 output section. 5237 5238'DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE)' 5239 This is equivalent to either 5240 (ALIGN(MAXPAGESIZE) + (. & (MAXPAGESIZE - 1))) 5241 or 5242 (ALIGN(MAXPAGESIZE) 5243 + ((. + COMMONPAGESIZE - 1) & (MAXPAGESIZE - COMMONPAGESIZE))) 5244 depending on whether the latter uses fewer COMMONPAGESIZE sized 5245 pages for the data segment (area between the result of this 5246 expression and 'DATA_SEGMENT_END') than the former or not. If the 5247 latter form is used, it means COMMONPAGESIZE bytes of runtime 5248 memory will be saved at the expense of up to COMMONPAGESIZE wasted 5249 bytes in the on-disk file. 5250 5251 This expression can only be used directly in 'SECTIONS' commands, 5252 not in any output section descriptions and only once in the linker 5253 script. COMMONPAGESIZE should be less or equal to MAXPAGESIZE and 5254 should be the system page size the object wants to be optimized for 5255 while still running on system page sizes up to MAXPAGESIZE. Note 5256 however that '-z relro' protection will not be effective if the 5257 system page size is larger than COMMONPAGESIZE. 5258 5259 Example: 5260 . = DATA_SEGMENT_ALIGN(0x10000, 0x2000); 5261 5262'DATA_SEGMENT_END(EXP)' 5263 This defines the end of data segment for 'DATA_SEGMENT_ALIGN' 5264 evaluation purposes. 5265 5266 . = DATA_SEGMENT_END(.); 5267 5268'DATA_SEGMENT_RELRO_END(OFFSET, EXP)' 5269 This defines the end of the 'PT_GNU_RELRO' segment when '-z relro' 5270 option is used. When '-z relro' option is not present, 5271 'DATA_SEGMENT_RELRO_END' does nothing, otherwise 5272 'DATA_SEGMENT_ALIGN' is padded so that EXP + OFFSET is aligned to 5273 the COMMONPAGESIZE argument given to 'DATA_SEGMENT_ALIGN'. If 5274 present in the linker script, it must be placed between 5275 'DATA_SEGMENT_ALIGN' and 'DATA_SEGMENT_END'. Evaluates to the 5276 second argument plus any padding needed at the end of the 5277 'PT_GNU_RELRO' segment due to section alignment. 5278 5279 . = DATA_SEGMENT_RELRO_END(24, .); 5280 5281'DEFINED(SYMBOL)' 5282 Return 1 if SYMBOL is in the linker global symbol table and is 5283 defined before the statement using DEFINED in the script, otherwise 5284 return 0. You can use this function to provide default values for 5285 symbols. For example, the following script fragment shows how to 5286 set a global symbol 'begin' to the first location in the '.text' 5287 section--but if a symbol called 'begin' already existed, its value 5288 is preserved: 5289 5290 SECTIONS { ... 5291 .text : { 5292 begin = DEFINED(begin) ? begin : . ; 5293 ... 5294 } 5295 ... 5296 } 5297 5298'LENGTH(MEMORY)' 5299 Return the length of the memory region named MEMORY. 5300 5301'LOADADDR(SECTION)' 5302 Return the absolute LMA of the named SECTION. (*note Output 5303 Section LMA::). 5304 5305'LOG2CEIL(EXP)' 5306 Return the binary logarithm of EXP rounded towards infinity. 5307 'LOG2CEIL(0)' returns 0. 5308 5309'MAX(EXP1, EXP2)' 5310 Returns the maximum of EXP1 and EXP2. 5311 5312'MIN(EXP1, EXP2)' 5313 Returns the minimum of EXP1 and EXP2. 5314 5315'NEXT(EXP)' 5316 Return the next unallocated address that is a multiple of EXP. 5317 This function is closely related to 'ALIGN(EXP)'; unless you use 5318 the 'MEMORY' command to define discontinuous memory for the output 5319 file, the two functions are equivalent. 5320 5321'ORIGIN(MEMORY)' 5322 Return the origin of the memory region named MEMORY. 5323 5324'SEGMENT_START(SEGMENT, DEFAULT)' 5325 Return the base address of the named SEGMENT. If an explicit value 5326 has already been given for this segment (with a command-line '-T' 5327 option) then that value will be returned otherwise the value will 5328 be DEFAULT. At present, the '-T' command-line option can only be 5329 used to set the base address for the "text", "data", and "bss" 5330 sections, but you can use 'SEGMENT_START' with any segment name. 5331 5332'SIZEOF(SECTION)' 5333 Return the size in bytes of the named SECTION, if that section has 5334 been allocated. If the section has not been allocated when this is 5335 evaluated, the linker will report an error. In the following 5336 example, 'symbol_1' and 'symbol_2' are assigned identical values: 5337 SECTIONS{ ... 5338 .output { 5339 .start = . ; 5340 ... 5341 .end = . ; 5342 } 5343 symbol_1 = .end - .start ; 5344 symbol_2 = SIZEOF(.output); 5345 ... } 5346 5347'SIZEOF_HEADERS' 5348'sizeof_headers' 5349 Return the size in bytes of the output file's headers. This is 5350 information which appears at the start of the output file. You can 5351 use this number when setting the start address of the first 5352 section, if you choose, to facilitate paging. 5353 5354 When producing an ELF output file, if the linker script uses the 5355 'SIZEOF_HEADERS' builtin function, the linker must compute the 5356 number of program headers before it has determined all the section 5357 addresses and sizes. If the linker later discovers that it needs 5358 additional program headers, it will report an error 'not enough 5359 room for program headers'. To avoid this error, you must avoid 5360 using the 'SIZEOF_HEADERS' function, or you must rework your linker 5361 script to avoid forcing the linker to use additional program 5362 headers, or you must define the program headers yourself using the 5363 'PHDRS' command (*note PHDRS::). 5364 5365 5366File: ld.info, Node: Implicit Linker Scripts, Prev: Expressions, Up: Scripts 5367 53683.11 Implicit Linker Scripts 5369============================ 5370 5371If you specify a linker input file which the linker can not recognize as 5372an object file or an archive file, it will try to read the file as a 5373linker script. If the file can not be parsed as a linker script, the 5374linker will report an error. 5375 5376 An implicit linker script will not replace the default linker script. 5377 5378 Typically an implicit linker script would contain only symbol 5379assignments, or the 'INPUT', 'GROUP', or 'VERSION' commands. 5380 5381 Any input files read because of an implicit linker script will be 5382read at the position in the command line where the implicit linker 5383script was read. This can affect archive searching. 5384 5385 5386File: ld.info, Node: Machine Dependent, Next: BFD, Prev: Scripts, Up: Top 5387 53884 Machine Dependent Features 5389**************************** 5390 5391'ld' has additional features on some platforms; the following sections 5392describe them. Machines where 'ld' has no additional functionality are 5393not listed. 5394 5395* Menu: 5396 5397* H8/300:: 'ld' and the H8/300 5398* M68HC11/68HC12:: 'ld' and the Motorola 68HC11 and 68HC12 families 5399* ARM:: 'ld' and the ARM family 5400* HPPA ELF32:: 'ld' and HPPA 32-bit ELF 5401* M68K:: 'ld' and the Motorola 68K family 5402* MIPS:: 'ld' and the MIPS family 5403* MMIX:: 'ld' and MMIX 5404* MSP430:: 'ld' and MSP430 5405* NDS32:: 'ld' and NDS32 5406* Nios II:: 'ld' and the Altera Nios II 5407* PowerPC ELF32:: 'ld' and PowerPC 32-bit ELF Support 5408* PowerPC64 ELF64:: 'ld' and PowerPC64 64-bit ELF Support 5409* S/390 ELF:: 'ld' and S/390 ELF Support 5410* SPU ELF:: 'ld' and SPU ELF Support 5411* TI COFF:: 'ld' and TI COFF 5412* WIN32:: 'ld' and WIN32 (cygwin/mingw) 5413* Xtensa:: 'ld' and Xtensa Processors 5414 5415 5416File: ld.info, Node: H8/300, Next: M68HC11/68HC12, Up: Machine Dependent 5417 54184.1 'ld' and the H8/300 5419======================= 5420 5421For the H8/300, 'ld' can perform these global optimizations when you 5422specify the '--relax' command-line option. 5423 5424_relaxing address modes_ 5425 'ld' finds all 'jsr' and 'jmp' instructions whose targets are 5426 within eight bits, and turns them into eight-bit program-counter 5427 relative 'bsr' and 'bra' instructions, respectively. 5428 5429_synthesizing instructions_ 5430 'ld' finds all 'mov.b' instructions which use the sixteen-bit 5431 absolute address form, but refer to the top page of memory, and 5432 changes them to use the eight-bit address form. (That is: the 5433 linker turns 'mov.b '@'AA:16' into 'mov.b '@'AA:8' whenever the 5434 address AA is in the top page of memory). 5435 5436 'ld' finds all 'mov' instructions which use the register indirect 5437 with 32-bit displacement addressing mode, but use a small 5438 displacement inside 16-bit displacement range, and changes them to 5439 use the 16-bit displacement form. (That is: the linker turns 5440 'mov.b '@'D:32,ERx' into 'mov.b '@'D:16,ERx' whenever the 5441 displacement D is in the 16 bit signed integer range. Only 5442 implemented in ELF-format ld). 5443 5444_bit manipulation instructions_ 5445 'ld' finds all bit manipulation instructions like 'band, bclr, 5446 biand, bild, bior, bist, bixor, bld, bnot, bor, bset, bst, btst, 5447 bxor' which use 32 bit and 16 bit absolute address form, but refer 5448 to the top page of memory, and changes them to use the 8 bit 5449 address form. (That is: the linker turns 'bset #xx:3,'@'AA:32' 5450 into 'bset #xx:3,'@'AA:8' whenever the address AA is in the top 5451 page of memory). 5452 5453_system control instructions_ 5454 'ld' finds all 'ldc.w, stc.w' instructions which use the 32 bit 5455 absolute address form, but refer to the top page of memory, and 5456 changes them to use 16 bit address form. (That is: the linker 5457 turns 'ldc.w '@'AA:32,ccr' into 'ldc.w '@'AA:16,ccr' whenever the 5458 address AA is in the top page of memory). 5459 5460 5461File: ld.info, Node: M68HC11/68HC12, Next: ARM, Prev: H8/300, Up: Machine Dependent 5462 54634.2 'ld' and the Motorola 68HC11 and 68HC12 families 5464==================================================== 5465 54664.2.1 Linker Relaxation 5467----------------------- 5468 5469For the Motorola 68HC11, 'ld' can perform these global optimizations 5470when you specify the '--relax' command-line option. 5471 5472_relaxing address modes_ 5473 'ld' finds all 'jsr' and 'jmp' instructions whose targets are 5474 within eight bits, and turns them into eight-bit program-counter 5475 relative 'bsr' and 'bra' instructions, respectively. 5476 5477 'ld' also looks at all 16-bit extended addressing modes and 5478 transforms them in a direct addressing mode when the address is in 5479 page 0 (between 0 and 0x0ff). 5480 5481_relaxing gcc instruction group_ 5482 When 'gcc' is called with '-mrelax', it can emit group of 5483 instructions that the linker can optimize to use a 68HC11 direct 5484 addressing mode. These instructions consists of 'bclr' or 'bset' 5485 instructions. 5486 54874.2.2 Trampoline Generation 5488--------------------------- 5489 5490For 68HC11 and 68HC12, 'ld' can generate trampoline code to call a far 5491function using a normal 'jsr' instruction. The linker will also change 5492the relocation to some far function to use the trampoline address 5493instead of the function address. This is typically the case when a 5494pointer to a function is taken. The pointer will in fact point to the 5495function trampoline. 5496 5497 5498File: ld.info, Node: ARM, Next: HPPA ELF32, Prev: M68HC11/68HC12, Up: Machine Dependent 5499 55004.3 'ld' and the ARM family 5501=========================== 5502 5503For the ARM, 'ld' will generate code stubs to allow functions calls 5504between ARM and Thumb code. These stubs only work with code that has 5505been compiled and assembled with the '-mthumb-interwork' command line 5506option. If it is necessary to link with old ARM object files or 5507libraries, which have not been compiled with the -mthumb-interwork 5508option then the '--support-old-code' command line switch should be given 5509to the linker. This will make it generate larger stub functions which 5510will work with non-interworking aware ARM code. Note, however, the 5511linker does not support generating stubs for function calls to 5512non-interworking aware Thumb code. 5513 5514 The '--thumb-entry' switch is a duplicate of the generic '--entry' 5515switch, in that it sets the program's starting address. But it also 5516sets the bottom bit of the address, so that it can be branched to using 5517a BX instruction, and the program will start executing in Thumb mode 5518straight away. 5519 5520 The '--use-nul-prefixed-import-tables' switch is specifying, that the 5521import tables idata4 and idata5 have to be generated with a zero element 5522prefix for import libraries. This is the old style to generate import 5523tables. By default this option is turned off. 5524 5525 The '--be8' switch instructs 'ld' to generate BE8 format executables. 5526This option is only valid when linking big-endian objects - ie ones 5527which have been assembled with the '-EB' option. The resulting image 5528will contain big-endian data and little-endian code. 5529 5530 The 'R_ARM_TARGET1' relocation is typically used for entries in the 5531'.init_array' section. It is interpreted as either 'R_ARM_REL32' or 5532'R_ARM_ABS32', depending on the target. The '--target1-rel' and 5533'--target1-abs' switches override the default. 5534 5535 The '--target2=type' switch overrides the default definition of the 5536'R_ARM_TARGET2' relocation. Valid values for 'type', their meanings, 5537and target defaults are as follows: 5538'rel' 5539 'R_ARM_REL32' (arm*-*-elf, arm*-*-eabi) 5540'abs' 5541 'R_ARM_ABS32' (arm*-*-symbianelf) 5542'got-rel' 5543 'R_ARM_GOT_PREL' (arm*-*-linux, arm*-*-*bsd) 5544 5545 The 'R_ARM_V4BX' relocation (defined by the ARM AAELF specification) 5546enables objects compiled for the ARMv4 architecture to be 5547interworking-safe when linked with other objects compiled for ARMv4t, 5548but also allows pure ARMv4 binaries to be built from the same ARMv4 5549objects. 5550 5551 In the latter case, the switch '--fix-v4bx' must be passed to the 5552linker, which causes v4t 'BX rM' instructions to be rewritten as 'MOV 5553PC,rM', since v4 processors do not have a 'BX' instruction. 5554 5555 In the former case, the switch should not be used, and 'R_ARM_V4BX' 5556relocations are ignored. 5557 5558 Replace 'BX rM' instructions identified by 'R_ARM_V4BX' relocations 5559with a branch to the following veneer: 5560 5561 TST rM, #1 5562 MOVEQ PC, rM 5563 BX Rn 5564 5565 This allows generation of libraries/applications that work on ARMv4 5566cores and are still interworking safe. Note that the above veneer 5567clobbers the condition flags, so may cause incorrect program behavior in 5568rare cases. 5569 5570 The '--use-blx' switch enables the linker to use ARM/Thumb BLX 5571instructions (available on ARMv5t and above) in various situations. 5572Currently it is used to perform calls via the PLT from Thumb code using 5573BLX rather than using BX and a mode-switching stub before each PLT 5574entry. This should lead to such calls executing slightly faster. 5575 5576 This option is enabled implicitly for SymbianOS, so there is no need 5577to specify it if you are using that target. 5578 5579 The '--vfp11-denorm-fix' switch enables a link-time workaround for a 5580bug in certain VFP11 coprocessor hardware, which sometimes allows 5581instructions with denorm operands (which must be handled by support 5582code) to have those operands overwritten by subsequent instructions 5583before the support code can read the intended values. 5584 5585 The bug may be avoided in scalar mode if you allow at least one 5586intervening instruction between a VFP11 instruction which uses a 5587register and another instruction which writes to the same register, or 5588at least two intervening instructions if vector mode is in use. The bug 5589only affects full-compliance floating-point mode: you do not need this 5590workaround if you are using "runfast" mode. Please contact ARM for 5591further details. 5592 5593 If you know you are using buggy VFP11 hardware, you can enable this 5594workaround by specifying the linker option '--vfp-denorm-fix=scalar' if 5595you are using the VFP11 scalar mode only, or '--vfp-denorm-fix=vector' 5596if you are using vector mode (the latter also works for scalar code). 5597The default is '--vfp-denorm-fix=none'. 5598 5599 If the workaround is enabled, instructions are scanned for 5600potentially-troublesome sequences, and a veneer is created for each such 5601sequence which may trigger the erratum. The veneer consists of the 5602first instruction of the sequence and a branch back to the subsequent 5603instruction. The original instruction is then replaced with a branch to 5604the veneer. The extra cycles required to call and return from the 5605veneer are sufficient to avoid the erratum in both the scalar and vector 5606cases. 5607 5608 The '--fix-arm1176' switch enables a link-time workaround for an 5609erratum in certain ARM1176 processors. The workaround is enabled by 5610default if you are targeting ARM v6 (excluding ARM v6T2) or earlier. It 5611can be disabled unconditionally by specifying '--no-fix-arm1176'. 5612 5613 Further information is available in the "ARM1176JZ-S and ARM1176JZF-S 5614Programmer Advice Notice" available on the ARM documentation website at: 5615http://infocenter.arm.com/. 5616 5617 The '--fix-stm32l4xx-629360' switch enables a link-time workaround 5618for a bug in the bus matrix / memory controller for some of the STM32 5619Cortex-M4 based products (STM32L4xx). When accessing off-chip memory 5620via the affected bus for bus reads of 9 words or more, the bus can 5621generate corrupt data and/or abort. These are only core-initiated 5622accesses (not DMA), and might affect any access: integer loads such as 5623LDM, POP and floating-point loads such as VLDM, VPOP. Stores are not 5624affected. 5625 5626 The bug can be avoided by splitting memory accesses into the 5627necessary chunks to keep bus reads below 8 words. 5628 5629 The workaround is not enabled by default, this is equivalent to use 5630'--fix-stm32l4xx-629360=none'. If you know you are using buggy 5631STM32L4xx hardware, you can enable the workaround by specifying the 5632linker option '--fix-stm32l4xx-629360', or the equivalent 5633'--fix-stm32l4xx-629360=default'. 5634 5635 If the workaround is enabled, instructions are scanned for 5636potentially-troublesome sequences, and a veneer is created for each such 5637sequence which may trigger the erratum. The veneer consists in a 5638replacement sequence emulating the behaviour of the original one and a 5639branch back to the subsequent instruction. The original instruction is 5640then replaced with a branch to the veneer. 5641 5642 The workaround does not always preserve the memory access order for 5643the LDMDB instruction, when the instruction loads the PC. 5644 5645 The workaround is not able to handle problematic instructions when 5646they are in the middle of an IT block, since a branch is not allowed 5647there. In that case, the linker reports a warning and no replacement 5648occurs. 5649 5650 The workaround is not able to replace problematic instructions with a 5651PC-relative branch instruction if the '.text' section is too large. In 5652that case, when the branch that replaces the original code cannot be 5653encoded, the linker reports a warning and no replacement occurs. 5654 5655 The '--no-enum-size-warning' switch prevents the linker from warning 5656when linking object files that specify incompatible EABI enumeration 5657size attributes. For example, with this switch enabled, linking of an 5658object file using 32-bit enumeration values with another using 5659enumeration values fitted into the smallest possible space will not be 5660diagnosed. 5661 5662 The '--no-wchar-size-warning' switch prevents the linker from warning 5663when linking object files that specify incompatible EABI 'wchar_t' size 5664attributes. For example, with this switch enabled, linking of an object 5665file using 32-bit 'wchar_t' values with another using 16-bit 'wchar_t' 5666values will not be diagnosed. 5667 5668 The '--pic-veneer' switch makes the linker use PIC sequences for 5669ARM/Thumb interworking veneers, even if the rest of the binary is not 5670PIC. This avoids problems on uClinux targets where '--emit-relocs' is 5671used to generate relocatable binaries. 5672 5673 The linker will automatically generate and insert small sequences of 5674code into a linked ARM ELF executable whenever an attempt is made to 5675perform a function call to a symbol that is too far away. The placement 5676of these sequences of instructions - called stubs - is controlled by the 5677command line option '--stub-group-size=N'. The placement is important 5678because a poor choice can create a need for duplicate stubs, increasing 5679the code size. The linker will try to group stubs together in order to 5680reduce interruptions to the flow of code, but it needs guidance as to 5681how big these groups should be and where they should be placed. 5682 5683 The value of 'N', the parameter to the '--stub-group-size=' option 5684controls where the stub groups are placed. If it is negative then all 5685stubs are placed after the first branch that needs them. If it is 5686positive then the stubs can be placed either before or after the 5687branches that need them. If the value of 'N' is 1 (either +1 or -1) 5688then the linker will choose exactly where to place groups of stubs, 5689using its built in heuristics. A value of 'N' greater than 1 (or 5690smaller than -1) tells the linker that a single group of stubs can 5691service at most 'N' bytes from the input sections. 5692 5693 The default, if '--stub-group-size=' is not specified, is 'N = +1'. 5694 5695 Farcalls stubs insertion is fully supported for the ARM-EABI target 5696only, because it relies on object files properties not present 5697otherwise. 5698 5699 The '--fix-cortex-a8' switch enables a link-time workaround for an 5700erratum in certain Cortex-A8 processors. The workaround is enabled by 5701default if you are targeting the ARM v7-A architecture profile. It can 5702be enabled otherwise by specifying '--fix-cortex-a8', or disabled 5703unconditionally by specifying '--no-fix-cortex-a8'. 5704 5705 The erratum only affects Thumb-2 code. Please contact ARM for 5706further details. 5707 5708 The '--fix-cortex-a53-835769' switch enables a link-time workaround 5709for erratum 835769 present on certain early revisions of Cortex-A53 5710processors. The workaround is disabled by default. It can be enabled 5711by specifying '--fix-cortex-a53-835769', or disabled unconditionally by 5712specifying '--no-fix-cortex-a53-835769'. 5713 5714 Please contact ARM for further details. 5715 5716 The '--no-merge-exidx-entries' switch disables the merging of 5717adjacent exidx entries in debuginfo. 5718 5719 The '--long-plt' option enables the use of 16 byte PLT entries which 5720support up to 4Gb of code. The default is to use 12 byte PLT entries 5721which only support 512Mb of code. 5722 5723 The '--no-apply-dynamic-relocs' option makes AArch64 linker do not 5724apply link-time values for dynamic relocations. 5725 5726 All SG veneers are placed in the special output section 5727'.gnu.sgstubs'. Its start address must be set, either with the command 5728line option '--section-start' or in a linker script, to indicate where 5729to place these veneers in memory. 5730 5731 The '--cmse-implib' option requests that the import libraries 5732specified by the '--out-implib' and '--in-implib' options are secure 5733gateway import libraries, suitable for linking a non-secure executable 5734against secure code as per ARMv8-M Security Extensions. 5735 5736 The '--in-implib=file' specifies an input import library whose 5737symbols must keep the same address in the executable being produced. A 5738warning is given if no '--out-implib' is given but new symbols have been 5739introduced in the executable that should be listed in its import 5740library. Otherwise, if '--out-implib' is specified, the symbols are 5741added to the output import library. A warning is also given if some 5742symbols present in the input import library have disappeared from the 5743executable. This option is only effective for Secure Gateway import 5744libraries, ie. when '--cmse-implib' is specified. 5745 5746 5747File: ld.info, Node: HPPA ELF32, Next: M68K, Prev: ARM, Up: Machine Dependent 5748 57494.4 'ld' and HPPA 32-bit ELF Support 5750==================================== 5751 5752When generating a shared library, 'ld' will by default generate import 5753stubs suitable for use with a single sub-space application. The 5754'--multi-subspace' switch causes 'ld' to generate export stubs, and 5755different (larger) import stubs suitable for use with multiple 5756sub-spaces. 5757 5758 Long branch stubs and import/export stubs are placed by 'ld' in stub 5759sections located between groups of input sections. '--stub-group-size' 5760specifies the maximum size of a group of input sections handled by one 5761stub section. Since branch offsets are signed, a stub section may serve 5762two groups of input sections, one group before the stub section, and one 5763group after it. However, when using conditional branches that require 5764stubs, it may be better (for branch prediction) that stub sections only 5765serve one group of input sections. A negative value for 'N' chooses 5766this scheme, ensuring that branches to stubs always use a negative 5767offset. Two special values of 'N' are recognized, '1' and '-1'. These 5768both instruct 'ld' to automatically size input section groups for the 5769branch types detected, with the same behaviour regarding stub placement 5770as other positive or negative values of 'N' respectively. 5771 5772 Note that '--stub-group-size' does not split input sections. A 5773single input section larger than the group size specified will of course 5774create a larger group (of one section). If input sections are too 5775large, it may not be possible for a branch to reach its stub. 5776 5777 5778File: ld.info, Node: M68K, Next: MIPS, Prev: HPPA ELF32, Up: Machine Dependent 5779 57804.5 'ld' and the Motorola 68K family 5781==================================== 5782 5783The '--got=TYPE' option lets you choose the GOT generation scheme. The 5784choices are 'single', 'negative', 'multigot' and 'target'. When 5785'target' is selected the linker chooses the default GOT generation 5786scheme for the current target. 'single' tells the linker to generate a 5787single GOT with entries only at non-negative offsets. 'negative' 5788instructs the linker to generate a single GOT with entries at both 5789negative and positive offsets. Not all environments support such GOTs. 5790'multigot' allows the linker to generate several GOTs in the output 5791file. All GOT references from a single input object file access the 5792same GOT, but references from different input object files might access 5793different GOTs. Not all environments support such GOTs. 5794 5795 5796File: ld.info, Node: MIPS, Next: MMIX, Prev: M68K, Up: Machine Dependent 5797 57984.6 'ld' and the MIPS family 5799============================ 5800 5801The '--insn32' and '--no-insn32' options control the choice of microMIPS 5802instructions used in code generated by the linker, such as that in the 5803PLT or lazy binding stubs, or in relaxation. If '--insn32' is used, 5804then the linker only uses 32-bit instruction encodings. By default or 5805if '--no-insn32' is used, all instruction encodings are used, including 580616-bit ones where possible. 5807 5808 The '--ignore-branch-isa' and '--no-ignore-branch-isa' options 5809control branch relocation checks for invalid ISA mode transitions. If 5810'--ignore-branch-isa' is used, then the linker accepts any branch 5811relocations and any ISA mode transition required is lost in relocation 5812calculation, except for some cases of 'BAL' instructions which meet 5813relaxation conditions and are converted to equivalent 'JALX' 5814instructions as the associated relocation is calculated. By default or 5815if '--no-ignore-branch-isa' is used a check is made causing the loss of 5816an ISA mode transition to produce an error. 5817 5818 5819File: ld.info, Node: MMIX, Next: MSP430, Prev: MIPS, Up: Machine Dependent 5820 58214.7 'ld' and MMIX 5822================= 5823 5824For MMIX, there is a choice of generating 'ELF' object files or 'mmo' 5825object files when linking. The simulator 'mmix' understands the 'mmo' 5826format. The binutils 'objcopy' utility can translate between the two 5827formats. 5828 5829 There is one special section, the '.MMIX.reg_contents' section. 5830Contents in this section is assumed to correspond to that of global 5831registers, and symbols referring to it are translated to special 5832symbols, equal to registers. In a final link, the start address of the 5833'.MMIX.reg_contents' section corresponds to the first allocated global 5834register multiplied by 8. Register '$255' is not included in this 5835section; it is always set to the program entry, which is at the symbol 5836'Main' for 'mmo' files. 5837 5838 Global symbols with the prefix '__.MMIX.start.', for example 5839'__.MMIX.start..text' and '__.MMIX.start..data' are special. The 5840default linker script uses these to set the default start address of a 5841section. 5842 5843 Initial and trailing multiples of zero-valued 32-bit words in a 5844section, are left out from an mmo file. 5845 5846 5847File: ld.info, Node: MSP430, Next: NDS32, Prev: MMIX, Up: Machine Dependent 5848 58494.8 'ld' and MSP430 5850=================== 5851 5852For the MSP430 it is possible to select the MPU architecture. The flag 5853'-m [mpu type]' will select an appropriate linker script for selected 5854MPU type. (To get a list of known MPUs just pass '-m help' option to 5855the linker). 5856 5857 The linker will recognize some extra sections which are MSP430 5858specific: 5859 5860''.vectors'' 5861 Defines a portion of ROM where interrupt vectors located. 5862 5863''.bootloader'' 5864 Defines the bootloader portion of the ROM (if applicable). Any 5865 code in this section will be uploaded to the MPU. 5866 5867''.infomem'' 5868 Defines an information memory section (if applicable). Any code in 5869 this section will be uploaded to the MPU. 5870 5871''.infomemnobits'' 5872 This is the same as the '.infomem' section except that any code in 5873 this section will not be uploaded to the MPU. 5874 5875''.noinit'' 5876 Denotes a portion of RAM located above '.bss' section. 5877 5878 The last two sections are used by gcc. 5879 5880'--code-region=[either,lower,upper,none]' 5881 This will transform .text* sections to [either,lower,upper].text* 5882 sections. The argument passed to GCC for -mcode-region is 5883 propagated to the linker using this option. 5884 5885'--data-region=[either,lower,upper,none]' 5886 This will transform .data*, .bss* and .rodata* sections to 5887 [either,lower,upper].[data,bss,rodata]* sections. The argument 5888 passed to GCC for -mdata-region is propagated to the linker using 5889 this option. 5890 5891'--disable-sec-transformation' 5892 Prevent the transformation of sections as specified by the 5893 '--code-region' and '--data-region' options. This is useful if you 5894 are compiling and linking using a single call to the GCC wrapper, 5895 and want to compile the source files using -m[code,data]-region but 5896 not transform the sections for prebuilt libraries and objects. 5897 5898 5899File: ld.info, Node: NDS32, Next: Nios II, Prev: MSP430, Up: Machine Dependent 5900 59014.9 'ld' and NDS32 5902================== 5903 5904For NDS32, there are some options to select relaxation behavior. The 5905linker relaxes objects according to these options. 5906 5907''--m[no-]fp-as-gp'' 5908 Disable/enable fp-as-gp relaxation. 5909 5910''--mexport-symbols=FILE'' 5911 Exporting symbols and their address into FILE as linker script. 5912 5913''--m[no-]ex9'' 5914 Disable/enable link-time EX9 relaxation. 5915 5916''--mexport-ex9=FILE'' 5917 Export the EX9 table after linking. 5918 5919''--mimport-ex9=FILE'' 5920 Import the Ex9 table for EX9 relaxation. 5921 5922''--mupdate-ex9'' 5923 Update the existing EX9 table. 5924 5925''--mex9-limit=NUM'' 5926 Maximum number of entries in the ex9 table. 5927 5928''--mex9-loop-aware'' 5929 Avoid generating the EX9 instruction inside the loop. 5930 5931''--m[no-]ifc'' 5932 Disable/enable the link-time IFC optimization. 5933 5934''--mifc-loop-aware'' 5935 Avoid generating the IFC instruction inside the loop. 5936 5937 5938File: ld.info, Node: Nios II, Next: PowerPC ELF32, Prev: NDS32, Up: Machine Dependent 5939 59404.10 'ld' and the Altera Nios II 5941================================ 5942 5943Call and immediate jump instructions on Nios II processors are limited 5944to transferring control to addresses in the same 256MB memory segment, 5945which may result in 'ld' giving 'relocation truncated to fit' errors 5946with very large programs. The command-line option '--relax' enables the 5947generation of trampolines that can access the entire 32-bit address 5948space for calls outside the normal 'call' and 'jmpi' address range. 5949These trampolines are inserted at section boundaries, so may not 5950themselves be reachable if an input section and its associated call 5951trampolines are larger than 256MB. 5952 5953 The '--relax' option is enabled by default unless '-r' is also 5954specified. You can disable trampoline generation by using the 5955'--no-relax' linker option. You can also disable this optimization 5956locally by using the 'set .noat' directive in assembly-language source 5957files, as the linker-inserted trampolines use the 'at' register as a 5958temporary. 5959 5960 Note that the linker '--relax' option is independent of assembler 5961relaxation options, and that using the GNU assembler's '-relax-all' 5962option interferes with the linker's more selective call instruction 5963relaxation. 5964 5965 5966File: ld.info, Node: PowerPC ELF32, Next: PowerPC64 ELF64, Prev: Nios II, Up: Machine Dependent 5967 59684.11 'ld' and PowerPC 32-bit ELF Support 5969======================================== 5970 5971Branches on PowerPC processors are limited to a signed 26-bit 5972displacement, which may result in 'ld' giving 'relocation truncated to 5973fit' errors with very large programs. '--relax' enables the generation 5974of trampolines that can access the entire 32-bit address space. These 5975trampolines are inserted at section boundaries, so may not themselves be 5976reachable if an input section exceeds 33M in size. You may combine '-r' 5977and '--relax' to add trampolines in a partial link. In that case both 5978branches to undefined symbols and inter-section branches are also 5979considered potentially out of range, and trampolines inserted. 5980 5981'--bss-plt' 5982 Current PowerPC GCC accepts a '-msecure-plt' option that generates 5983 code capable of using a newer PLT and GOT layout that has the 5984 security advantage of no executable section ever needing to be 5985 writable and no writable section ever being executable. PowerPC 5986 'ld' will generate this layout, including stubs to access the PLT, 5987 if all input files (including startup and static libraries) were 5988 compiled with '-msecure-plt'. '--bss-plt' forces the old BSS PLT 5989 (and GOT layout) which can give slightly better performance. 5990 5991'--secure-plt' 5992 'ld' will use the new PLT and GOT layout if it is linking new 5993 '-fpic' or '-fPIC' code, but does not do so automatically when 5994 linking non-PIC code. This option requests the new PLT and GOT 5995 layout. A warning will be given if some object file requires the 5996 old style BSS PLT. 5997 5998'--sdata-got' 5999 The new secure PLT and GOT are placed differently relative to other 6000 sections compared to older BSS PLT and GOT placement. The location 6001 of '.plt' must change because the new secure PLT is an initialized 6002 section while the old PLT is uninitialized. The reason for the 6003 '.got' change is more subtle: The new placement allows '.got' to be 6004 read-only in applications linked with '-z relro -z now'. However, 6005 this placement means that '.sdata' cannot always be used in shared 6006 libraries, because the PowerPC ABI accesses '.sdata' in shared 6007 libraries from the GOT pointer. '--sdata-got' forces the old GOT 6008 placement. PowerPC GCC doesn't use '.sdata' in shared libraries, 6009 so this option is really only useful for other compilers that may 6010 do so. 6011 6012'--emit-stub-syms' 6013 This option causes 'ld' to label linker stubs with a local symbol 6014 that encodes the stub type and destination. 6015 6016'--no-tls-optimize' 6017 PowerPC 'ld' normally performs some optimization of code sequences 6018 used to access Thread-Local Storage. Use this option to disable 6019 the optimization. 6020 6021 6022File: ld.info, Node: PowerPC64 ELF64, Next: S/390 ELF, Prev: PowerPC ELF32, Up: Machine Dependent 6023 60244.12 'ld' and PowerPC64 64-bit ELF Support 6025========================================== 6026 6027'--stub-group-size' 6028 Long branch stubs, PLT call stubs and TOC adjusting stubs are 6029 placed by 'ld' in stub sections located between groups of input 6030 sections. '--stub-group-size' specifies the maximum size of a 6031 group of input sections handled by one stub section. Since branch 6032 offsets are signed, a stub section may serve two groups of input 6033 sections, one group before the stub section, and one group after 6034 it. However, when using conditional branches that require stubs, 6035 it may be better (for branch prediction) that stub sections only 6036 serve one group of input sections. A negative value for 'N' 6037 chooses this scheme, ensuring that branches to stubs always use a 6038 negative offset. Two special values of 'N' are recognized, '1' and 6039 '-1'. These both instruct 'ld' to automatically size input section 6040 groups for the branch types detected, with the same behaviour 6041 regarding stub placement as other positive or negative values of 6042 'N' respectively. 6043 6044 Note that '--stub-group-size' does not split input sections. A 6045 single input section larger than the group size specified will of 6046 course create a larger group (of one section). If input sections 6047 are too large, it may not be possible for a branch to reach its 6048 stub. 6049 6050'--emit-stub-syms' 6051 This option causes 'ld' to label linker stubs with a local symbol 6052 that encodes the stub type and destination. 6053 6054'--dotsyms' 6055'--no-dotsyms' 6056 These two options control how 'ld' interprets version patterns in a 6057 version script. Older PowerPC64 compilers emitted both a function 6058 descriptor symbol with the same name as the function, and a code 6059 entry symbol with the name prefixed by a dot ('.'). To properly 6060 version a function 'foo', the version script thus needs to control 6061 both 'foo' and '.foo'. The option '--dotsyms', on by default, 6062 automatically adds the required dot-prefixed patterns. Use 6063 '--no-dotsyms' to disable this feature. 6064 6065'--save-restore-funcs' 6066'--no-save-restore-funcs' 6067 These two options control whether PowerPC64 'ld' automatically 6068 provides out-of-line register save and restore functions used by 6069 '-Os' code. The default is to provide any such referenced function 6070 for a normal final link, and to not do so for a relocatable link. 6071 6072'--no-tls-optimize' 6073 PowerPC64 'ld' normally performs some optimization of code 6074 sequences used to access Thread-Local Storage. Use this option to 6075 disable the optimization. 6076 6077'--tls-get-addr-optimize' 6078'--no-tls-get-addr-optimize' 6079 These options control whether PowerPC64 'ld' uses a special stub to 6080 call __tls_get_addr. PowerPC64 glibc 2.22 and later support an 6081 optimization that allows the second and subsequent calls to 6082 '__tls_get_addr' for a given symbol to be resolved by the special 6083 stub without calling in to glibc. By default the linker enables 6084 this option when glibc advertises the availability of 6085 __tls_get_addr_opt. Forcing this option on when using an older 6086 glibc won't do much besides slow down your applications, but may be 6087 useful if linking an application against an older glibc with the 6088 expectation that it will normally be used on systems having a newer 6089 glibc. 6090 6091'--no-opd-optimize' 6092 PowerPC64 'ld' normally removes '.opd' section entries 6093 corresponding to deleted link-once functions, or functions removed 6094 by the action of '--gc-sections' or linker script '/DISCARD/'. Use 6095 this option to disable '.opd' optimization. 6096 6097'--non-overlapping-opd' 6098 Some PowerPC64 compilers have an option to generate compressed 6099 '.opd' entries spaced 16 bytes apart, overlapping the third word, 6100 the static chain pointer (unused in C) with the first word of the 6101 next entry. This option expands such entries to the full 24 bytes. 6102 6103'--no-toc-optimize' 6104 PowerPC64 'ld' normally removes unused '.toc' section entries. 6105 Such entries are detected by examining relocations that reference 6106 the TOC in code sections. A reloc in a deleted code section marks 6107 a TOC word as unneeded, while a reloc in a kept code section marks 6108 a TOC word as needed. Since the TOC may reference itself, TOC 6109 relocs are also examined. TOC words marked as both needed and 6110 unneeded will of course be kept. TOC words without any referencing 6111 reloc are assumed to be part of a multi-word entry, and are kept or 6112 discarded as per the nearest marked preceding word. This works 6113 reliably for compiler generated code, but may be incorrect if 6114 assembly code is used to insert TOC entries. Use this option to 6115 disable the optimization. 6116 6117'--no-multi-toc' 6118 If given any toc option besides '-mcmodel=medium' or 6119 '-mcmodel=large', PowerPC64 GCC generates code for a TOC model 6120 where TOC entries are accessed with a 16-bit offset from r2. This 6121 limits the total TOC size to 64K. PowerPC64 'ld' extends this limit 6122 by grouping code sections such that each group uses less than 64K 6123 for its TOC entries, then inserts r2 adjusting stubs between 6124 inter-group calls. 'ld' does not split apart input sections, so 6125 cannot help if a single input file has a '.toc' section that 6126 exceeds 64K, most likely from linking multiple files with 'ld -r'. 6127 Use this option to turn off this feature. 6128 6129'--no-toc-sort' 6130 By default, 'ld' sorts TOC sections so that those whose file 6131 happens to have a section called '.init' or '.fini' are placed 6132 first, followed by TOC sections referenced by code generated with 6133 PowerPC64 gcc's '-mcmodel=small', and lastly TOC sections 6134 referenced only by code generated with PowerPC64 gcc's 6135 '-mcmodel=medium' or '-mcmodel=large' options. Doing this results 6136 in better TOC grouping for multi-TOC. Use this option to turn off 6137 this feature. 6138 6139'--plt-align' 6140'--no-plt-align' 6141 Use these options to control whether individual PLT call stubs are 6142 aligned to a 32-byte boundary, or to the specified power of two 6143 boundary when using '--plt-align='. A negative value may be 6144 specified to pad PLT call stubs so that they do not cross the 6145 specified power of two boundary (or the minimum number of 6146 boundaries if a PLT stub is so large that it must cross a 6147 boundary). By default PLT call stubs are aligned to 32-byte 6148 boundaries. 6149 6150'--plt-static-chain' 6151'--no-plt-static-chain' 6152 Use these options to control whether PLT call stubs load the static 6153 chain pointer (r11). 'ld' defaults to not loading the static chain 6154 since there is never any need to do so on a PLT call. 6155 6156'--plt-thread-safe' 6157'--no-plt-thread-safe' 6158 With power7's weakly ordered memory model, it is possible when 6159 using lazy binding for ld.so to update a plt entry in one thread 6160 and have another thread see the individual plt entry words update 6161 in the wrong order, despite ld.so carefully writing in the correct 6162 order and using memory write barriers. To avoid this we need some 6163 sort of read barrier in the call stub, or use LD_BIND_NOW=1. By 6164 default, 'ld' looks for calls to commonly used functions that 6165 create threads, and if seen, adds the necessary barriers. Use 6166 these options to change the default behaviour. 6167 6168'--plt-localentry' 6169'--no-localentry' 6170 ELFv2 functions with localentry:0 are those with a single entry 6171 point, ie. global entry == local entry, and that have no 6172 requirement on r2 (the TOC/GOT pointer) or r12, and guarantee r2 is 6173 unchanged on return. Such an external function can be called via 6174 the PLT without saving r2 or restoring it on return, avoiding a 6175 common load-hit-store for small functions. The optimization is 6176 attractive, with up to 40% reduction in execution time for a small 6177 function, but can result in symbol interposition failures. Also, 6178 minor changes in a shared library, including system libraries, can 6179 cause a function that was localentry:0 to become localentry:8. 6180 This will result in a dynamic loader complaint and failure to run. 6181 The option is experimental, use with care. '--no-plt-localentry' 6182 is the default. 6183 6184 6185File: ld.info, Node: S/390 ELF, Next: SPU ELF, Prev: PowerPC64 ELF64, Up: Machine Dependent 6186 61874.13 'ld' and S/390 ELF Support 6188=============================== 6189 6190'--s390-pgste' 6191 This option marks the result file with a 'PT_S390_PGSTE' segment. 6192 The Linux kernel is supposed to allocate 4k page tables for 6193 binaries marked that way. 6194 6195 6196File: ld.info, Node: SPU ELF, Next: TI COFF, Prev: S/390 ELF, Up: Machine Dependent 6197 61984.14 'ld' and SPU ELF Support 6199============================= 6200 6201'--plugin' 6202 This option marks an executable as a PIC plugin module. 6203 6204'--no-overlays' 6205 Normally, 'ld' recognizes calls to functions within overlay 6206 regions, and redirects such calls to an overlay manager via a stub. 6207 'ld' also provides a built-in overlay manager. This option turns 6208 off all this special overlay handling. 6209 6210'--emit-stub-syms' 6211 This option causes 'ld' to label overlay stubs with a local symbol 6212 that encodes the stub type and destination. 6213 6214'--extra-overlay-stubs' 6215 This option causes 'ld' to add overlay call stubs on all function 6216 calls out of overlay regions. Normally stubs are not added on 6217 calls to non-overlay regions. 6218 6219'--local-store=lo:hi' 6220 'ld' usually checks that a final executable for SPU fits in the 6221 address range 0 to 256k. This option may be used to change the 6222 range. Disable the check entirely with '--local-store=0:0'. 6223 6224'--stack-analysis' 6225 SPU local store space is limited. Over-allocation of stack space 6226 unnecessarily limits space available for code and data, while 6227 under-allocation results in runtime failures. If given this 6228 option, 'ld' will provide an estimate of maximum stack usage. 'ld' 6229 does this by examining symbols in code sections to determine the 6230 extents of functions, and looking at function prologues for stack 6231 adjusting instructions. A call-graph is created by looking for 6232 relocations on branch instructions. The graph is then searched for 6233 the maximum stack usage path. Note that this analysis does not 6234 find calls made via function pointers, and does not handle 6235 recursion and other cycles in the call graph. Stack usage may be 6236 under-estimated if your code makes such calls. Also, stack usage 6237 for dynamic allocation, e.g. alloca, will not be detected. If a 6238 link map is requested, detailed information about each function's 6239 stack usage and calls will be given. 6240 6241'--emit-stack-syms' 6242 This option, if given along with '--stack-analysis' will result in 6243 'ld' emitting stack sizing symbols for each function. These take 6244 the form '__stack_<function_name>' for global functions, and 6245 '__stack_<number>_<function_name>' for static functions. 6246 '<number>' is the section id in hex. The value of such symbols is 6247 the stack requirement for the corresponding function. The symbol 6248 size will be zero, type 'STT_NOTYPE', binding 'STB_LOCAL', and 6249 section 'SHN_ABS'. 6250 6251 6252File: ld.info, Node: TI COFF, Next: WIN32, Prev: SPU ELF, Up: Machine Dependent 6253 62544.15 'ld''s Support for Various TI COFF Versions 6255================================================ 6256 6257The '--format' switch allows selection of one of the various TI COFF 6258versions. The latest of this writing is 2; versions 0 and 1 are also 6259supported. The TI COFF versions also vary in header byte-order format; 6260'ld' will read any version or byte order, but the output header format 6261depends on the default specified by the specific target. 6262 6263 6264File: ld.info, Node: WIN32, Next: Xtensa, Prev: TI COFF, Up: Machine Dependent 6265 62664.16 'ld' and WIN32 (cygwin/mingw) 6267================================== 6268 6269This section describes some of the win32 specific 'ld' issues. See 6270*note Command Line Options: Options. for detailed description of the 6271command line options mentioned here. 6272 6273_import libraries_ 6274 The standard Windows linker creates and uses so-called import 6275 libraries, which contains information for linking to dll's. They 6276 are regular static archives and are handled as any other static 6277 archive. The cygwin and mingw ports of 'ld' have specific support 6278 for creating such libraries provided with the '--out-implib' 6279 command line option. 6280 6281_exporting DLL symbols_ 6282 The cygwin/mingw 'ld' has several ways to export symbols for dll's. 6283 6284 _using auto-export functionality_ 6285 By default 'ld' exports symbols with the auto-export 6286 functionality, which is controlled by the following command 6287 line options: 6288 6289 * -export-all-symbols [This is the default] 6290 * -exclude-symbols 6291 * -exclude-libs 6292 * -exclude-modules-for-implib 6293 * -version-script 6294 6295 When auto-export is in operation, 'ld' will export all the 6296 non-local (global and common) symbols it finds in a DLL, with 6297 the exception of a few symbols known to belong to the system's 6298 runtime and libraries. As it will often not be desirable to 6299 export all of a DLL's symbols, which may include private 6300 functions that are not part of any public interface, the 6301 command-line options listed above may be used to filter 6302 symbols out from the list for exporting. The '--output-def' 6303 option can be used in order to see the final list of exported 6304 symbols with all exclusions taken into effect. 6305 6306 If '--export-all-symbols' is not given explicitly on the 6307 command line, then the default auto-export behavior will be 6308 _disabled_ if either of the following are true: 6309 6310 * A DEF file is used. 6311 * Any symbol in any object file was marked with the 6312 __declspec(dllexport) attribute. 6313 6314 _using a DEF file_ 6315 Another way of exporting symbols is using a DEF file. A DEF 6316 file is an ASCII file containing definitions of symbols which 6317 should be exported when a dll is created. Usually it is named 6318 '<dll name>.def' and is added as any other object file to the 6319 linker's command line. The file's name must end in '.def' or 6320 '.DEF'. 6321 6322 gcc -o <output> <objectfiles> <dll name>.def 6323 6324 Using a DEF file turns off the normal auto-export behavior, 6325 unless the '--export-all-symbols' option is also used. 6326 6327 Here is an example of a DEF file for a shared library called 6328 'xyz.dll': 6329 6330 LIBRARY "xyz.dll" BASE=0x20000000 6331 6332 EXPORTS 6333 foo 6334 bar 6335 _bar = bar 6336 another_foo = abc.dll.afoo 6337 var1 DATA 6338 doo = foo == foo2 6339 eoo DATA == var1 6340 6341 This example defines a DLL with a non-default base address and 6342 seven symbols in the export table. The third exported symbol 6343 '_bar' is an alias for the second. The fourth symbol, 6344 'another_foo' is resolved by "forwarding" to another module 6345 and treating it as an alias for 'afoo' exported from the DLL 6346 'abc.dll'. The final symbol 'var1' is declared to be a data 6347 object. The 'doo' symbol in export library is an alias of 6348 'foo', which gets the string name in export table 'foo2'. The 6349 'eoo' symbol is an data export symbol, which gets in export 6350 table the name 'var1'. 6351 6352 The optional 'LIBRARY <name>' command indicates the _internal_ 6353 name of the output DLL. If '<name>' does not include a suffix, 6354 the default library suffix, '.DLL' is appended. 6355 6356 When the .DEF file is used to build an application, rather 6357 than a library, the 'NAME <name>' command should be used 6358 instead of 'LIBRARY'. If '<name>' does not include a suffix, 6359 the default executable suffix, '.EXE' is appended. 6360 6361 With either 'LIBRARY <name>' or 'NAME <name>' the optional 6362 specification 'BASE = <number>' may be used to specify a 6363 non-default base address for the image. 6364 6365 If neither 'LIBRARY <name>' nor 'NAME <name>' is specified, or 6366 they specify an empty string, the internal name is the same as 6367 the filename specified on the command line. 6368 6369 The complete specification of an export symbol is: 6370 6371 EXPORTS 6372 ( ( ( <name1> [ = <name2> ] ) 6373 | ( <name1> = <module-name> . <external-name>)) 6374 [ @ <integer> ] [NONAME] [DATA] [CONSTANT] [PRIVATE] [== <name3>] ) * 6375 6376 Declares '<name1>' as an exported symbol from the DLL, or 6377 declares '<name1>' as an exported alias for '<name2>'; or 6378 declares '<name1>' as a "forward" alias for the symbol 6379 '<external-name>' in the DLL '<module-name>'. Optionally, the 6380 symbol may be exported by the specified ordinal '<integer>' 6381 alias. The optional '<name3>' is the to be used string in 6382 import/export table for the symbol. 6383 6384 The optional keywords that follow the declaration indicate: 6385 6386 'NONAME': Do not put the symbol name in the DLL's export 6387 table. It will still be exported by its ordinal alias (either 6388 the value specified by the .def specification or, otherwise, 6389 the value assigned by the linker). The symbol name, however, 6390 does remain visible in the import library (if any), unless 6391 'PRIVATE' is also specified. 6392 6393 'DATA': The symbol is a variable or object, rather than a 6394 function. The import lib will export only an indirect 6395 reference to 'foo' as the symbol '_imp__foo' (ie, 'foo' must 6396 be resolved as '*_imp__foo'). 6397 6398 'CONSTANT': Like 'DATA', but put the undecorated 'foo' as well 6399 as '_imp__foo' into the import library. Both refer to the 6400 read-only import address table's pointer to the variable, not 6401 to the variable itself. This can be dangerous. If the user 6402 code fails to add the 'dllimport' attribute and also fails to 6403 explicitly add the extra indirection that the use of the 6404 attribute enforces, the application will behave unexpectedly. 6405 6406 'PRIVATE': Put the symbol in the DLL's export table, but do 6407 not put it into the static import library used to resolve 6408 imports at link time. The symbol can still be imported using 6409 the 'LoadLibrary/GetProcAddress' API at runtime or by using 6410 the GNU ld extension of linking directly to the DLL without an 6411 import library. 6412 6413 See ld/deffilep.y in the binutils sources for the full 6414 specification of other DEF file statements 6415 6416 While linking a shared dll, 'ld' is able to create a DEF file 6417 with the '--output-def <file>' command line option. 6418 6419 _Using decorations_ 6420 Another way of marking symbols for export is to modify the 6421 source code itself, so that when building the DLL each symbol 6422 to be exported is declared as: 6423 6424 __declspec(dllexport) int a_variable 6425 __declspec(dllexport) void a_function(int with_args) 6426 6427 All such symbols will be exported from the DLL. If, however, 6428 any of the object files in the DLL contain symbols decorated 6429 in this way, then the normal auto-export behavior is disabled, 6430 unless the '--export-all-symbols' option is also used. 6431 6432 Note that object files that wish to access these symbols must 6433 _not_ decorate them with dllexport. Instead, they should use 6434 dllimport, instead: 6435 6436 __declspec(dllimport) int a_variable 6437 __declspec(dllimport) void a_function(int with_args) 6438 6439 This complicates the structure of library header files, 6440 because when included by the library itself the header must 6441 declare the variables and functions as dllexport, but when 6442 included by client code the header must declare them as 6443 dllimport. There are a number of idioms that are typically 6444 used to do this; often client code can omit the __declspec() 6445 declaration completely. See '--enable-auto-import' and 6446 'automatic data imports' for more information. 6447 6448_automatic data imports_ 6449 The standard Windows dll format supports data imports from dlls 6450 only by adding special decorations (dllimport/dllexport), which let 6451 the compiler produce specific assembler instructions to deal with 6452 this issue. This increases the effort necessary to port existing 6453 Un*x code to these platforms, especially for large c++ libraries 6454 and applications. The auto-import feature, which was initially 6455 provided by Paul Sokolovsky, allows one to omit the decorations to 6456 achieve a behavior that conforms to that on POSIX/Un*x platforms. 6457 This feature is enabled with the '--enable-auto-import' 6458 command-line option, although it is enabled by default on 6459 cygwin/mingw. The '--enable-auto-import' option itself now serves 6460 mainly to suppress any warnings that are ordinarily emitted when 6461 linked objects trigger the feature's use. 6462 6463 auto-import of variables does not always work flawlessly without 6464 additional assistance. Sometimes, you will see this message 6465 6466 "variable '<var>' can't be auto-imported. Please read the 6467 documentation for ld's '--enable-auto-import' for details." 6468 6469 The '--enable-auto-import' documentation explains why this error 6470 occurs, and several methods that can be used to overcome this 6471 difficulty. One of these methods is the _runtime pseudo-relocs_ 6472 feature, described below. 6473 6474 For complex variables imported from DLLs (such as structs or 6475 classes), object files typically contain a base address for the 6476 variable and an offset (_addend_) within the variable-to specify a 6477 particular field or public member, for instance. Unfortunately, 6478 the runtime loader used in win32 environments is incapable of 6479 fixing these references at runtime without the additional 6480 information supplied by dllimport/dllexport decorations. The 6481 standard auto-import feature described above is unable to resolve 6482 these references. 6483 6484 The '--enable-runtime-pseudo-relocs' switch allows these references 6485 to be resolved without error, while leaving the task of adjusting 6486 the references themselves (with their non-zero addends) to 6487 specialized code provided by the runtime environment. Recent 6488 versions of the cygwin and mingw environments and compilers provide 6489 this runtime support; older versions do not. However, the support 6490 is only necessary on the developer's platform; the compiled result 6491 will run without error on an older system. 6492 6493 '--enable-runtime-pseudo-relocs' is not the default; it must be 6494 explicitly enabled as needed. 6495 6496_direct linking to a dll_ 6497 The cygwin/mingw ports of 'ld' support the direct linking, 6498 including data symbols, to a dll without the usage of any import 6499 libraries. This is much faster and uses much less memory than does 6500 the traditional import library method, especially when linking 6501 large libraries or applications. When 'ld' creates an import lib, 6502 each function or variable exported from the dll is stored in its 6503 own bfd, even though a single bfd could contain many exports. The 6504 overhead involved in storing, loading, and processing so many bfd's 6505 is quite large, and explains the tremendous time, memory, and 6506 storage needed to link against particularly large or complex 6507 libraries when using import libs. 6508 6509 Linking directly to a dll uses no extra command-line switches other 6510 than '-L' and '-l', because 'ld' already searches for a number of 6511 names to match each library. All that is needed from the 6512 developer's perspective is an understanding of this search, in 6513 order to force ld to select the dll instead of an import library. 6514 6515 For instance, when ld is called with the argument '-lxxx' it will 6516 attempt to find, in the first directory of its search path, 6517 6518 libxxx.dll.a 6519 xxx.dll.a 6520 libxxx.a 6521 xxx.lib 6522 libxxx.lib 6523 cygxxx.dll (*) 6524 libxxx.dll 6525 xxx.dll 6526 6527 before moving on to the next directory in the search path. 6528 6529 (*) Actually, this is not 'cygxxx.dll' but in fact is 6530 '<prefix>xxx.dll', where '<prefix>' is set by the 'ld' option 6531 '--dll-search-prefix=<prefix>'. In the case of cygwin, the 6532 standard gcc spec file includes '--dll-search-prefix=cyg', so in 6533 effect we actually search for 'cygxxx.dll'. 6534 6535 Other win32-based unix environments, such as mingw or pw32, may use 6536 other '<prefix>'es, although at present only cygwin makes use of 6537 this feature. It was originally intended to help avoid name 6538 conflicts among dll's built for the various win32/un*x 6539 environments, so that (for example) two versions of a zlib dll 6540 could coexist on the same machine. 6541 6542 The generic cygwin/mingw path layout uses a 'bin' directory for 6543 applications and dll's and a 'lib' directory for the import 6544 libraries (using cygwin nomenclature): 6545 6546 bin/ 6547 cygxxx.dll 6548 lib/ 6549 libxxx.dll.a (in case of dll's) 6550 libxxx.a (in case of static archive) 6551 6552 Linking directly to a dll without using the import library can be 6553 done two ways: 6554 6555 1. Use the dll directly by adding the 'bin' path to the link line 6556 gcc -Wl,-verbose -o a.exe -L../bin/ -lxxx 6557 6558 However, as the dll's often have version numbers appended to their 6559 names ('cygncurses-5.dll') this will often fail, unless one 6560 specifies '-L../bin -lncurses-5' to include the version. Import 6561 libs are generally not versioned, and do not have this difficulty. 6562 6563 2. Create a symbolic link from the dll to a file in the 'lib' 6564 directory according to the above mentioned search pattern. This 6565 should be used to avoid unwanted changes in the tools needed for 6566 making the app/dll. 6567 6568 ln -s bin/cygxxx.dll lib/[cyg|lib|]xxx.dll[.a] 6569 6570 Then you can link without any make environment changes. 6571 6572 gcc -Wl,-verbose -o a.exe -L../lib/ -lxxx 6573 6574 This technique also avoids the version number problems, because the 6575 following is perfectly legal 6576 6577 bin/ 6578 cygxxx-5.dll 6579 lib/ 6580 libxxx.dll.a -> ../bin/cygxxx-5.dll 6581 6582 Linking directly to a dll without using an import lib will work 6583 even when auto-import features are exercised, and even when 6584 '--enable-runtime-pseudo-relocs' is used. 6585 6586 Given the improvements in speed and memory usage, one might 6587 justifiably wonder why import libraries are used at all. There are 6588 three reasons: 6589 6590 1. Until recently, the link-directly-to-dll functionality did 6591 _not_ work with auto-imported data. 6592 6593 2. Sometimes it is necessary to include pure static objects within 6594 the import library (which otherwise contains only bfd's for 6595 indirection symbols that point to the exports of a dll). Again, 6596 the import lib for the cygwin kernel makes use of this ability, and 6597 it is not possible to do this without an import lib. 6598 6599 3. Symbol aliases can only be resolved using an import lib. This 6600 is critical when linking against OS-supplied dll's (eg, the win32 6601 API) in which symbols are usually exported as undecorated aliases 6602 of their stdcall-decorated assembly names. 6603 6604 So, import libs are not going away. But the ability to replace 6605 true import libs with a simple symbolic link to (or a copy of) a 6606 dll, in many cases, is a useful addition to the suite of tools 6607 binutils makes available to the win32 developer. Given the massive 6608 improvements in memory requirements during linking, storage 6609 requirements, and linking speed, we expect that many developers 6610 will soon begin to use this feature whenever possible. 6611 6612_symbol aliasing_ 6613 _adding additional names_ 6614 Sometimes, it is useful to export symbols with additional 6615 names. A symbol 'foo' will be exported as 'foo', but it can 6616 also be exported as '_foo' by using special directives in the 6617 DEF file when creating the dll. This will affect also the 6618 optional created import library. Consider the following DEF 6619 file: 6620 6621 LIBRARY "xyz.dll" BASE=0x61000000 6622 6623 EXPORTS 6624 foo 6625 _foo = foo 6626 6627 The line '_foo = foo' maps the symbol 'foo' to '_foo'. 6628 6629 Another method for creating a symbol alias is to create it in 6630 the source code using the "weak" attribute: 6631 6632 void foo () { /* Do something. */; } 6633 void _foo () __attribute__ ((weak, alias ("foo"))); 6634 6635 See the gcc manual for more information about attributes and 6636 weak symbols. 6637 6638 _renaming symbols_ 6639 Sometimes it is useful to rename exports. For instance, the 6640 cygwin kernel does this regularly. A symbol '_foo' can be 6641 exported as 'foo' but not as '_foo' by using special 6642 directives in the DEF file. (This will also affect the import 6643 library, if it is created). In the following example: 6644 6645 LIBRARY "xyz.dll" BASE=0x61000000 6646 6647 EXPORTS 6648 _foo = foo 6649 6650 The line '_foo = foo' maps the exported symbol 'foo' to 6651 '_foo'. 6652 6653 Note: using a DEF file disables the default auto-export behavior, 6654 unless the '--export-all-symbols' command line option is used. If, 6655 however, you are trying to rename symbols, then you should list 6656 _all_ desired exports in the DEF file, including the symbols that 6657 are not being renamed, and do _not_ use the '--export-all-symbols' 6658 option. If you list only the renamed symbols in the DEF file, and 6659 use '--export-all-symbols' to handle the other symbols, then the 6660 both the new names _and_ the original names for the renamed symbols 6661 will be exported. In effect, you'd be aliasing those symbols, not 6662 renaming them, which is probably not what you wanted. 6663 6664_weak externals_ 6665 The Windows object format, PE, specifies a form of weak symbols 6666 called weak externals. When a weak symbol is linked and the symbol 6667 is not defined, the weak symbol becomes an alias for some other 6668 symbol. There are three variants of weak externals: 6669 * Definition is searched for in objects and libraries, 6670 historically called lazy externals. 6671 * Definition is searched for only in other objects, not in 6672 libraries. This form is not presently implemented. 6673 * No search; the symbol is an alias. This form is not presently 6674 implemented. 6675 As a GNU extension, weak symbols that do not specify an alternate 6676 symbol are supported. If the symbol is undefined when linking, the 6677 symbol uses a default value. 6678 6679_aligned common symbols_ 6680 As a GNU extension to the PE file format, it is possible to specify 6681 the desired alignment for a common symbol. This information is 6682 conveyed from the assembler or compiler to the linker by means of 6683 GNU-specific commands carried in the object file's '.drectve' 6684 section, which are recognized by 'ld' and respected when laying out 6685 the common symbols. Native tools will be able to process object 6686 files employing this GNU extension, but will fail to respect the 6687 alignment instructions, and may issue noisy warnings about unknown 6688 linker directives. 6689 6690 6691File: ld.info, Node: Xtensa, Prev: WIN32, Up: Machine Dependent 6692 66934.17 'ld' and Xtensa Processors 6694=============================== 6695 6696The default 'ld' behavior for Xtensa processors is to interpret 6697'SECTIONS' commands so that lists of explicitly named sections in a 6698specification with a wildcard file will be interleaved when necessary to 6699keep literal pools within the range of PC-relative load offsets. For 6700example, with the command: 6701 6702 SECTIONS 6703 { 6704 .text : { 6705 *(.literal .text) 6706 } 6707 } 6708 6709'ld' may interleave some of the '.literal' and '.text' sections from 6710different object files to ensure that the literal pools are within the 6711range of PC-relative load offsets. A valid interleaving might place the 6712'.literal' sections from an initial group of files followed by the 6713'.text' sections of that group of files. Then, the '.literal' sections 6714from the rest of the files and the '.text' sections from the rest of the 6715files would follow. 6716 6717 Relaxation is enabled by default for the Xtensa version of 'ld' and 6718provides two important link-time optimizations. The first optimization 6719is to combine identical literal values to reduce code size. A redundant 6720literal will be removed and all the 'L32R' instructions that use it will 6721be changed to reference an identical literal, as long as the location of 6722the replacement literal is within the offset range of all the 'L32R' 6723instructions. The second optimization is to remove unnecessary overhead 6724from assembler-generated "longcall" sequences of 'L32R'/'CALLXN' when 6725the target functions are within range of direct 'CALLN' instructions. 6726 6727 For each of these cases where an indirect call sequence can be 6728optimized to a direct call, the linker will change the 'CALLXN' 6729instruction to a 'CALLN' instruction, remove the 'L32R' instruction, and 6730remove the literal referenced by the 'L32R' instruction if it is not 6731used for anything else. Removing the 'L32R' instruction always reduces 6732code size but can potentially hurt performance by changing the alignment 6733of subsequent branch targets. By default, the linker will always 6734preserve alignments, either by switching some instructions between 673524-bit encodings and the equivalent density instructions or by inserting 6736a no-op in place of the 'L32R' instruction that was removed. If code 6737size is more important than performance, the '--size-opt' option can be 6738used to prevent the linker from widening density instructions or 6739inserting no-ops, except in a few cases where no-ops are required for 6740correctness. 6741 6742 The following Xtensa-specific command-line options can be used to 6743control the linker: 6744 6745'--size-opt' 6746 When optimizing indirect calls to direct calls, optimize for code 6747 size more than performance. With this option, the linker will not 6748 insert no-ops or widen density instructions to preserve branch 6749 target alignment. There may still be some cases where no-ops are 6750 required to preserve the correctness of the code. 6751 6752 6753File: ld.info, Node: BFD, Next: Reporting Bugs, Prev: Machine Dependent, Up: Top 6754 67555 BFD 6756***** 6757 6758The linker accesses object and archive files using the BFD libraries. 6759These libraries allow the linker to use the same routines to operate on 6760object files whatever the object file format. A different object file 6761format can be supported simply by creating a new BFD back end and adding 6762it to the library. To conserve runtime memory, however, the linker and 6763associated tools are usually configured to support only a subset of the 6764object file formats available. You can use 'objdump -i' (*note objdump: 6765(binutils.info)objdump.) to list all the formats available for your 6766configuration. 6767 6768 As with most implementations, BFD is a compromise between several 6769conflicting requirements. The major factor influencing BFD design was 6770efficiency: any time used converting between formats is time which would 6771not have been spent had BFD not been involved. This is partly offset by 6772abstraction payback; since BFD simplifies applications and back ends, 6773more time and care may be spent optimizing algorithms for a greater 6774speed. 6775 6776 One minor artifact of the BFD solution which you should bear in mind 6777is the potential for information loss. There are two places where 6778useful information can be lost using the BFD mechanism: during 6779conversion and during output. *Note BFD information loss::. 6780 6781* Menu: 6782 6783* BFD outline:: How it works: an outline of BFD 6784 6785 6786File: ld.info, Node: BFD outline, Up: BFD 6787 67885.1 How It Works: An Outline of BFD 6789=================================== 6790 6791When an object file is opened, BFD subroutines automatically determine 6792the format of the input object file. They then build a descriptor in 6793memory with pointers to routines that will be used to access elements of 6794the object file's data structures. 6795 6796 As different information from the object files is required, BFD reads 6797from different sections of the file and processes them. For example, a 6798very common operation for the linker is processing symbol tables. Each 6799BFD back end provides a routine for converting between the object file's 6800representation of symbols and an internal canonical format. When the 6801linker asks for the symbol table of an object file, it calls through a 6802memory pointer to the routine from the relevant BFD back end which reads 6803and converts the table into a canonical form. The linker then operates 6804upon the canonical form. When the link is finished and the linker 6805writes the output file's symbol table, another BFD back end routine is 6806called to take the newly created symbol table and convert it into the 6807chosen output format. 6808 6809* Menu: 6810 6811* BFD information loss:: Information Loss 6812* Canonical format:: The BFD canonical object-file format 6813 6814 6815File: ld.info, Node: BFD information loss, Next: Canonical format, Up: BFD outline 6816 68175.1.1 Information Loss 6818---------------------- 6819 6820_Information can be lost during output._ The output formats supported 6821by BFD do not provide identical facilities, and information which can be 6822described in one form has nowhere to go in another format. One example 6823of this is alignment information in 'b.out'. There is nowhere in an 6824'a.out' format file to store alignment information on the contained 6825data, so when a file is linked from 'b.out' and an 'a.out' image is 6826produced, alignment information will not propagate to the output file. 6827(The linker will still use the alignment information internally, so the 6828link is performed correctly). 6829 6830 Another example is COFF section names. COFF files may contain an 6831unlimited number of sections, each one with a textual section name. If 6832the target of the link is a format which does not have many sections 6833(e.g., 'a.out') or has sections without names (e.g., the Oasys format), 6834the link cannot be done simply. You can circumvent this problem by 6835describing the desired input-to-output section mapping with the linker 6836command language. 6837 6838 _Information can be lost during canonicalization._ The BFD internal 6839canonical form of the external formats is not exhaustive; there are 6840structures in input formats for which there is no direct representation 6841internally. This means that the BFD back ends cannot maintain all 6842possible data richness through the transformation between external to 6843internal and back to external formats. 6844 6845 This limitation is only a problem when an application reads one 6846format and writes another. Each BFD back end is responsible for 6847maintaining as much data as possible, and the internal BFD canonical 6848form has structures which are opaque to the BFD core, and exported only 6849to the back ends. When a file is read in one format, the canonical form 6850is generated for BFD and the application. At the same time, the back 6851end saves away any information which may otherwise be lost. If the data 6852is then written back in the same format, the back end routine will be 6853able to use the canonical form provided by the BFD core as well as the 6854information it prepared earlier. Since there is a great deal of 6855commonality between back ends, there is no information lost when linking 6856or copying big endian COFF to little endian COFF, or 'a.out' to 'b.out'. 6857When a mixture of formats is linked, the information is only lost from 6858the files whose format differs from the destination. 6859 6860 6861File: ld.info, Node: Canonical format, Prev: BFD information loss, Up: BFD outline 6862 68635.1.2 The BFD canonical object-file format 6864------------------------------------------ 6865 6866The greatest potential for loss of information occurs when there is the 6867least overlap between the information provided by the source format, 6868that stored by the canonical format, and that needed by the destination 6869format. A brief description of the canonical form may help you 6870understand which kinds of data you can count on preserving across 6871conversions. 6872 6873_files_ 6874 Information stored on a per-file basis includes target machine 6875 architecture, particular implementation format type, a demand 6876 pageable bit, and a write protected bit. Information like Unix 6877 magic numbers is not stored here--only the magic numbers' meaning, 6878 so a 'ZMAGIC' file would have both the demand pageable bit and the 6879 write protected text bit set. The byte order of the target is 6880 stored on a per-file basis, so that big- and little-endian object 6881 files may be used with one another. 6882 6883_sections_ 6884 Each section in the input file contains the name of the section, 6885 the section's original address in the object file, size and 6886 alignment information, various flags, and pointers into other BFD 6887 data structures. 6888 6889_symbols_ 6890 Each symbol contains a pointer to the information for the object 6891 file which originally defined it, its name, its value, and various 6892 flag bits. When a BFD back end reads in a symbol table, it 6893 relocates all symbols to make them relative to the base of the 6894 section where they were defined. Doing this ensures that each 6895 symbol points to its containing section. Each symbol also has a 6896 varying amount of hidden private data for the BFD back end. Since 6897 the symbol points to the original file, the private data format for 6898 that symbol is accessible. 'ld' can operate on a collection of 6899 symbols of wildly different formats without problems. 6900 6901 Normal global and simple local symbols are maintained on output, so 6902 an output file (no matter its format) will retain symbols pointing 6903 to functions and to global, static, and common variables. Some 6904 symbol information is not worth retaining; in 'a.out', type 6905 information is stored in the symbol table as long symbol names. 6906 This information would be useless to most COFF debuggers; the 6907 linker has command line switches to allow users to throw it away. 6908 6909 There is one word of type information within the symbol, so if the 6910 format supports symbol type information within symbols (for 6911 example, COFF, Oasys) and the type is simple enough to fit within 6912 one word (nearly everything but aggregates), the information will 6913 be preserved. 6914 6915_relocation level_ 6916 Each canonical BFD relocation record contains a pointer to the 6917 symbol to relocate to, the offset of the data to relocate, the 6918 section the data is in, and a pointer to a relocation type 6919 descriptor. Relocation is performed by passing messages through 6920 the relocation type descriptor and the symbol pointer. Therefore, 6921 relocations can be performed on output data using a relocation 6922 method that is only available in one of the input formats. For 6923 instance, Oasys provides a byte relocation format. A relocation 6924 record requesting this relocation type would point indirectly to a 6925 routine to perform this, so the relocation may be performed on a 6926 byte being written to a 68k COFF file, even though 68k COFF has no 6927 such relocation type. 6928 6929_line numbers_ 6930 Object formats can contain, for debugging purposes, some form of 6931 mapping between symbols, source line numbers, and addresses in the 6932 output file. These addresses have to be relocated along with the 6933 symbol information. Each symbol with an associated list of line 6934 number records points to the first record of the list. The head of 6935 a line number list consists of a pointer to the symbol, which 6936 allows finding out the address of the function whose line number is 6937 being described. The rest of the list is made up of pairs: offsets 6938 into the section and line numbers. Any format which can simply 6939 derive this information can pass it successfully between formats. 6940 6941 6942File: ld.info, Node: Reporting Bugs, Next: MRI, Prev: BFD, Up: Top 6943 69446 Reporting Bugs 6945**************** 6946 6947Your bug reports play an essential role in making 'ld' reliable. 6948 6949 Reporting a bug may help you by bringing a solution to your problem, 6950or it may not. But in any case the principal function of a bug report 6951is to help the entire community by making the next version of 'ld' work 6952better. Bug reports are your contribution to the maintenance of 'ld'. 6953 6954 In order for a bug report to serve its purpose, you must include the 6955information that enables us to fix the bug. 6956 6957* Menu: 6958 6959* Bug Criteria:: Have you found a bug? 6960* Bug Reporting:: How to report bugs 6961 6962 6963File: ld.info, Node: Bug Criteria, Next: Bug Reporting, Up: Reporting Bugs 6964 69656.1 Have You Found a Bug? 6966========================= 6967 6968If you are not sure whether you have found a bug, here are some 6969guidelines: 6970 6971 * If the linker gets a fatal signal, for any input whatever, that is 6972 a 'ld' bug. Reliable linkers never crash. 6973 6974 * If 'ld' produces an error message for valid input, that is a bug. 6975 6976 * If 'ld' does not produce an error message for invalid input, that 6977 may be a bug. In the general case, the linker can not verify that 6978 object files are correct. 6979 6980 * If you are an experienced user of linkers, your suggestions for 6981 improvement of 'ld' are welcome in any case. 6982 6983 6984File: ld.info, Node: Bug Reporting, Prev: Bug Criteria, Up: Reporting Bugs 6985 69866.2 How to Report Bugs 6987====================== 6988 6989A number of companies and individuals offer support for GNU products. 6990If you obtained 'ld' from a support organization, we recommend you 6991contact that organization first. 6992 6993 You can find contact information for many support companies and 6994individuals in the file 'etc/SERVICE' in the GNU Emacs distribution. 6995 6996 Otherwise, send bug reports for 'ld' to 6997<http://www.sourceware.org/bugzilla/>. 6998 6999 The fundamental principle of reporting bugs usefully is this: *report 7000all the facts*. If you are not sure whether to state a fact or leave it 7001out, state it! 7002 7003 Often people omit facts because they think they know what causes the 7004problem and assume that some details do not matter. Thus, you might 7005assume that the name of a symbol you use in an example does not matter. 7006Well, probably it does not, but one cannot be sure. Perhaps the bug is 7007a stray memory reference which happens to fetch from the location where 7008that name is stored in memory; perhaps, if the name were different, the 7009contents of that location would fool the linker into doing the right 7010thing despite the bug. Play it safe and give a specific, complete 7011example. That is the easiest thing for you to do, and the most helpful. 7012 7013 Keep in mind that the purpose of a bug report is to enable us to fix 7014the bug if it is new to us. Therefore, always write your bug reports on 7015the assumption that the bug has not been reported previously. 7016 7017 Sometimes people give a few sketchy facts and ask, "Does this ring a 7018bell?" This cannot help us fix a bug, so it is basically useless. We 7019respond by asking for enough details to enable us to investigate. You 7020might as well expedite matters by sending them to begin with. 7021 7022 To enable us to fix the bug, you should include all these things: 7023 7024 * The version of 'ld'. 'ld' announces it if you start it with the 7025 '--version' argument. 7026 7027 Without this, we will not know whether there is any point in 7028 looking for the bug in the current version of 'ld'. 7029 7030 * Any patches you may have applied to the 'ld' source, including any 7031 patches made to the 'BFD' library. 7032 7033 * The type of machine you are using, and the operating system name 7034 and version number. 7035 7036 * What compiler (and its version) was used to compile 'ld'--e.g. 7037 "'gcc-2.7'". 7038 7039 * The command arguments you gave the linker to link your example and 7040 observe the bug. To guarantee you will not omit something 7041 important, list them all. A copy of the Makefile (or the output 7042 from make) is sufficient. 7043 7044 If we were to try to guess the arguments, we would probably guess 7045 wrong and then we might not encounter the bug. 7046 7047 * A complete input file, or set of input files, that will reproduce 7048 the bug. It is generally most helpful to send the actual object 7049 files provided that they are reasonably small. Say no more than 7050 10K. For bigger files you can either make them available by FTP or 7051 HTTP or else state that you are willing to send the object file(s) 7052 to whomever requests them. (Note - your email will be going to a 7053 mailing list, so we do not want to clog it up with large 7054 attachments). But small attachments are best. 7055 7056 If the source files were assembled using 'gas' or compiled using 7057 'gcc', then it may be OK to send the source files rather than the 7058 object files. In this case, be sure to say exactly what version of 7059 'gas' or 'gcc' was used to produce the object files. Also say how 7060 'gas' or 'gcc' were configured. 7061 7062 * A description of what behavior you observe that you believe is 7063 incorrect. For example, "It gets a fatal signal." 7064 7065 Of course, if the bug is that 'ld' gets a fatal signal, then we 7066 will certainly notice it. But if the bug is incorrect output, we 7067 might not notice unless it is glaringly wrong. You might as well 7068 not give us a chance to make a mistake. 7069 7070 Even if the problem you experience is a fatal signal, you should 7071 still say so explicitly. Suppose something strange is going on, 7072 such as, your copy of 'ld' is out of sync, or you have encountered 7073 a bug in the C library on your system. (This has happened!) Your 7074 copy might crash and ours would not. If you told us to expect a 7075 crash, then when ours fails to crash, we would know that the bug 7076 was not happening for us. If you had not told us to expect a 7077 crash, then we would not be able to draw any conclusion from our 7078 observations. 7079 7080 * If you wish to suggest changes to the 'ld' source, send us context 7081 diffs, as generated by 'diff' with the '-u', '-c', or '-p' option. 7082 Always send diffs from the old file to the new file. If you even 7083 discuss something in the 'ld' source, refer to it by context, not 7084 by line number. 7085 7086 The line numbers in our development sources will not match those in 7087 your sources. Your line numbers would convey no useful information 7088 to us. 7089 7090 Here are some things that are not necessary: 7091 7092 * A description of the envelope of the bug. 7093 7094 Often people who encounter a bug spend a lot of time investigating 7095 which changes to the input file will make the bug go away and which 7096 changes will not affect it. 7097 7098 This is often time consuming and not very useful, because the way 7099 we will find the bug is by running a single example under the 7100 debugger with breakpoints, not by pure deduction from a series of 7101 examples. We recommend that you save your time for something else. 7102 7103 Of course, if you can find a simpler example to report _instead_ of 7104 the original one, that is a convenience for us. Errors in the 7105 output will be easier to spot, running under the debugger will take 7106 less time, and so on. 7107 7108 However, simplification is not vital; if you do not want to do 7109 this, report the bug anyway and send us the entire test case you 7110 used. 7111 7112 * A patch for the bug. 7113 7114 A patch for the bug does help us if it is a good one. But do not 7115 omit the necessary information, such as the test case, on the 7116 assumption that a patch is all we need. We might see problems with 7117 your patch and decide to fix the problem another way, or we might 7118 not understand it at all. 7119 7120 Sometimes with a program as complicated as 'ld' it is very hard to 7121 construct an example that will make the program follow a certain 7122 path through the code. If you do not send us the example, we will 7123 not be able to construct one, so we will not be able to verify that 7124 the bug is fixed. 7125 7126 And if we cannot understand what bug you are trying to fix, or why 7127 your patch should be an improvement, we will not install it. A 7128 test case will help us to understand. 7129 7130 * A guess about what the bug is or what it depends on. 7131 7132 Such guesses are usually wrong. Even we cannot guess right about 7133 such things without first using the debugger to find the facts. 7134 7135 7136File: ld.info, Node: MRI, Next: GNU Free Documentation License, Prev: Reporting Bugs, Up: Top 7137 7138Appendix A MRI Compatible Script Files 7139************************************** 7140 7141To aid users making the transition to GNU 'ld' from the MRI linker, 'ld' 7142can use MRI compatible linker scripts as an alternative to the more 7143general-purpose linker scripting language described in *note Scripts::. 7144MRI compatible linker scripts have a much simpler command set than the 7145scripting language otherwise used with 'ld'. GNU 'ld' supports the most 7146commonly used MRI linker commands; these commands are described here. 7147 7148 In general, MRI scripts aren't of much use with the 'a.out' object 7149file format, since it only has three sections and MRI scripts lack some 7150features to make use of them. 7151 7152 You can specify a file containing an MRI-compatible script using the 7153'-c' command-line option. 7154 7155 Each command in an MRI-compatible script occupies its own line; each 7156command line starts with the keyword that identifies the command (though 7157blank lines are also allowed for punctuation). If a line of an 7158MRI-compatible script begins with an unrecognized keyword, 'ld' issues a 7159warning message, but continues processing the script. 7160 7161 Lines beginning with '*' are comments. 7162 7163 You can write these commands using all upper-case letters, or all 7164lower case; for example, 'chip' is the same as 'CHIP'. The following 7165list shows only the upper-case form of each command. 7166 7167'ABSOLUTE SECNAME' 7168'ABSOLUTE SECNAME, SECNAME, ... SECNAME' 7169 Normally, 'ld' includes in the output file all sections from all 7170 the input files. However, in an MRI-compatible script, you can use 7171 the 'ABSOLUTE' command to restrict the sections that will be 7172 present in your output program. If the 'ABSOLUTE' command is used 7173 at all in a script, then only the sections named explicitly in 7174 'ABSOLUTE' commands will appear in the linker output. You can 7175 still use other input sections (whatever you select on the command 7176 line, or using 'LOAD') to resolve addresses in the output file. 7177 7178'ALIAS OUT-SECNAME, IN-SECNAME' 7179 Use this command to place the data from input section IN-SECNAME in 7180 a section called OUT-SECNAME in the linker output file. 7181 7182 IN-SECNAME may be an integer. 7183 7184'ALIGN SECNAME = EXPRESSION' 7185 Align the section called SECNAME to EXPRESSION. The EXPRESSION 7186 should be a power of two. 7187 7188'BASE EXPRESSION' 7189 Use the value of EXPRESSION as the lowest address (other than 7190 absolute addresses) in the output file. 7191 7192'CHIP EXPRESSION' 7193'CHIP EXPRESSION, EXPRESSION' 7194 This command does nothing; it is accepted only for compatibility. 7195 7196'END' 7197 This command does nothing whatever; it's only accepted for 7198 compatibility. 7199 7200'FORMAT OUTPUT-FORMAT' 7201 Similar to the 'OUTPUT_FORMAT' command in the more general linker 7202 language, but restricted to S-records, if OUTPUT-FORMAT is 'S' 7203 7204'LIST ANYTHING...' 7205 Print (to the standard output file) a link map, as produced by the 7206 'ld' command-line option '-M'. 7207 7208 The keyword 'LIST' may be followed by anything on the same line, 7209 with no change in its effect. 7210 7211'LOAD FILENAME' 7212'LOAD FILENAME, FILENAME, ... FILENAME' 7213 Include one or more object file FILENAME in the link; this has the 7214 same effect as specifying FILENAME directly on the 'ld' command 7215 line. 7216 7217'NAME OUTPUT-NAME' 7218 OUTPUT-NAME is the name for the program produced by 'ld'; the 7219 MRI-compatible command 'NAME' is equivalent to the command-line 7220 option '-o' or the general script language command 'OUTPUT'. 7221 7222'ORDER SECNAME, SECNAME, ... SECNAME' 7223'ORDER SECNAME SECNAME SECNAME' 7224 Normally, 'ld' orders the sections in its output file in the order 7225 in which they first appear in the input files. In an 7226 MRI-compatible script, you can override this ordering with the 7227 'ORDER' command. The sections you list with 'ORDER' will appear 7228 first in your output file, in the order specified. 7229 7230'PUBLIC NAME=EXPRESSION' 7231'PUBLIC NAME,EXPRESSION' 7232'PUBLIC NAME EXPRESSION' 7233 Supply a value (EXPRESSION) for external symbol NAME used in the 7234 linker input files. 7235 7236'SECT SECNAME, EXPRESSION' 7237'SECT SECNAME=EXPRESSION' 7238'SECT SECNAME EXPRESSION' 7239 You can use any of these three forms of the 'SECT' command to 7240 specify the start address (EXPRESSION) for section SECNAME. If you 7241 have more than one 'SECT' statement for the same SECNAME, only the 7242 _first_ sets the start address. 7243 7244 7245File: ld.info, Node: GNU Free Documentation License, Next: LD Index, Prev: MRI, Up: Top 7246 7247Appendix B GNU Free Documentation License 7248***************************************** 7249 7250 Version 1.3, 3 November 2008 7251 7252 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 7253 <http://fsf.org/> 7254 7255 Everyone is permitted to copy and distribute verbatim copies 7256 of this license document, but changing it is not allowed. 7257 7258 0. PREAMBLE 7259 7260 The purpose of this License is to make a manual, textbook, or other 7261 functional and useful document "free" in the sense of freedom: to 7262 assure everyone the effective freedom to copy and redistribute it, 7263 with or without modifying it, either commercially or 7264 noncommercially. Secondarily, this License preserves for the 7265 author and publisher a way to get credit for their work, while not 7266 being considered responsible for modifications made by others. 7267 7268 This License is a kind of "copyleft", which means that derivative 7269 works of the document must themselves be free in the same sense. 7270 It complements the GNU General Public License, which is a copyleft 7271 license designed for free software. 7272 7273 We have designed this License in order to use it for manuals for 7274 free software, because free software needs free documentation: a 7275 free program should come with manuals providing the same freedoms 7276 that the software does. But this License is not limited to 7277 software manuals; it can be used for any textual work, regardless 7278 of subject matter or whether it is published as a printed book. We 7279 recommend this License principally for works whose purpose is 7280 instruction or reference. 7281 7282 1. APPLICABILITY AND DEFINITIONS 7283 7284 This License applies to any manual or other work, in any medium, 7285 that contains a notice placed by the copyright holder saying it can 7286 be distributed under the terms of this License. Such a notice 7287 grants a world-wide, royalty-free license, unlimited in duration, 7288 to use that work under the conditions stated herein. The 7289 "Document", below, refers to any such manual or work. Any member 7290 of the public is a licensee, and is addressed as "you". You accept 7291 the license if you copy, modify or distribute the work in a way 7292 requiring permission under copyright law. 7293 7294 A "Modified Version" of the Document means any work containing the 7295 Document or a portion of it, either copied verbatim, or with 7296 modifications and/or translated into another language. 7297 7298 A "Secondary Section" is a named appendix or a front-matter section 7299 of the Document that deals exclusively with the relationship of the 7300 publishers or authors of the Document to the Document's overall 7301 subject (or to related matters) and contains nothing that could 7302 fall directly within that overall subject. (Thus, if the Document 7303 is in part a textbook of mathematics, a Secondary Section may not 7304 explain any mathematics.) The relationship could be a matter of 7305 historical connection with the subject or with related matters, or 7306 of legal, commercial, philosophical, ethical or political position 7307 regarding them. 7308 7309 The "Invariant Sections" are certain Secondary Sections whose 7310 titles are designated, as being those of Invariant Sections, in the 7311 notice that says that the Document is released under this License. 7312 If a section does not fit the above definition of Secondary then it 7313 is not allowed to be designated as Invariant. The Document may 7314 contain zero Invariant Sections. If the Document does not identify 7315 any Invariant Sections then there are none. 7316 7317 The "Cover Texts" are certain short passages of text that are 7318 listed, as Front-Cover Texts or Back-Cover Texts, in the notice 7319 that says that the Document is released under this License. A 7320 Front-Cover Text may be at most 5 words, and a Back-Cover Text may 7321 be at most 25 words. 7322 7323 A "Transparent" copy of the Document means a machine-readable copy, 7324 represented in a format whose specification is available to the 7325 general public, that is suitable for revising the document 7326 straightforwardly with generic text editors or (for images composed 7327 of pixels) generic paint programs or (for drawings) some widely 7328 available drawing editor, and that is suitable for input to text 7329 formatters or for automatic translation to a variety of formats 7330 suitable for input to text formatters. A copy made in an otherwise 7331 Transparent file format whose markup, or absence of markup, has 7332 been arranged to thwart or discourage subsequent modification by 7333 readers is not Transparent. An image format is not Transparent if 7334 used for any substantial amount of text. A copy that is not 7335 "Transparent" is called "Opaque". 7336 7337 Examples of suitable formats for Transparent copies include plain 7338 ASCII without markup, Texinfo input format, LaTeX input format, 7339 SGML or XML using a publicly available DTD, and standard-conforming 7340 simple HTML, PostScript or PDF designed for human modification. 7341 Examples of transparent image formats include PNG, XCF and JPG. 7342 Opaque formats include proprietary formats that can be read and 7343 edited only by proprietary word processors, SGML or XML for which 7344 the DTD and/or processing tools are not generally available, and 7345 the machine-generated HTML, PostScript or PDF produced by some word 7346 processors for output purposes only. 7347 7348 The "Title Page" means, for a printed book, the title page itself, 7349 plus such following pages as are needed to hold, legibly, the 7350 material this License requires to appear in the title page. For 7351 works in formats which do not have any title page as such, "Title 7352 Page" means the text near the most prominent appearance of the 7353 work's title, preceding the beginning of the body of the text. 7354 7355 The "publisher" means any person or entity that distributes copies 7356 of the Document to the public. 7357 7358 A section "Entitled XYZ" means a named subunit of the Document 7359 whose title either is precisely XYZ or contains XYZ in parentheses 7360 following text that translates XYZ in another language. (Here XYZ 7361 stands for a specific section name mentioned below, such as 7362 "Acknowledgements", "Dedications", "Endorsements", or "History".) 7363 To "Preserve the Title" of such a section when you modify the 7364 Document means that it remains a section "Entitled XYZ" according 7365 to this definition. 7366 7367 The Document may include Warranty Disclaimers next to the notice 7368 which states that this License applies to the Document. These 7369 Warranty Disclaimers are considered to be included by reference in 7370 this License, but only as regards disclaiming warranties: any other 7371 implication that these Warranty Disclaimers may have is void and 7372 has no effect on the meaning of this License. 7373 7374 2. VERBATIM COPYING 7375 7376 You may copy and distribute the Document in any medium, either 7377 commercially or noncommercially, provided that this License, the 7378 copyright notices, and the license notice saying this License 7379 applies to the Document are reproduced in all copies, and that you 7380 add no other conditions whatsoever to those of this License. You 7381 may not use technical measures to obstruct or control the reading 7382 or further copying of the copies you make or distribute. However, 7383 you may accept compensation in exchange for copies. If you 7384 distribute a large enough number of copies you must also follow the 7385 conditions in section 3. 7386 7387 You may also lend copies, under the same conditions stated above, 7388 and you may publicly display copies. 7389 7390 3. COPYING IN QUANTITY 7391 7392 If you publish printed copies (or copies in media that commonly 7393 have printed covers) of the Document, numbering more than 100, and 7394 the Document's license notice requires Cover Texts, you must 7395 enclose the copies in covers that carry, clearly and legibly, all 7396 these Cover Texts: Front-Cover Texts on the front cover, and 7397 Back-Cover Texts on the back cover. Both covers must also clearly 7398 and legibly identify you as the publisher of these copies. The 7399 front cover must present the full title with all words of the title 7400 equally prominent and visible. You may add other material on the 7401 covers in addition. Copying with changes limited to the covers, as 7402 long as they preserve the title of the Document and satisfy these 7403 conditions, can be treated as verbatim copying in other respects. 7404 7405 If the required texts for either cover are too voluminous to fit 7406 legibly, you should put the first ones listed (as many as fit 7407 reasonably) on the actual cover, and continue the rest onto 7408 adjacent pages. 7409 7410 If you publish or distribute Opaque copies of the Document 7411 numbering more than 100, you must either include a machine-readable 7412 Transparent copy along with each Opaque copy, or state in or with 7413 each Opaque copy a computer-network location from which the general 7414 network-using public has access to download using public-standard 7415 network protocols a complete Transparent copy of the Document, free 7416 of added material. If you use the latter option, you must take 7417 reasonably prudent steps, when you begin distribution of Opaque 7418 copies in quantity, to ensure that this Transparent copy will 7419 remain thus accessible at the stated location until at least one 7420 year after the last time you distribute an Opaque copy (directly or 7421 through your agents or retailers) of that edition to the public. 7422 7423 It is requested, but not required, that you contact the authors of 7424 the Document well before redistributing any large number of copies, 7425 to give them a chance to provide you with an updated version of the 7426 Document. 7427 7428 4. MODIFICATIONS 7429 7430 You may copy and distribute a Modified Version of the Document 7431 under the conditions of sections 2 and 3 above, provided that you 7432 release the Modified Version under precisely this License, with the 7433 Modified Version filling the role of the Document, thus licensing 7434 distribution and modification of the Modified Version to whoever 7435 possesses a copy of it. In addition, you must do these things in 7436 the Modified Version: 7437 7438 A. Use in the Title Page (and on the covers, if any) a title 7439 distinct from that of the Document, and from those of previous 7440 versions (which should, if there were any, be listed in the 7441 History section of the Document). You may use the same title 7442 as a previous version if the original publisher of that 7443 version gives permission. 7444 7445 B. List on the Title Page, as authors, one or more persons or 7446 entities responsible for authorship of the modifications in 7447 the Modified Version, together with at least five of the 7448 principal authors of the Document (all of its principal 7449 authors, if it has fewer than five), unless they release you 7450 from this requirement. 7451 7452 C. State on the Title page the name of the publisher of the 7453 Modified Version, as the publisher. 7454 7455 D. Preserve all the copyright notices of the Document. 7456 7457 E. Add an appropriate copyright notice for your modifications 7458 adjacent to the other copyright notices. 7459 7460 F. Include, immediately after the copyright notices, a license 7461 notice giving the public permission to use the Modified 7462 Version under the terms of this License, in the form shown in 7463 the Addendum below. 7464 7465 G. Preserve in that license notice the full lists of Invariant 7466 Sections and required Cover Texts given in the Document's 7467 license notice. 7468 7469 H. Include an unaltered copy of this License. 7470 7471 I. Preserve the section Entitled "History", Preserve its Title, 7472 and add to it an item stating at least the title, year, new 7473 authors, and publisher of the Modified Version as given on the 7474 Title Page. If there is no section Entitled "History" in the 7475 Document, create one stating the title, year, authors, and 7476 publisher of the Document as given on its Title Page, then add 7477 an item describing the Modified Version as stated in the 7478 previous sentence. 7479 7480 J. Preserve the network location, if any, given in the Document 7481 for public access to a Transparent copy of the Document, and 7482 likewise the network locations given in the Document for 7483 previous versions it was based on. These may be placed in the 7484 "History" section. You may omit a network location for a work 7485 that was published at least four years before the Document 7486 itself, or if the original publisher of the version it refers 7487 to gives permission. 7488 7489 K. For any section Entitled "Acknowledgements" or "Dedications", 7490 Preserve the Title of the section, and preserve in the section 7491 all the substance and tone of each of the contributor 7492 acknowledgements and/or dedications given therein. 7493 7494 L. Preserve all the Invariant Sections of the Document, unaltered 7495 in their text and in their titles. Section numbers or the 7496 equivalent are not considered part of the section titles. 7497 7498 M. Delete any section Entitled "Endorsements". Such a section 7499 may not be included in the Modified Version. 7500 7501 N. Do not retitle any existing section to be Entitled 7502 "Endorsements" or to conflict in title with any Invariant 7503 Section. 7504 7505 O. Preserve any Warranty Disclaimers. 7506 7507 If the Modified Version includes new front-matter sections or 7508 appendices that qualify as Secondary Sections and contain no 7509 material copied from the Document, you may at your option designate 7510 some or all of these sections as invariant. To do this, add their 7511 titles to the list of Invariant Sections in the Modified Version's 7512 license notice. These titles must be distinct from any other 7513 section titles. 7514 7515 You may add a section Entitled "Endorsements", provided it contains 7516 nothing but endorsements of your Modified Version by various 7517 parties--for example, statements of peer review or that the text 7518 has been approved by an organization as the authoritative 7519 definition of a standard. 7520 7521 You may add a passage of up to five words as a Front-Cover Text, 7522 and a passage of up to 25 words as a Back-Cover Text, to the end of 7523 the list of Cover Texts in the Modified Version. Only one passage 7524 of Front-Cover Text and one of Back-Cover Text may be added by (or 7525 through arrangements made by) any one entity. If the Document 7526 already includes a cover text for the same cover, previously added 7527 by you or by arrangement made by the same entity you are acting on 7528 behalf of, you may not add another; but you may replace the old 7529 one, on explicit permission from the previous publisher that added 7530 the old one. 7531 7532 The author(s) and publisher(s) of the Document do not by this 7533 License give permission to use their names for publicity for or to 7534 assert or imply endorsement of any Modified Version. 7535 7536 5. COMBINING DOCUMENTS 7537 7538 You may combine the Document with other documents released under 7539 this License, under the terms defined in section 4 above for 7540 modified versions, provided that you include in the combination all 7541 of the Invariant Sections of all of the original documents, 7542 unmodified, and list them all as Invariant Sections of your 7543 combined work in its license notice, and that you preserve all 7544 their Warranty Disclaimers. 7545 7546 The combined work need only contain one copy of this License, and 7547 multiple identical Invariant Sections may be replaced with a single 7548 copy. If there are multiple Invariant Sections with the same name 7549 but different contents, make the title of each such section unique 7550 by adding at the end of it, in parentheses, the name of the 7551 original author or publisher of that section if known, or else a 7552 unique number. Make the same adjustment to the section titles in 7553 the list of Invariant Sections in the license notice of the 7554 combined work. 7555 7556 In the combination, you must combine any sections Entitled 7557 "History" in the various original documents, forming one section 7558 Entitled "History"; likewise combine any sections Entitled 7559 "Acknowledgements", and any sections Entitled "Dedications". You 7560 must delete all sections Entitled "Endorsements." 7561 7562 6. COLLECTIONS OF DOCUMENTS 7563 7564 You may make a collection consisting of the Document and other 7565 documents released under this License, and replace the individual 7566 copies of this License in the various documents with a single copy 7567 that is included in the collection, provided that you follow the 7568 rules of this License for verbatim copying of each of the documents 7569 in all other respects. 7570 7571 You may extract a single document from such a collection, and 7572 distribute it individually under this License, provided you insert 7573 a copy of this License into the extracted document, and follow this 7574 License in all other respects regarding verbatim copying of that 7575 document. 7576 7577 7. AGGREGATION WITH INDEPENDENT WORKS 7578 7579 A compilation of the Document or its derivatives with other 7580 separate and independent documents or works, in or on a volume of a 7581 storage or distribution medium, is called an "aggregate" if the 7582 copyright resulting from the compilation is not used to limit the 7583 legal rights of the compilation's users beyond what the individual 7584 works permit. When the Document is included in an aggregate, this 7585 License does not apply to the other works in the aggregate which 7586 are not themselves derivative works of the Document. 7587 7588 If the Cover Text requirement of section 3 is applicable to these 7589 copies of the Document, then if the Document is less than one half 7590 of the entire aggregate, the Document's Cover Texts may be placed 7591 on covers that bracket the Document within the aggregate, or the 7592 electronic equivalent of covers if the Document is in electronic 7593 form. Otherwise they must appear on printed covers that bracket 7594 the whole aggregate. 7595 7596 8. TRANSLATION 7597 7598 Translation is considered a kind of modification, so you may 7599 distribute translations of the Document under the terms of section 7600 4. Replacing Invariant Sections with translations requires special 7601 permission from their copyright holders, but you may include 7602 translations of some or all Invariant Sections in addition to the 7603 original versions of these Invariant Sections. You may include a 7604 translation of this License, and all the license notices in the 7605 Document, and any Warranty Disclaimers, provided that you also 7606 include the original English version of this License and the 7607 original versions of those notices and disclaimers. In case of a 7608 disagreement between the translation and the original version of 7609 this License or a notice or disclaimer, the original version will 7610 prevail. 7611 7612 If a section in the Document is Entitled "Acknowledgements", 7613 "Dedications", or "History", the requirement (section 4) to 7614 Preserve its Title (section 1) will typically require changing the 7615 actual title. 7616 7617 9. TERMINATION 7618 7619 You may not copy, modify, sublicense, or distribute the Document 7620 except as expressly provided under this License. Any attempt 7621 otherwise to copy, modify, sublicense, or distribute it is void, 7622 and will automatically terminate your rights under this License. 7623 7624 However, if you cease all violation of this License, then your 7625 license from a particular copyright holder is reinstated (a) 7626 provisionally, unless and until the copyright holder explicitly and 7627 finally terminates your license, and (b) permanently, if the 7628 copyright holder fails to notify you of the violation by some 7629 reasonable means prior to 60 days after the cessation. 7630 7631 Moreover, your license from a particular copyright holder is 7632 reinstated permanently if the copyright holder notifies you of the 7633 violation by some reasonable means, this is the first time you have 7634 received notice of violation of this License (for any work) from 7635 that copyright holder, and you cure the violation prior to 30 days 7636 after your receipt of the notice. 7637 7638 Termination of your rights under this section does not terminate 7639 the licenses of parties who have received copies or rights from you 7640 under this License. If your rights have been terminated and not 7641 permanently reinstated, receipt of a copy of some or all of the 7642 same material does not give you any rights to use it. 7643 7644 10. FUTURE REVISIONS OF THIS LICENSE 7645 7646 The Free Software Foundation may publish new, revised versions of 7647 the GNU Free Documentation License from time to time. Such new 7648 versions will be similar in spirit to the present version, but may 7649 differ in detail to address new problems or concerns. See 7650 <http://www.gnu.org/copyleft/>. 7651 7652 Each version of the License is given a distinguishing version 7653 number. If the Document specifies that a particular numbered 7654 version of this License "or any later version" applies to it, you 7655 have the option of following the terms and conditions either of 7656 that specified version or of any later version that has been 7657 published (not as a draft) by the Free Software Foundation. If the 7658 Document does not specify a version number of this License, you may 7659 choose any version ever published (not as a draft) by the Free 7660 Software Foundation. If the Document specifies that a proxy can 7661 decide which future versions of this License can be used, that 7662 proxy's public statement of acceptance of a version permanently 7663 authorizes you to choose that version for the Document. 7664 7665 11. RELICENSING 7666 7667 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any 7668 World Wide Web server that publishes copyrightable works and also 7669 provides prominent facilities for anybody to edit those works. A 7670 public wiki that anybody can edit is an example of such a server. 7671 A "Massive Multiauthor Collaboration" (or "MMC") contained in the 7672 site means any set of copyrightable works thus published on the MMC 7673 site. 7674 7675 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 7676 license published by Creative Commons Corporation, a not-for-profit 7677 corporation with a principal place of business in San Francisco, 7678 California, as well as future copyleft versions of that license 7679 published by that same organization. 7680 7681 "Incorporate" means to publish or republish a Document, in whole or 7682 in part, as part of another Document. 7683 7684 An MMC is "eligible for relicensing" if it is licensed under this 7685 License, and if all works that were first published under this 7686 License somewhere other than this MMC, and subsequently 7687 incorporated in whole or in part into the MMC, (1) had no cover 7688 texts or invariant sections, and (2) were thus incorporated prior 7689 to November 1, 2008. 7690 7691 The operator of an MMC Site may republish an MMC contained in the 7692 site under CC-BY-SA on the same site at any time before August 1, 7693 2009, provided the MMC is eligible for relicensing. 7694 7695ADDENDUM: How to use this License for your documents 7696==================================================== 7697 7698To use this License in a document you have written, include a copy of 7699the License in the document and put the following copyright and license 7700notices just after the title page: 7701 7702 Copyright (C) YEAR YOUR NAME. 7703 Permission is granted to copy, distribute and/or modify this document 7704 under the terms of the GNU Free Documentation License, Version 1.3 7705 or any later version published by the Free Software Foundation; 7706 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 7707 Texts. A copy of the license is included in the section entitled ``GNU 7708 Free Documentation License''. 7709 7710 If you have Invariant Sections, Front-Cover Texts and Back-Cover 7711Texts, replace the "with...Texts." line with this: 7712 7713 with the Invariant Sections being LIST THEIR TITLES, with 7714 the Front-Cover Texts being LIST, and with the Back-Cover Texts 7715 being LIST. 7716 7717 If you have Invariant Sections without Cover Texts, or some other 7718combination of the three, merge those two alternatives to suit the 7719situation. 7720 7721 If your document contains nontrivial examples of program code, we 7722recommend releasing these examples in parallel under your choice of free 7723software license, such as the GNU General Public License, to permit 7724their use in free software. 7725 7726 7727File: ld.info, Node: LD Index, Prev: GNU Free Documentation License, Up: Top 7728 7729LD Index 7730******** 7731 7732[index] 7733* Menu: 7734 7735* ": Symbols. (line 6) 7736* -(: Options. (line 864) 7737* --accept-unknown-input-arch: Options. (line 882) 7738* --add-needed: Options. (line 909) 7739* --add-stdcall-alias: Options. (line 1869) 7740* --allow-multiple-definition: Options. (line 1215) 7741* --allow-shlib-undefined: Options. (line 1221) 7742* --as-needed: Options. (line 892) 7743* --audit AUDITLIB: Options. (line 111) 7744* --auxiliary=NAME: Options. (line 242) 7745* --bank-window: Options. (line 2316) 7746* --base-file: Options. (line 1874) 7747* --be8: ARM. (line 28) 7748* --bss-plt: PowerPC ELF32. (line 16) 7749* --build-id: Options. (line 1831) 7750* --build-id=STYLE: Options. (line 1831) 7751* --check-sections: Options. (line 994) 7752* --cmse-implib: ARM. (line 234) 7753* --code-region: MSP430. (line 34) 7754* --compress-debug-sections=none: Options. (line 1789) 7755* --compress-debug-sections=zlib: Options. (line 1789) 7756* --compress-debug-sections=zlib-gabi: Options. (line 1789) 7757* --compress-debug-sections=zlib-gnu: Options. (line 1789) 7758* --copy-dt-needed-entries: Options. (line 1006) 7759* --cref: Options. (line 1026) 7760* --data-region: MSP430. (line 39) 7761* --default-imported-symver: Options. (line 1257) 7762* --default-script=SCRIPT: Options. (line 565) 7763* --default-symver: Options. (line 1253) 7764* --defsym=SYMBOL=EXP: Options. (line 1063) 7765* --demangle[=STYLE]: Options. (line 1075) 7766* --depaudit AUDITLIB: Options. (line 164) 7767* --disable-auto-image-base: Options. (line 2051) 7768* --disable-auto-import: Options. (line 2190) 7769* --disable-large-address-aware: Options. (line 1999) 7770* --disable-long-section-names: Options. (line 1884) 7771* --disable-multiple-abs-defs: Options. (line 1106) 7772* --disable-new-dtags: Options. (line 1765) 7773* --disable-runtime-pseudo-reloc: Options. (line 2203) 7774* --disable-sec-transformation: MSP430. (line 45) 7775* --disable-stdcall-fixup: Options. (line 1906) 7776* --discard-all: Options. (line 650) 7777* --discard-locals: Options. (line 654) 7778* --dll: Options. (line 1879) 7779* --dll-search-prefix: Options. (line 2057) 7780* --dotsyms: PowerPC64 ELF64. (line 33) 7781* --dsbt-index: Options. (line 2294) 7782* --dsbt-size: Options. (line 2289) 7783* --dynamic-linker=FILE: Options. (line 1088) 7784* --dynamic-list-cpp-new: Options. (line 986) 7785* --dynamic-list-cpp-typeinfo: Options. (line 990) 7786* --dynamic-list-data: Options. (line 983) 7787* --dynamic-list=DYNAMIC-LIST-FILE: Options. (line 970) 7788* --dynamicbase: Options. (line 2243) 7789* --eh-frame-hdr: Options. (line 1754) 7790* --embedded-relocs: Options. (line 1101) 7791* --emit-relocs: Options. (line 496) 7792* --emit-stack-syms: SPU ELF. (line 46) 7793* --emit-stub-syms: PowerPC ELF32. (line 47) 7794* --emit-stub-syms <1>: PowerPC64 ELF64. (line 29) 7795* --emit-stub-syms <2>: SPU ELF. (line 15) 7796* --enable-auto-image-base: Options. (line 2042) 7797* --enable-auto-import: Options. (line 2066) 7798* --enable-extra-pe-debug: Options. (line 2208) 7799* --enable-long-section-names: Options. (line 1884) 7800* --enable-new-dtags: Options. (line 1765) 7801* --enable-runtime-pseudo-reloc: Options. (line 2195) 7802* --enable-stdcall-fixup: Options. (line 1906) 7803* --entry=ENTRY: Options. (line 174) 7804* --error-unresolved-symbols: Options. (line 1707) 7805* --exclude-all-symbols: Options. (line 1959) 7806* --exclude-libs: Options. (line 184) 7807* --exclude-modules-for-implib: Options. (line 195) 7808* --exclude-symbols: Options. (line 1953) 7809* --export-all-symbols: Options. (line 1929) 7810* --export-dynamic: Options. (line 208) 7811* --extra-overlay-stubs: SPU ELF. (line 19) 7812* --fatal-warnings: Options. (line 1110) 7813* --file-alignment: Options. (line 1963) 7814* --filter=NAME: Options. (line 263) 7815* --fix-arm1176: ARM. (line 111) 7816* --fix-cortex-a53-835769: ARM. (line 211) 7817* --fix-cortex-a8: ARM. (line 202) 7818* --fix-stm32l4xx-629360: ARM. (line 120) 7819* --fix-v4bx: ARM. (line 48) 7820* --fix-v4bx-interworking: ARM. (line 61) 7821* --force-dynamic: Options. (line 505) 7822* --force-exe-suffix: Options. (line 1115) 7823* --force-group-allocation: Options. (line 1055) 7824* --forceinteg: Options. (line 2248) 7825* --format=FORMAT: Options. (line 121) 7826* --format=VERSION: TI COFF. (line 6) 7827* --gc-keep-exported: Options. (line 1158) 7828* --gc-sections: Options. (line 1125) 7829* --got: Options. (line 2328) 7830* --got=TYPE: M68K. (line 6) 7831* --gpsize=VALUE: Options. (line 295) 7832* --hash-size=NUMBER: Options. (line 1775) 7833* --hash-style=STYLE: Options. (line 1783) 7834* --heap: Options. (line 1969) 7835* --help: Options. (line 1186) 7836* --high-entropy-va: Options. (line 2239) 7837* --ignore-branch-isa: Options. (line 2349) 7838* --ignore-branch-isa <1>: MIPS. (line 13) 7839* --image-base: Options. (line 1976) 7840* --in-implib=FILE: ARM. (line 239) 7841* --insert-timestamp: Options. (line 2271) 7842* --insn32: Options. (line 2340) 7843* --insn32 <1>: MIPS. (line 6) 7844* --just-symbols=FILE: Options. (line 527) 7845* --kill-at: Options. (line 1985) 7846* --large-address-aware: Options. (line 1990) 7847* --ld-generated-unwind-info: Options. (line 1760) 7848* --leading-underscore: Options. (line 1923) 7849* --library-path=DIR: Options. (line 353) 7850* --library=NAMESPEC: Options. (line 320) 7851* --local-store=lo:hi: SPU ELF. (line 24) 7852* --long-plt: ARM. (line 222) 7853* --major-image-version: Options. (line 2006) 7854* --major-os-version: Options. (line 2011) 7855* --major-subsystem-version: Options. (line 2015) 7856* --merge-exidx-entries: ARM. (line 219) 7857* --minor-image-version: Options. (line 2020) 7858* --minor-os-version: Options. (line 2025) 7859* --minor-subsystem-version: Options. (line 2029) 7860* --mri-script=MRI-CMDFILE: Options. (line 145) 7861* --multi-subspace: HPPA ELF32. (line 6) 7862* --nmagic: Options. (line 422) 7863* --no-accept-unknown-input-arch: Options. (line 882) 7864* --no-add-needed: Options. (line 909) 7865* --no-allow-shlib-undefined: Options. (line 1221) 7866* --no-apply-dynamic-relocs: ARM. (line 226) 7867* --no-as-needed: Options. (line 892) 7868* --no-bind: Options. (line 2262) 7869* --no-check-sections: Options. (line 994) 7870* --no-copy-dt-needed-entries: Options. (line 1006) 7871* --no-define-common: Options. (line 1039) 7872* --no-demangle: Options. (line 1075) 7873* --no-dotsyms: PowerPC64 ELF64. (line 33) 7874* --no-dynamic-linker: Options. (line 1095) 7875* --no-eh-frame-hdr: Options. (line 1754) 7876* --no-enum-size-warning: ARM. (line 158) 7877* --no-export-dynamic: Options. (line 208) 7878* --no-fatal-warnings: Options. (line 1110) 7879* --no-fix-arm1176: ARM. (line 111) 7880* --no-fix-cortex-a53-835769: ARM. (line 211) 7881* --no-fix-cortex-a8: ARM. (line 202) 7882* --no-gc-sections: Options. (line 1125) 7883* --no-ignore-branch-isa: Options. (line 2350) 7884* --no-ignore-branch-isa <1>: MIPS. (line 13) 7885* --no-insn32: Options. (line 2341) 7886* --no-insn32 <1>: MIPS. (line 6) 7887* --no-isolation: Options. (line 2255) 7888* --no-keep-memory: Options. (line 1198) 7889* --no-leading-underscore: Options. (line 1923) 7890* --no-merge-exidx-entries: Options. (line 2301) 7891* --no-merge-exidx-entries <1>: ARM. (line 219) 7892* --no-multi-toc: PowerPC64 ELF64. (line 96) 7893* --no-omagic: Options. (line 437) 7894* --no-opd-optimize: PowerPC64 ELF64. (line 70) 7895* --no-overlays: SPU ELF. (line 9) 7896* --no-plt-align: PowerPC64 ELF64. (line 118) 7897* --no-plt-localentry: PowerPC64 ELF64. (line 147) 7898* --no-plt-static-chain: PowerPC64 ELF64. (line 129) 7899* --no-plt-thread-safe: PowerPC64 ELF64. (line 135) 7900* --no-print-gc-sections: Options. (line 1149) 7901* --no-save-restore-funcs: PowerPC64 ELF64. (line 44) 7902* --no-seh: Options. (line 2258) 7903* --no-strip-discarded: Options. (line 547) 7904* --no-tls-get-addr-optimize: PowerPC64 ELF64. (line 56) 7905* --no-tls-optimize: PowerPC ELF32. (line 51) 7906* --no-tls-optimize <1>: PowerPC64 ELF64. (line 51) 7907* --no-toc-optimize: PowerPC64 ELF64. (line 82) 7908* --no-toc-sort: PowerPC64 ELF64. (line 108) 7909* --no-trampoline: Options. (line 2310) 7910* --no-undefined: Options. (line 1205) 7911* --no-undefined-version: Options. (line 1248) 7912* --no-warn-mismatch: Options. (line 1261) 7913* --no-warn-search-mismatch: Options. (line 1270) 7914* --no-wchar-size-warning: ARM. (line 165) 7915* --no-whole-archive: Options. (line 1274) 7916* --noinhibit-exec: Options. (line 1278) 7917* --non-overlapping-opd: PowerPC64 ELF64. (line 76) 7918* --nxcompat: Options. (line 2251) 7919* --oformat=OUTPUT-FORMAT: Options. (line 1289) 7920* --omagic: Options. (line 428) 7921* --orphan-handling=MODE: Options. (line 609) 7922* --out-implib: Options. (line 1302) 7923* --output-def: Options. (line 2034) 7924* --output=OUTPUT: Options. (line 443) 7925* --pic-executable: Options. (line 1311) 7926* --pic-veneer: ARM. (line 171) 7927* --plt-align: PowerPC64 ELF64. (line 118) 7928* --plt-localentry: PowerPC64 ELF64. (line 147) 7929* --plt-static-chain: PowerPC64 ELF64. (line 129) 7930* --plt-thread-safe: PowerPC64 ELF64. (line 135) 7931* --plugin: SPU ELF. (line 6) 7932* --pop-state: Options. (line 492) 7933* --print-gc-sections: Options. (line 1149) 7934* --print-map: Options. (line 388) 7935* --print-memory-usage: Options. (line 1174) 7936* --print-output-format: Options. (line 1168) 7937* --push-state: Options. (line 474) 7938* --reduce-memory-overheads: Options. (line 1817) 7939* --relax: Options. (line 1327) 7940* --relax on Nios II: Nios II. (line 6) 7941* --relax on PowerPC: PowerPC ELF32. (line 6) 7942* --relax on Xtensa: Xtensa. (line 27) 7943* --relocatable: Options. (line 509) 7944* --require-defined=SYMBOL: Options. (line 591) 7945* --retain-symbols-file=FILENAME: Options. (line 1353) 7946* --s390-pgste: S/390 ELF. (line 6) 7947* --save-restore-funcs: PowerPC64 ELF64. (line 44) 7948* --script=SCRIPT: Options. (line 556) 7949* --sdata-got: PowerPC ELF32. (line 33) 7950* --section-alignment: Options. (line 2213) 7951* --section-start=SECTIONNAME=ORG: Options. (line 1521) 7952* --secure-plt: PowerPC ELF32. (line 26) 7953* --sort-common: Options. (line 1453) 7954* --sort-section=alignment: Options. (line 1468) 7955* --sort-section=name: Options. (line 1464) 7956* --spare-dynamic-tags: Options. (line 1472) 7957* --split-by-file: Options. (line 1477) 7958* --split-by-reloc: Options. (line 1482) 7959* --stack: Options. (line 2219) 7960* --stack-analysis: SPU ELF. (line 29) 7961* --stats: Options. (line 1495) 7962* --strip-all: Options. (line 538) 7963* --strip-debug: Options. (line 542) 7964* --strip-discarded: Options. (line 547) 7965* --stub-group-size: PowerPC64 ELF64. (line 6) 7966* --stub-group-size=N: ARM. (line 176) 7967* --stub-group-size=N <1>: HPPA ELF32. (line 12) 7968* --subsystem: Options. (line 2226) 7969* --support-old-code: ARM. (line 6) 7970* --sysroot=DIRECTORY: Options. (line 1499) 7971* --target-help: Options. (line 1190) 7972* --target1-abs: ARM. (line 33) 7973* --target1-rel: ARM. (line 33) 7974* --target2=TYPE: ARM. (line 38) 7975* --task-link: Options. (line 1504) 7976* --thumb-entry=ENTRY: ARM. (line 17) 7977* --tls-get-addr-optimize: PowerPC64 ELF64. (line 56) 7978* --trace: Options. (line 552) 7979* --trace-symbol=SYMBOL: Options. (line 660) 7980* --traditional-format: Options. (line 1509) 7981* --tsaware: Options. (line 2268) 7982* --undefined=SYMBOL: Options. (line 578) 7983* --unique[=SECTION]: Options. (line 635) 7984* --unresolved-symbols: Options. (line 1551) 7985* --use-blx: ARM. (line 73) 7986* --use-nul-prefixed-import-tables: ARM. (line 23) 7987* --verbose[=NUMBER]: Options. (line 1580) 7988* --version: Options. (line 644) 7989* --version-script=VERSION-SCRIPTFILE: Options. (line 1588) 7990* --vfp11-denorm-fix: ARM. (line 82) 7991* --warn-alternate-em: Options. (line 1699) 7992* --warn-common: Options. (line 1598) 7993* --warn-constructors: Options. (line 1666) 7994* --warn-multiple-gp: Options. (line 1671) 7995* --warn-once: Options. (line 1685) 7996* --warn-section-align: Options. (line 1689) 7997* --warn-shared-textrel: Options. (line 1696) 7998* --warn-unresolved-symbols: Options. (line 1702) 7999* --wdmdriver: Options. (line 2265) 8000* --whole-archive: Options. (line 1711) 8001* --wrap=SYMBOL: Options. (line 1725) 8002* -a KEYWORD: Options. (line 104) 8003* -assert KEYWORD: Options. (line 916) 8004* -b FORMAT: Options. (line 121) 8005* -Bdynamic: Options. (line 919) 8006* -Bgroup: Options. (line 929) 8007* -Bshareable: Options. (line 1446) 8008* -Bstatic: Options. (line 936) 8009* -Bsymbolic: Options. (line 950) 8010* -Bsymbolic-functions: Options. (line 961) 8011* -c MRI-CMDFILE: Options. (line 145) 8012* -call_shared: Options. (line 919) 8013* -d: Options. (line 155) 8014* -dc: Options. (line 155) 8015* -dn: Options. (line 936) 8016* -dp: Options. (line 155) 8017* -dT SCRIPT: Options. (line 565) 8018* -dy: Options. (line 919) 8019* -E: Options. (line 208) 8020* -e ENTRY: Options. (line 174) 8021* -EB: Options. (line 235) 8022* -EL: Options. (line 238) 8023* -f NAME: Options. (line 242) 8024* -F NAME: Options. (line 263) 8025* -fini=NAME: Options. (line 286) 8026* -g: Options. (line 292) 8027* -G VALUE: Options. (line 295) 8028* -h NAME: Options. (line 302) 8029* -i: Options. (line 311) 8030* -IFILE: Options. (line 1088) 8031* -init=NAME: Options. (line 314) 8032* -L DIR: Options. (line 353) 8033* -l NAMESPEC: Options. (line 320) 8034* -M: Options. (line 388) 8035* -m EMULATION: Options. (line 378) 8036* -Map=MAPFILE: Options. (line 1194) 8037* -n: Options. (line 422) 8038* -N: Options. (line 428) 8039* -no-relax: Options. (line 1327) 8040* -non_shared: Options. (line 936) 8041* -nostdlib: Options. (line 1284) 8042* -O LEVEL: Options. (line 449) 8043* -o OUTPUT: Options. (line 443) 8044* -P AUDITLIB: Options. (line 164) 8045* -pie: Options. (line 1311) 8046* -plugin NAME: Options. (line 459) 8047* -q: Options. (line 496) 8048* -qmagic: Options. (line 1321) 8049* -Qy: Options. (line 1324) 8050* -r: Options. (line 509) 8051* -R FILE: Options. (line 527) 8052* -rpath-link=DIR: Options. (line 1389) 8053* -rpath=DIR: Options. (line 1367) 8054* -s: Options. (line 538) 8055* -S: Options. (line 542) 8056* -shared: Options. (line 1446) 8057* -soname=NAME: Options. (line 302) 8058* -static: Options. (line 936) 8059* -t: Options. (line 552) 8060* -T SCRIPT: Options. (line 556) 8061* -Tbss=ORG: Options. (line 1530) 8062* -Tdata=ORG: Options. (line 1530) 8063* -Tldata-segment=ORG: Options. (line 1546) 8064* -Trodata-segment=ORG: Options. (line 1540) 8065* -Ttext-segment=ORG: Options. (line 1536) 8066* -Ttext=ORG: Options. (line 1530) 8067* -u SYMBOL: Options. (line 578) 8068* -Ur: Options. (line 599) 8069* -v: Options. (line 644) 8070* -V: Options. (line 644) 8071* -x: Options. (line 650) 8072* -X: Options. (line 654) 8073* -Y PATH: Options. (line 669) 8074* -y SYMBOL: Options. (line 660) 8075* -z defs: Options. (line 1205) 8076* -z KEYWORD: Options. (line 673) 8077* -z muldefs: Options. (line 1215) 8078* -z undefs: Options. (line 1205) 8079* .: Location Counter. (line 6) 8080* /DISCARD/: Output Section Discarding. 8081 (line 26) 8082* 32-bit PLT entries: ARM. (line 222) 8083* :PHDR: Output Section Phdr. 8084 (line 6) 8085* =FILLEXP: Output Section Fill. 8086 (line 6) 8087* >REGION: Output Section Region. 8088 (line 6) 8089* [COMMON]: Input Section Common. 8090 (line 29) 8091* AArch64 rela addend: ARM. (line 226) 8092* ABSOLUTE (MRI): MRI. (line 32) 8093* absolute and relocatable symbols: Expression Section. (line 6) 8094* absolute expressions: Expression Section. (line 6) 8095* ABSOLUTE(EXP): Builtin Functions. (line 10) 8096* ADDR(SECTION): Builtin Functions. (line 17) 8097* address, section: Output Section Address. 8098 (line 6) 8099* ALIAS (MRI): MRI. (line 43) 8100* ALIGN (MRI): MRI. (line 49) 8101* align expression: Builtin Functions. (line 38) 8102* align location counter: Builtin Functions. (line 38) 8103* ALIGN(ALIGN): Builtin Functions. (line 38) 8104* ALIGN(EXP,ALIGN): Builtin Functions. (line 38) 8105* ALIGN(SECTION_ALIGN): Forced Output Alignment. 8106 (line 6) 8107* aligned common symbols: WIN32. (line 416) 8108* ALIGNOF(SECTION): Builtin Functions. (line 63) 8109* allocating memory: MEMORY. (line 6) 8110* architecture: Miscellaneous Commands. 8111 (line 121) 8112* archive files, from cmd line: Options. (line 320) 8113* archive search path in linker script: File Commands. (line 77) 8114* arithmetic: Expressions. (line 6) 8115* arithmetic operators: Operators. (line 6) 8116* ARM interworking support: ARM. (line 6) 8117* ARM1176 erratum workaround: ARM. (line 111) 8118* ASSERT: Miscellaneous Commands. 8119 (line 9) 8120* assertion in linker script: Miscellaneous Commands. 8121 (line 9) 8122* assignment in scripts: Assignments. (line 6) 8123* AS_NEEDED(FILES): File Commands. (line 57) 8124* AT(LMA): Output Section LMA. (line 6) 8125* AT>LMA_REGION: Output Section LMA. (line 6) 8126* automatic data imports: WIN32. (line 185) 8127* back end: BFD. (line 6) 8128* BASE (MRI): MRI. (line 53) 8129* BE8: ARM. (line 28) 8130* BFD canonical format: Canonical format. (line 11) 8131* BFD requirements: BFD. (line 16) 8132* big-endian objects: Options. (line 235) 8133* binary input format: Options. (line 121) 8134* BLOCK(EXP): Builtin Functions. (line 76) 8135* bug criteria: Bug Criteria. (line 6) 8136* bug reports: Bug Reporting. (line 6) 8137* bugs in ld: Reporting Bugs. (line 6) 8138* BYTE(EXPRESSION): Output Section Data. 8139 (line 6) 8140* C++ constructors, arranging in link: Output Section Keywords. 8141 (line 19) 8142* CHIP (MRI): MRI. (line 57) 8143* COLLECT_NO_DEMANGLE: Environment. (line 29) 8144* combining symbols, warnings on: Options. (line 1598) 8145* COMDAT: Options. (line 1055) 8146* COMDAT <1>: Miscellaneous Commands. 8147 (line 56) 8148* command files: Scripts. (line 6) 8149* command line: Options. (line 6) 8150* common allocation: Options. (line 155) 8151* common allocation <1>: Options. (line 1039) 8152* common allocation in linker script: Miscellaneous Commands. 8153 (line 46) 8154* common allocation in linker script <1>: Miscellaneous Commands. 8155 (line 51) 8156* common symbol placement: Input Section Common. 8157 (line 6) 8158* COMMONPAGESIZE: Symbolic Constants. (line 13) 8159* compatibility, MRI: Options. (line 145) 8160* CONSTANT: Symbolic Constants. (line 6) 8161* constants in linker scripts: Constants. (line 6) 8162* constraints on output sections: Output Section Constraint. 8163 (line 6) 8164* constructors: Options. (line 599) 8165* CONSTRUCTORS: Output Section Keywords. 8166 (line 19) 8167* constructors, arranging in link: Output Section Keywords. 8168 (line 19) 8169* Cortex-A53 erratum 835769 workaround: ARM. (line 211) 8170* Cortex-A8 erratum workaround: ARM. (line 202) 8171* crash of linker: Bug Criteria. (line 9) 8172* CREATE_OBJECT_SYMBOLS: Output Section Keywords. 8173 (line 9) 8174* creating a DEF file: WIN32. (line 153) 8175* cross reference table: Options. (line 1026) 8176* cross references: Miscellaneous Commands. 8177 (line 88) 8178* cross references <1>: Miscellaneous Commands. 8179 (line 104) 8180* current output location: Location Counter. (line 6) 8181* data: Output Section Data. 8182 (line 6) 8183* DATA_SEGMENT_ALIGN(MAXPAGESIZE, COMMONPAGESIZE): Builtin Functions. 8184 (line 81) 8185* DATA_SEGMENT_END(EXP): Builtin Functions. (line 105) 8186* DATA_SEGMENT_RELRO_END(OFFSET, EXP): Builtin Functions. (line 111) 8187* dbx: Options. (line 1514) 8188* DEF files, creating: Options. (line 2034) 8189* default emulation: Environment. (line 21) 8190* default input format: Environment. (line 9) 8191* defined symbol: Options. (line 591) 8192* DEFINED(SYMBOL): Builtin Functions. (line 124) 8193* deleting local symbols: Options. (line 650) 8194* demangling, default: Environment. (line 29) 8195* demangling, from command line: Options. (line 1075) 8196* direct linking to a dll: WIN32. (line 233) 8197* discarding sections: Output Section Discarding. 8198 (line 6) 8199* discontinuous memory: MEMORY. (line 6) 8200* DLLs, creating: Options. (line 1929) 8201* DLLs, creating <1>: Options. (line 2034) 8202* DLLs, creating <2>: Options. (line 2042) 8203* DLLs, linking to: Options. (line 2057) 8204* dot: Location Counter. (line 6) 8205* dot inside sections: Location Counter. (line 36) 8206* dot outside sections: Location Counter. (line 66) 8207* dynamic linker, from command line: Options. (line 1088) 8208* dynamic symbol table: Options. (line 208) 8209* ELF program headers: PHDRS. (line 6) 8210* emulation: Options. (line 378) 8211* emulation, default: Environment. (line 21) 8212* END (MRI): MRI. (line 61) 8213* endianness: Options. (line 235) 8214* entry point: Entry Point. (line 6) 8215* entry point, from command line: Options. (line 174) 8216* entry point, thumb: ARM. (line 17) 8217* ENTRY(SYMBOL): Entry Point. (line 6) 8218* error on valid input: Bug Criteria. (line 12) 8219* example of linker script: Simple Example. (line 6) 8220* EXCLUDE_FILE: Input Section Basics. 8221 (line 17) 8222* exporting DLL symbols: WIN32. (line 19) 8223* expression evaluation order: Evaluation. (line 6) 8224* expression sections: Expression Section. (line 6) 8225* expression, absolute: Builtin Functions. (line 10) 8226* expressions: Expressions. (line 6) 8227* EXTERN: Miscellaneous Commands. 8228 (line 39) 8229* fatal signal: Bug Criteria. (line 9) 8230* file name wildcard patterns: Input Section Wildcards. 8231 (line 6) 8232* FILEHDR: PHDRS. (line 62) 8233* filename symbols: Output Section Keywords. 8234 (line 9) 8235* fill pattern, entire section: Output Section Fill. 8236 (line 6) 8237* FILL(EXPRESSION): Output Section Data. 8238 (line 39) 8239* finalization function: Options. (line 286) 8240* first input file: File Commands. (line 85) 8241* first instruction: Entry Point. (line 6) 8242* FIX_V4BX: ARM. (line 48) 8243* FIX_V4BX_INTERWORKING: ARM. (line 61) 8244* FORCE_COMMON_ALLOCATION: Miscellaneous Commands. 8245 (line 46) 8246* FORCE_GROUP_ALLOCATION: Miscellaneous Commands. 8247 (line 56) 8248* forcing input section alignment: Forced Input Alignment. 8249 (line 6) 8250* forcing output section alignment: Forced Output Alignment. 8251 (line 6) 8252* forcing the creation of dynamic sections: Options. (line 505) 8253* FORMAT (MRI): MRI. (line 65) 8254* functions in expressions: Builtin Functions. (line 6) 8255* garbage collection: Options. (line 1125) 8256* garbage collection <1>: Options. (line 1149) 8257* garbage collection <2>: Options. (line 1158) 8258* garbage collection <3>: Input Section Keep. (line 6) 8259* generating optimized output: Options. (line 449) 8260* GNU linker: Overview. (line 6) 8261* GNUTARGET: Environment. (line 9) 8262* group allocation in linker script: Options. (line 1055) 8263* group allocation in linker script <1>: Miscellaneous Commands. 8264 (line 56) 8265* GROUP(FILES): File Commands. (line 50) 8266* grouping input files: File Commands. (line 50) 8267* groups of archives: Options. (line 864) 8268* H8/300 support: H8/300. (line 6) 8269* header size: Builtin Functions. (line 191) 8270* heap size: Options. (line 1969) 8271* help: Options. (line 1186) 8272* HIDDEN: HIDDEN. (line 6) 8273* holes: Location Counter. (line 12) 8274* holes, filling: Output Section Data. 8275 (line 39) 8276* HPPA multiple sub-space stubs: HPPA ELF32. (line 6) 8277* HPPA stub grouping: HPPA ELF32. (line 12) 8278* image base: Options. (line 1976) 8279* implicit linker scripts: Implicit Linker Scripts. 8280 (line 6) 8281* import libraries: WIN32. (line 10) 8282* INCLUDE FILENAME: File Commands. (line 9) 8283* including a linker script: File Commands. (line 9) 8284* including an entire archive: Options. (line 1711) 8285* incremental link: Options. (line 311) 8286* INHIBIT_COMMON_ALLOCATION: Miscellaneous Commands. 8287 (line 51) 8288* initialization function: Options. (line 314) 8289* initialized data in ROM: Output Section LMA. (line 39) 8290* input file format in linker script: Format Commands. (line 35) 8291* input filename symbols: Output Section Keywords. 8292 (line 9) 8293* input files in linker scripts: File Commands. (line 19) 8294* input files, displaying: Options. (line 552) 8295* input format: Options. (line 121) 8296* input format <1>: Options. (line 121) 8297* Input import library: ARM. (line 239) 8298* input object files in linker scripts: File Commands. (line 19) 8299* input section alignment: Forced Input Alignment. 8300 (line 6) 8301* input section basics: Input Section Basics. 8302 (line 6) 8303* input section wildcards: Input Section Wildcards. 8304 (line 6) 8305* input sections: Input Section. (line 6) 8306* INPUT(FILES): File Commands. (line 19) 8307* INSERT: Miscellaneous Commands. 8308 (line 62) 8309* insert user script into default script: Miscellaneous Commands. 8310 (line 62) 8311* integer notation: Constants. (line 6) 8312* integer suffixes: Constants. (line 15) 8313* internal object-file format: Canonical format. (line 11) 8314* invalid input: Bug Criteria. (line 14) 8315* K and M integer suffixes: Constants. (line 15) 8316* KEEP: Input Section Keep. (line 6) 8317* l =: MEMORY. (line 68) 8318* lazy evaluation: Evaluation. (line 6) 8319* ld bugs, reporting: Bug Reporting. (line 6) 8320* ldata segment origin, cmd line: Options. (line 1547) 8321* LDEMULATION: Environment. (line 21) 8322* LD_FEATURE(STRING): Miscellaneous Commands. 8323 (line 127) 8324* len =: MEMORY. (line 68) 8325* LENGTH =: MEMORY. (line 68) 8326* LENGTH(MEMORY): Builtin Functions. (line 141) 8327* library search path in linker script: File Commands. (line 77) 8328* link map: Options. (line 388) 8329* link-time runtime library search path: Options. (line 1389) 8330* linker crash: Bug Criteria. (line 9) 8331* linker script concepts: Basic Script Concepts. 8332 (line 6) 8333* linker script example: Simple Example. (line 6) 8334* linker script file commands: File Commands. (line 6) 8335* linker script format: Script Format. (line 6) 8336* linker script input object files: File Commands. (line 19) 8337* linker script simple commands: Simple Commands. (line 6) 8338* linker scripts: Scripts. (line 6) 8339* LIST (MRI): MRI. (line 69) 8340* little-endian objects: Options. (line 238) 8341* LOAD (MRI): MRI. (line 76) 8342* load address: Output Section LMA. (line 6) 8343* LOADADDR(SECTION): Builtin Functions. (line 144) 8344* loading, preventing: Output Section Type. 8345 (line 21) 8346* local symbols, deleting: Options. (line 654) 8347* location counter: Location Counter. (line 6) 8348* LOG2CEIL(EXP): Builtin Functions. (line 148) 8349* LONG(EXPRESSION): Output Section Data. 8350 (line 6) 8351* M and K integer suffixes: Constants. (line 15) 8352* M68HC11 and 68HC12 support: M68HC11/68HC12. (line 5) 8353* machine architecture: Miscellaneous Commands. 8354 (line 121) 8355* machine dependencies: Machine Dependent. (line 6) 8356* mapping input sections to output sections: Input Section. (line 6) 8357* MAX: Builtin Functions. (line 151) 8358* MAXPAGESIZE: Symbolic Constants. (line 10) 8359* MEMORY: MEMORY. (line 6) 8360* memory region attributes: MEMORY. (line 34) 8361* memory regions: MEMORY. (line 6) 8362* memory regions and sections: Output Section Region. 8363 (line 6) 8364* memory usage: Options. (line 1174) 8365* memory usage <1>: Options. (line 1198) 8366* Merging exidx entries: ARM. (line 219) 8367* MIN: Builtin Functions. (line 154) 8368* MIPS branch relocation check control: MIPS. (line 13) 8369* MIPS microMIPS instruction choice selection: MIPS. (line 6) 8370* Motorola 68K GOT generation: M68K. (line 6) 8371* MRI compatibility: MRI. (line 6) 8372* MSP430 extra sections: MSP430. (line 11) 8373* MSP430 Options: MSP430. (line 34) 8374* NAME (MRI): MRI. (line 82) 8375* name, section: Output Section Name. 8376 (line 6) 8377* names: Symbols. (line 6) 8378* naming the output file: Options. (line 443) 8379* NEXT(EXP): Builtin Functions. (line 158) 8380* Nios II call relaxation: Nios II. (line 6) 8381* NMAGIC: Options. (line 422) 8382* NOCROSSREFS(SECTIONS): Miscellaneous Commands. 8383 (line 88) 8384* NOCROSSREFS_TO(TOSECTION FROMSECTIONS): Miscellaneous Commands. 8385 (line 104) 8386* NOLOAD: Output Section Type. 8387 (line 21) 8388* not enough room for program headers: Builtin Functions. (line 196) 8389* NO_ENUM_SIZE_WARNING: ARM. (line 158) 8390* NO_WCHAR_SIZE_WARNING: ARM. (line 165) 8391* o =: MEMORY. (line 63) 8392* objdump -i: BFD. (line 6) 8393* object file management: BFD. (line 6) 8394* object files: Options. (line 29) 8395* object formats available: BFD. (line 6) 8396* object size: Options. (line 295) 8397* OMAGIC: Options. (line 428) 8398* OMAGIC <1>: Options. (line 437) 8399* ONLY_IF_RO: Output Section Constraint. 8400 (line 6) 8401* ONLY_IF_RW: Output Section Constraint. 8402 (line 6) 8403* opening object files: BFD outline. (line 6) 8404* operators for arithmetic: Operators. (line 6) 8405* options: Options. (line 6) 8406* ORDER (MRI): MRI. (line 87) 8407* org =: MEMORY. (line 63) 8408* ORIGIN =: MEMORY. (line 63) 8409* ORIGIN(MEMORY): Builtin Functions. (line 164) 8410* orphan: Orphan Sections. (line 6) 8411* orphan sections: Options. (line 609) 8412* output file after errors: Options. (line 1278) 8413* output file format in linker script: Format Commands. (line 10) 8414* output file name in linker script: File Commands. (line 67) 8415* output format: Options. (line 1168) 8416* output section alignment: Forced Output Alignment. 8417 (line 6) 8418* output section attributes: Output Section Attributes. 8419 (line 6) 8420* output section data: Output Section Data. 8421 (line 6) 8422* OUTPUT(FILENAME): File Commands. (line 67) 8423* OUTPUT_ARCH(BFDARCH): Miscellaneous Commands. 8424 (line 121) 8425* OUTPUT_FORMAT(BFDNAME): Format Commands. (line 10) 8426* OVERLAY: Overlay Description. 8427 (line 6) 8428* overlays: Overlay Description. 8429 (line 6) 8430* partial link: Options. (line 509) 8431* PE import table prefixing: ARM. (line 23) 8432* PHDRS: PHDRS. (line 6) 8433* PHDRS <1>: PHDRS. (line 62) 8434* PIC_VENEER: ARM. (line 171) 8435* Placement of SG veneers: ARM. (line 229) 8436* pop state governing input file handling: Options. (line 492) 8437* position independent executables: Options. (line 1313) 8438* PowerPC ELF32 options: PowerPC ELF32. (line 16) 8439* PowerPC GOT: PowerPC ELF32. (line 33) 8440* PowerPC long branches: PowerPC ELF32. (line 6) 8441* PowerPC PLT: PowerPC ELF32. (line 16) 8442* PowerPC stub symbols: PowerPC ELF32. (line 47) 8443* PowerPC TLS optimization: PowerPC ELF32. (line 51) 8444* PowerPC64 dot symbols: PowerPC64 ELF64. (line 33) 8445* PowerPC64 ELF64 options: PowerPC64 ELF64. (line 6) 8446* PowerPC64 ELFv2 PLT localentry optimization: PowerPC64 ELF64. 8447 (line 147) 8448* PowerPC64 multi-TOC: PowerPC64 ELF64. (line 96) 8449* PowerPC64 OPD optimization: PowerPC64 ELF64. (line 70) 8450* PowerPC64 OPD spacing: PowerPC64 ELF64. (line 76) 8451* PowerPC64 PLT call stub static chain: PowerPC64 ELF64. (line 129) 8452* PowerPC64 PLT call stub thread safety: PowerPC64 ELF64. (line 135) 8453* PowerPC64 PLT stub alignment: PowerPC64 ELF64. (line 118) 8454* PowerPC64 register save/restore functions: PowerPC64 ELF64. 8455 (line 44) 8456* PowerPC64 stub grouping: PowerPC64 ELF64. (line 6) 8457* PowerPC64 stub symbols: PowerPC64 ELF64. (line 29) 8458* PowerPC64 TLS optimization: PowerPC64 ELF64. (line 51) 8459* PowerPC64 TOC optimization: PowerPC64 ELF64. (line 82) 8460* PowerPC64 TOC sorting: PowerPC64 ELF64. (line 108) 8461* PowerPC64 __tls_get_addr optimization: PowerPC64 ELF64. (line 56) 8462* precedence in expressions: Operators. (line 6) 8463* prevent unnecessary loading: Output Section Type. 8464 (line 21) 8465* program headers: PHDRS. (line 6) 8466* program headers and sections: Output Section Phdr. 8467 (line 6) 8468* program headers, not enough room: Builtin Functions. (line 196) 8469* program segments: PHDRS. (line 6) 8470* PROVIDE: PROVIDE. (line 6) 8471* PROVIDE_HIDDEN: PROVIDE_HIDDEN. (line 6) 8472* PUBLIC (MRI): MRI. (line 95) 8473* push state governing input file handling: Options. (line 474) 8474* QUAD(EXPRESSION): Output Section Data. 8475 (line 6) 8476* quoted symbol names: Symbols. (line 6) 8477* read-only text: Options. (line 422) 8478* read/write from cmd line: Options. (line 428) 8479* region alias: REGION_ALIAS. (line 6) 8480* region names: REGION_ALIAS. (line 6) 8481* regions of memory: MEMORY. (line 6) 8482* REGION_ALIAS(ALIAS, REGION): REGION_ALIAS. (line 6) 8483* relative expressions: Expression Section. (line 6) 8484* relaxing addressing modes: Options. (line 1327) 8485* relaxing on H8/300: H8/300. (line 9) 8486* relaxing on M68HC11: M68HC11/68HC12. (line 12) 8487* relaxing on NDS32: NDS32. (line 6) 8488* relaxing on Xtensa: Xtensa. (line 27) 8489* relocatable and absolute symbols: Expression Section. (line 6) 8490* relocatable output: Options. (line 509) 8491* removing sections: Output Section Discarding. 8492 (line 6) 8493* reporting bugs in ld: Reporting Bugs. (line 6) 8494* requirements for BFD: BFD. (line 16) 8495* retain relocations in final executable: Options. (line 496) 8496* retaining specified symbols: Options. (line 1353) 8497* rodata segment origin, cmd line: Options. (line 1541) 8498* ROM initialized data: Output Section LMA. (line 39) 8499* round up expression: Builtin Functions. (line 38) 8500* round up location counter: Builtin Functions. (line 38) 8501* runtime library name: Options. (line 302) 8502* runtime library search path: Options. (line 1367) 8503* runtime pseudo-relocation: WIN32. (line 211) 8504* S/390: S/390 ELF. (line 6) 8505* S/390 ELF options: S/390 ELF. (line 6) 8506* scaled integers: Constants. (line 15) 8507* scommon section: Input Section Common. 8508 (line 20) 8509* script files: Options. (line 556) 8510* script files <1>: Options. (line 565) 8511* scripts: Scripts. (line 6) 8512* search directory, from cmd line: Options. (line 353) 8513* search path in linker script: File Commands. (line 77) 8514* SEARCH_DIR(PATH): File Commands. (line 77) 8515* SECT (MRI): MRI. (line 101) 8516* section address: Output Section Address. 8517 (line 6) 8518* section address in expression: Builtin Functions. (line 17) 8519* section alignment: Builtin Functions. (line 63) 8520* section alignment, warnings on: Options. (line 1689) 8521* section data: Output Section Data. 8522 (line 6) 8523* section fill pattern: Output Section Fill. 8524 (line 6) 8525* section groups: Options. (line 1055) 8526* section groups <1>: Miscellaneous Commands. 8527 (line 56) 8528* section load address: Output Section LMA. (line 6) 8529* section load address in expression: Builtin Functions. (line 144) 8530* section name: Output Section Name. 8531 (line 6) 8532* section name wildcard patterns: Input Section Wildcards. 8533 (line 6) 8534* section size: Builtin Functions. (line 175) 8535* section, assigning to memory region: Output Section Region. 8536 (line 6) 8537* section, assigning to program header: Output Section Phdr. 8538 (line 6) 8539* SECTIONS: SECTIONS. (line 6) 8540* sections, discarding: Output Section Discarding. 8541 (line 6) 8542* sections, orphan: Options. (line 609) 8543* Secure gateway import library: ARM. (line 234) 8544* segment origins, cmd line: Options. (line 1530) 8545* segments, ELF: PHDRS. (line 6) 8546* SEGMENT_START(SEGMENT, DEFAULT): Builtin Functions. (line 167) 8547* shared libraries: Options. (line 1448) 8548* SHORT(EXPRESSION): Output Section Data. 8549 (line 6) 8550* SIZEOF(SECTION): Builtin Functions. (line 175) 8551* SIZEOF_HEADERS: Builtin Functions. (line 191) 8552* small common symbols: Input Section Common. 8553 (line 20) 8554* SORT: Input Section Wildcards. 8555 (line 62) 8556* SORT_BY_ALIGNMENT: Input Section Wildcards. 8557 (line 51) 8558* SORT_BY_INIT_PRIORITY: Input Section Wildcards. 8559 (line 57) 8560* SORT_BY_NAME: Input Section Wildcards. 8561 (line 43) 8562* SORT_NONE: Input Section Wildcards. 8563 (line 98) 8564* SPU: SPU ELF. (line 29) 8565* SPU <1>: SPU ELF. (line 46) 8566* SPU ELF options: SPU ELF. (line 6) 8567* SPU extra overlay stubs: SPU ELF. (line 19) 8568* SPU local store size: SPU ELF. (line 24) 8569* SPU overlay stub symbols: SPU ELF. (line 15) 8570* SPU overlays: SPU ELF. (line 9) 8571* SPU plugins: SPU ELF. (line 6) 8572* SQUAD(EXPRESSION): Output Section Data. 8573 (line 6) 8574* stack size: Options. (line 2219) 8575* standard Unix system: Options. (line 7) 8576* start of execution: Entry Point. (line 6) 8577* STARTUP(FILENAME): File Commands. (line 85) 8578* STM32L4xx erratum workaround: ARM. (line 120) 8579* strip all symbols: Options. (line 538) 8580* strip debugger symbols: Options. (line 542) 8581* stripping all but some symbols: Options. (line 1353) 8582* STUB_GROUP_SIZE: ARM. (line 176) 8583* SUBALIGN(SUBSECTION_ALIGN): Forced Input Alignment. 8584 (line 6) 8585* suffixes for integers: Constants. (line 15) 8586* symbol defaults: Builtin Functions. (line 124) 8587* symbol definition, scripts: Assignments. (line 6) 8588* symbol names: Symbols. (line 6) 8589* symbol tracing: Options. (line 660) 8590* symbol versions: VERSION. (line 6) 8591* symbol-only input: Options. (line 527) 8592* symbolic constants: Symbolic Constants. (line 6) 8593* symbols, from command line: Options. (line 1063) 8594* symbols, relocatable and absolute: Expression Section. (line 6) 8595* symbols, require defined: Options. (line 591) 8596* symbols, retaining selectively: Options. (line 1353) 8597* synthesizing linker: Options. (line 1327) 8598* synthesizing on H8/300: H8/300. (line 14) 8599* TARGET(BFDNAME): Format Commands. (line 35) 8600* TARGET1: ARM. (line 33) 8601* TARGET2: ARM. (line 38) 8602* text segment origin, cmd line: Options. (line 1537) 8603* thumb entry point: ARM. (line 17) 8604* TI COFF versions: TI COFF. (line 6) 8605* traditional format: Options. (line 1509) 8606* trampoline generation on M68HC11: M68HC11/68HC12. (line 30) 8607* trampoline generation on M68HC12: M68HC11/68HC12. (line 30) 8608* unallocated address, next: Builtin Functions. (line 158) 8609* undefined symbol: Options. (line 578) 8610* undefined symbol in linker script: Miscellaneous Commands. 8611 (line 39) 8612* undefined symbols, warnings on: Options. (line 1685) 8613* uninitialized data placement: Input Section Common. 8614 (line 6) 8615* unspecified memory: Output Section Data. 8616 (line 39) 8617* usage: Options. (line 1186) 8618* USE_BLX: ARM. (line 73) 8619* using a DEF file: WIN32. (line 52) 8620* using auto-export functionality: WIN32. (line 22) 8621* Using decorations: WIN32. (line 157) 8622* variables, defining: Assignments. (line 6) 8623* verbose[=NUMBER]: Options. (line 1580) 8624* version: Options. (line 644) 8625* version script: VERSION. (line 6) 8626* version script, symbol versions: Options. (line 1588) 8627* VERSION {script text}: VERSION. (line 6) 8628* versions of symbols: VERSION. (line 6) 8629* VFP11_DENORM_FIX: ARM. (line 82) 8630* warnings, on combining symbols: Options. (line 1598) 8631* warnings, on section alignment: Options. (line 1689) 8632* warnings, on undefined symbols: Options. (line 1685) 8633* weak externals: WIN32. (line 401) 8634* what is this?: Overview. (line 6) 8635* wildcard file name patterns: Input Section Wildcards. 8636 (line 6) 8637* Xtensa options: Xtensa. (line 55) 8638* Xtensa processors: Xtensa. (line 6) 8639 8640 8641 8642Tag Table: 8643Node: Top706 8644Node: Overview1490 8645Node: Invocation2606 8646Node: Options3014 8647Node: Environment111207 8648Node: Scripts112968 8649Node: Basic Script Concepts114702 8650Node: Script Format117410 8651Node: Simple Example118273 8652Node: Simple Commands121367 8653Node: Entry Point121872 8654Node: File Commands122800 8655Node: Format Commands126974 8656Node: REGION_ALIAS128930 8657Node: Miscellaneous Commands133757 8658Node: Assignments139588 8659Node: Simple Assignments140099 8660Node: HIDDEN141830 8661Node: PROVIDE142457 8662Node: PROVIDE_HIDDEN143978 8663Node: Source Code Reference144222 8664Node: SECTIONS148139 8665Node: Output Section Description150027 8666Node: Output Section Name151268 8667Node: Output Section Address152145 8668Node: Input Section154378 8669Node: Input Section Basics155179 8670Node: Input Section Wildcards160197 8671Node: Input Section Common165398 8672Node: Input Section Keep166880 8673Node: Input Section Example167370 8674Node: Output Section Data168781 8675Node: Output Section Keywords171560 8676Node: Output Section Discarding175127 8677Node: Output Section Attributes176617 8678Node: Output Section Type177717 8679Node: Output Section LMA178787 8680Node: Forced Output Alignment181858 8681Node: Forced Input Alignment182287 8682Node: Output Section Constraint182675 8683Node: Output Section Region183103 8684Node: Output Section Phdr183536 8685Node: Output Section Fill184200 8686Node: Overlay Description185342 8687Node: MEMORY189787 8688Node: PHDRS194158 8689Node: VERSION199484 8690Node: Expressions207575 8691Node: Constants208504 8692Node: Symbolic Constants209378 8693Node: Symbols209929 8694Node: Orphan Sections210676 8695Node: Location Counter212261 8696Node: Operators216695 8697Node: Evaluation217617 8698Node: Expression Section218981 8699Node: Builtin Functions222951 8700Node: Implicit Linker Scripts231302 8701Node: Machine Dependent232077 8702Node: H8/300233165 8703Node: M68HC11/68HC12235238 8704Node: ARM236685 8705Node: HPPA ELF32248932 8706Node: M68K250555 8707Node: MIPS251464 8708Node: MMIX252580 8709Node: MSP430253745 8710Node: NDS32255658 8711Node: Nios II256622 8712Node: PowerPC ELF32257938 8713Node: PowerPC64 ELF64260769 8714Node: S/390 ELF269170 8715Node: SPU ELF269517 8716Node: TI COFF272145 8717Node: WIN32272671 8718Node: Xtensa292818 8719Node: BFD295784 8720Node: BFD outline297242 8721Node: BFD information loss298530 8722Node: Canonical format301056 8723Node: Reporting Bugs305384 8724Node: Bug Criteria306078 8725Node: Bug Reporting306777 8726Node: MRI313815 8727Node: GNU Free Documentation License318286 8728Node: LD Index343423 8729 8730End Tag Table 8731