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