| 1 | This is ld.info, produced by makeinfo version 4.3 from ./ld.texinfo.
|
|---|
| 2 |
|
|---|
| 3 | START-INFO-DIR-ENTRY
|
|---|
| 4 | * Ld: (ld). The GNU linker.
|
|---|
| 5 | END-INFO-DIR-ENTRY
|
|---|
| 6 |
|
|---|
| 7 | This file documents the GNU linker LD version 2.14.
|
|---|
| 8 |
|
|---|
| 9 | Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001,
|
|---|
| 10 | 2002, 2003 Free Software Foundation, Inc.
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | File: ld.info, Node: Overlay Description, Prev: Output Section Attributes, Up: SECTIONS
|
|---|
| 14 |
|
|---|
| 15 | Overlay Description
|
|---|
| 16 | -------------------
|
|---|
| 17 |
|
|---|
| 18 | An overlay description provides an easy way to describe sections
|
|---|
| 19 | which are to be loaded as part of a single memory image but are to be
|
|---|
| 20 | run at the same memory address. At run time, some sort of overlay
|
|---|
| 21 | manager will copy the overlaid sections in and out of the runtime
|
|---|
| 22 | memory address as required, perhaps by simply manipulating addressing
|
|---|
| 23 | bits. This approach can be useful, for example, when a certain region
|
|---|
| 24 | of memory is faster than another.
|
|---|
| 25 |
|
|---|
| 26 | Overlays are described using the `OVERLAY' command. The `OVERLAY'
|
|---|
| 27 | command is used within a `SECTIONS' command, like an output section
|
|---|
| 28 | description. The full syntax of the `OVERLAY' command is as follows:
|
|---|
| 29 | OVERLAY [START] : [NOCROSSREFS] [AT ( LDADDR )]
|
|---|
| 30 | {
|
|---|
| 31 | SECNAME1
|
|---|
| 32 | {
|
|---|
| 33 | OUTPUT-SECTION-COMMAND
|
|---|
| 34 | OUTPUT-SECTION-COMMAND
|
|---|
| 35 | ...
|
|---|
| 36 | } [:PHDR...] [=FILL]
|
|---|
| 37 | SECNAME2
|
|---|
| 38 | {
|
|---|
| 39 | OUTPUT-SECTION-COMMAND
|
|---|
| 40 | OUTPUT-SECTION-COMMAND
|
|---|
| 41 | ...
|
|---|
| 42 | } [:PHDR...] [=FILL]
|
|---|
| 43 | ...
|
|---|
| 44 | } [>REGION] [:PHDR...] [=FILL]
|
|---|
| 45 |
|
|---|
| 46 | Everything is optional except `OVERLAY' (a keyword), and each
|
|---|
| 47 | section must have a name (SECNAME1 and SECNAME2 above). The section
|
|---|
| 48 | definitions within the `OVERLAY' construct are identical to those
|
|---|
| 49 | within the general `SECTIONS' contruct (*note SECTIONS::), except that
|
|---|
| 50 | no addresses and no memory regions may be defined for sections within
|
|---|
| 51 | an `OVERLAY'.
|
|---|
| 52 |
|
|---|
| 53 | The sections are all defined with the same starting address. The
|
|---|
| 54 | load addresses of the sections are arranged such that they are
|
|---|
| 55 | consecutive in memory starting at the load address used for the
|
|---|
| 56 | `OVERLAY' as a whole (as with normal section definitions, the load
|
|---|
| 57 | address is optional, and defaults to the start address; the start
|
|---|
| 58 | address is also optional, and defaults to the current value of the
|
|---|
| 59 | location counter).
|
|---|
| 60 |
|
|---|
| 61 | If the `NOCROSSREFS' keyword is used, and there any references among
|
|---|
| 62 | the sections, the linker will report an error. Since the sections all
|
|---|
| 63 | run at the same address, it normally does not make sense for one
|
|---|
| 64 | section to refer directly to another. *Note NOCROSSREFS: Miscellaneous
|
|---|
| 65 | Commands.
|
|---|
| 66 |
|
|---|
| 67 | For each section within the `OVERLAY', the linker automatically
|
|---|
| 68 | defines two symbols. The symbol `__load_start_SECNAME' is defined as
|
|---|
| 69 | the starting load address of the section. The symbol
|
|---|
| 70 | `__load_stop_SECNAME' is defined as the final load address of the
|
|---|
| 71 | section. Any characters within SECNAME which are not legal within C
|
|---|
| 72 | identifiers are removed. C (or assembler) code may use these symbols
|
|---|
| 73 | to move the overlaid sections around as necessary.
|
|---|
| 74 |
|
|---|
| 75 | At the end of the overlay, the value of the location counter is set
|
|---|
| 76 | to the start address of the overlay plus the size of the largest
|
|---|
| 77 | section.
|
|---|
| 78 |
|
|---|
| 79 | Here is an example. Remember that this would appear inside a
|
|---|
| 80 | `SECTIONS' construct.
|
|---|
| 81 | OVERLAY 0x1000 : AT (0x4000)
|
|---|
| 82 | {
|
|---|
| 83 | .text0 { o1/*.o(.text) }
|
|---|
| 84 | .text1 { o2/*.o(.text) }
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | This will define both `.text0' and `.text1' to start at address 0x1000.
|
|---|
| 88 | `.text0' will be loaded at address 0x4000, and `.text1' will be loaded
|
|---|
| 89 | immediately after `.text0'. The following symbols will be defined:
|
|---|
| 90 | `__load_start_text0', `__load_stop_text0', `__load_start_text1',
|
|---|
| 91 | `__load_stop_text1'.
|
|---|
| 92 |
|
|---|
| 93 | C code to copy overlay `.text1' into the overlay area might look
|
|---|
| 94 | like the following.
|
|---|
| 95 |
|
|---|
| 96 | extern char __load_start_text1, __load_stop_text1;
|
|---|
| 97 | memcpy ((char *) 0x1000, &__load_start_text1,
|
|---|
| 98 | &__load_stop_text1 - &__load_start_text1);
|
|---|
| 99 |
|
|---|
| 100 | Note that the `OVERLAY' command is just syntactic sugar, since
|
|---|
| 101 | everything it does can be done using the more basic commands. The above
|
|---|
| 102 | example could have been written identically as follows.
|
|---|
| 103 |
|
|---|
| 104 | .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
|
|---|
| 105 | __load_start_text0 = LOADADDR (.text0);
|
|---|
| 106 | __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
|
|---|
| 107 | .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
|
|---|
| 108 | __load_start_text1 = LOADADDR (.text1);
|
|---|
| 109 | __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
|
|---|
| 110 | . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | File: ld.info, Node: MEMORY, Next: PHDRS, Prev: SECTIONS, Up: Scripts
|
|---|
| 114 |
|
|---|
| 115 | MEMORY Command
|
|---|
| 116 | ==============
|
|---|
| 117 |
|
|---|
| 118 | The linker's default configuration permits allocation of all
|
|---|
| 119 | available memory. You can override this by using the `MEMORY' command.
|
|---|
| 120 |
|
|---|
| 121 | The `MEMORY' command describes the location and size of blocks of
|
|---|
| 122 | memory in the target. You can use it to describe which memory regions
|
|---|
| 123 | may be used by the linker, and which memory regions it must avoid. You
|
|---|
| 124 | can then assign sections to particular memory regions. The linker will
|
|---|
| 125 | set section addresses based on the memory regions, and will warn about
|
|---|
| 126 | regions that become too full. The linker will not shuffle sections
|
|---|
| 127 | around to fit into the available regions.
|
|---|
| 128 |
|
|---|
| 129 | A linker script may contain at most one use of the `MEMORY' command.
|
|---|
| 130 | However, you can define as many blocks of memory within it as you
|
|---|
| 131 | wish. The syntax is:
|
|---|
| 132 | MEMORY
|
|---|
| 133 | {
|
|---|
| 134 | NAME [(ATTR)] : ORIGIN = ORIGIN, LENGTH = LEN
|
|---|
| 135 | ...
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | The NAME is a name used in the linker script to refer to the region.
|
|---|
| 139 | The region name has no meaning outside of the linker script. Region
|
|---|
| 140 | names are stored in a separate name space, and will not conflict with
|
|---|
| 141 | symbol names, file names, or section names. Each memory region must
|
|---|
| 142 | have a distinct name.
|
|---|
| 143 |
|
|---|
| 144 | The ATTR string is an optional list of attributes that specify
|
|---|
| 145 | whether to use a particular memory region for an input section which is
|
|---|
| 146 | not explicitly mapped in the linker script. As described in *Note
|
|---|
| 147 | SECTIONS::, if you do not specify an output section for some input
|
|---|
| 148 | section, the linker will create an output section with the same name as
|
|---|
| 149 | the input section. If you define region attributes, the linker will use
|
|---|
| 150 | them to select the memory region for the output section that it creates.
|
|---|
| 151 |
|
|---|
| 152 | The ATTR string must consist only of the following characters:
|
|---|
| 153 | `R'
|
|---|
| 154 | Read-only section
|
|---|
| 155 |
|
|---|
| 156 | `W'
|
|---|
| 157 | Read/write section
|
|---|
| 158 |
|
|---|
| 159 | `X'
|
|---|
| 160 | Executable section
|
|---|
| 161 |
|
|---|
| 162 | `A'
|
|---|
| 163 | Allocatable section
|
|---|
| 164 |
|
|---|
| 165 | `I'
|
|---|
| 166 | Initialized section
|
|---|
| 167 |
|
|---|
| 168 | `L'
|
|---|
| 169 | Same as `I'
|
|---|
| 170 |
|
|---|
| 171 | `!'
|
|---|
| 172 | Invert the sense of any of the preceding attributes
|
|---|
| 173 |
|
|---|
| 174 | If a unmapped section matches any of the listed attributes other than
|
|---|
| 175 | `!', it will be placed in the memory region. The `!' attribute
|
|---|
| 176 | reverses this test, so that an unmapped section will be placed in the
|
|---|
| 177 | memory region only if it does not match any of the listed attributes.
|
|---|
| 178 |
|
|---|
| 179 | The ORIGIN is an expression for the start address of the memory
|
|---|
| 180 | region. The expression must evaluate to a constant before memory
|
|---|
| 181 | allocation is performed, which means that you may not use any section
|
|---|
| 182 | relative symbols. The keyword `ORIGIN' may be abbreviated to `org' or
|
|---|
| 183 | `o' (but not, for example, `ORG').
|
|---|
| 184 |
|
|---|
| 185 | The LEN is an expression for the size in bytes of the memory region.
|
|---|
| 186 | As with the ORIGIN expression, the expression must evaluate to a
|
|---|
| 187 | constant before memory allocation is performed. The keyword `LENGTH'
|
|---|
| 188 | may be abbreviated to `len' or `l'.
|
|---|
| 189 |
|
|---|
| 190 | In the following example, we specify that there are two memory
|
|---|
| 191 | regions available for allocation: one starting at `0' for 256 kilobytes,
|
|---|
| 192 | and the other starting at `0x40000000' for four megabytes. The linker
|
|---|
| 193 | will place into the `rom' memory region every section which is not
|
|---|
| 194 | explicitly mapped into a memory region, and is either read-only or
|
|---|
| 195 | executable. The linker will place other sections which are not
|
|---|
| 196 | explicitly mapped into a memory region into the `ram' memory region.
|
|---|
| 197 |
|
|---|
| 198 | MEMORY
|
|---|
| 199 | {
|
|---|
| 200 | rom (rx) : ORIGIN = 0, LENGTH = 256K
|
|---|
| 201 | ram (!rx) : org = 0x40000000, l = 4M
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | Once you define a memory region, you can direct the linker to place
|
|---|
| 205 | specific output sections into that memory region by using the `>REGION'
|
|---|
| 206 | output section attribute. For example, if you have a memory region
|
|---|
| 207 | named `mem', you would use `>mem' in the output section definition.
|
|---|
| 208 | *Note Output Section Region::. If no address was specified for the
|
|---|
| 209 | output section, the linker will set the address to the next available
|
|---|
| 210 | address within the memory region. If the combined output sections
|
|---|
| 211 | directed to a memory region are too large for the region, the linker
|
|---|
| 212 | will issue an error message.
|
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 | File: ld.info, Node: PHDRS, Next: VERSION, Prev: MEMORY, Up: Scripts
|
|---|
| 216 |
|
|---|
| 217 | PHDRS Command
|
|---|
| 218 | =============
|
|---|
| 219 |
|
|---|
| 220 | The ELF object file format uses "program headers", also knows as
|
|---|
| 221 | "segments". The program headers describe how the program should be
|
|---|
| 222 | loaded into memory. You can print them out by using the `objdump'
|
|---|
| 223 | program with the `-p' option.
|
|---|
| 224 |
|
|---|
| 225 | When you run an ELF program on a native ELF system, the system loader
|
|---|
| 226 | reads the program headers in order to figure out how to load the
|
|---|
| 227 | program. This will only work if the program headers are set correctly.
|
|---|
| 228 | This manual does not describe the details of how the system loader
|
|---|
| 229 | interprets program headers; for more information, see the ELF ABI.
|
|---|
| 230 |
|
|---|
| 231 | The linker will create reasonable program headers by default.
|
|---|
| 232 | However, in some cases, you may need to specify the program headers more
|
|---|
| 233 | precisely. You may use the `PHDRS' command for this purpose. When the
|
|---|
| 234 | linker sees the `PHDRS' command in the linker script, it will not
|
|---|
| 235 | create any program headers other than the ones specified.
|
|---|
| 236 |
|
|---|
| 237 | The linker only pays attention to the `PHDRS' command when
|
|---|
| 238 | generating an ELF output file. In other cases, the linker will simply
|
|---|
| 239 | ignore `PHDRS'.
|
|---|
| 240 |
|
|---|
| 241 | This is the syntax of the `PHDRS' command. The words `PHDRS',
|
|---|
| 242 | `FILEHDR', `AT', and `FLAGS' are keywords.
|
|---|
| 243 |
|
|---|
| 244 | PHDRS
|
|---|
| 245 | {
|
|---|
| 246 | NAME TYPE [ FILEHDR ] [ PHDRS ] [ AT ( ADDRESS ) ]
|
|---|
| 247 | [ FLAGS ( FLAGS ) ] ;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | The NAME is used only for reference in the `SECTIONS' command of the
|
|---|
| 251 | linker script. It is not put into the output file. Program header
|
|---|
| 252 | names are stored in a separate name space, and will not conflict with
|
|---|
| 253 | symbol names, file names, or section names. Each program header must
|
|---|
| 254 | have a distinct name.
|
|---|
| 255 |
|
|---|
| 256 | Certain program header types describe segments of memory which the
|
|---|
| 257 | system loader will load from the file. In the linker script, you
|
|---|
| 258 | specify the contents of these segments by placing allocatable output
|
|---|
| 259 | sections in the segments. You use the `:PHDR' output section attribute
|
|---|
| 260 | to place a section in a particular segment. *Note Output Section
|
|---|
| 261 | Phdr::.
|
|---|
| 262 |
|
|---|
| 263 | It is normal to put certain sections in more than one segment. This
|
|---|
| 264 | merely implies that one segment of memory contains another. You may
|
|---|
| 265 | repeat `:PHDR', using it once for each segment which should contain the
|
|---|
| 266 | section.
|
|---|
| 267 |
|
|---|
| 268 | If you place a section in one or more segments using `:PHDR', then
|
|---|
| 269 | the linker will place all subsequent allocatable sections which do not
|
|---|
| 270 | specify `:PHDR' in the same segments. This is for convenience, since
|
|---|
| 271 | generally a whole set of contiguous sections will be placed in a single
|
|---|
| 272 | segment. You can use `:NONE' to override the default segment and tell
|
|---|
| 273 | the linker to not put the section in any segment at all.
|
|---|
| 274 |
|
|---|
| 275 | You may use the `FILEHDR' and `PHDRS' keywords appear after the
|
|---|
| 276 | program header type to further describe the contents of the segment.
|
|---|
| 277 | The `FILEHDR' keyword means that the segment should include the ELF
|
|---|
| 278 | file header. The `PHDRS' keyword means that the segment should include
|
|---|
| 279 | the ELF program headers themselves.
|
|---|
| 280 |
|
|---|
| 281 | The TYPE may be one of the following. The numbers indicate the
|
|---|
| 282 | value of the keyword.
|
|---|
| 283 |
|
|---|
| 284 | `PT_NULL' (0)
|
|---|
| 285 | Indicates an unused program header.
|
|---|
| 286 |
|
|---|
| 287 | `PT_LOAD' (1)
|
|---|
| 288 | Indicates that this program header describes a segment to be
|
|---|
| 289 | loaded from the file.
|
|---|
| 290 |
|
|---|
| 291 | `PT_DYNAMIC' (2)
|
|---|
| 292 | Indicates a segment where dynamic linking information can be found.
|
|---|
| 293 |
|
|---|
| 294 | `PT_INTERP' (3)
|
|---|
| 295 | Indicates a segment where the name of the program interpreter may
|
|---|
| 296 | be found.
|
|---|
| 297 |
|
|---|
| 298 | `PT_NOTE' (4)
|
|---|
| 299 | Indicates a segment holding note information.
|
|---|
| 300 |
|
|---|
| 301 | `PT_SHLIB' (5)
|
|---|
| 302 | A reserved program header type, defined but not specified by the
|
|---|
| 303 | ELF ABI.
|
|---|
| 304 |
|
|---|
| 305 | `PT_PHDR' (6)
|
|---|
| 306 | Indicates a segment where the program headers may be found.
|
|---|
| 307 |
|
|---|
| 308 | EXPRESSION
|
|---|
| 309 | An expression giving the numeric type of the program header. This
|
|---|
| 310 | may be used for types not defined above.
|
|---|
| 311 |
|
|---|
| 312 | You can specify that a segment should be loaded at a particular
|
|---|
| 313 | address in memory by using an `AT' expression. This is identical to the
|
|---|
| 314 | `AT' command used as an output section attribute (*note Output Section
|
|---|
| 315 | LMA::). The `AT' command for a program header overrides the output
|
|---|
| 316 | section attribute.
|
|---|
| 317 |
|
|---|
| 318 | The linker will normally set the segment flags based on the sections
|
|---|
| 319 | which comprise the segment. You may use the `FLAGS' keyword to
|
|---|
| 320 | explicitly specify the segment flags. The value of FLAGS must be an
|
|---|
| 321 | integer. It is used to set the `p_flags' field of the program header.
|
|---|
| 322 |
|
|---|
| 323 | Here is an example of `PHDRS'. This shows a typical set of program
|
|---|
| 324 | headers used on a native ELF system.
|
|---|
| 325 |
|
|---|
| 326 | PHDRS
|
|---|
| 327 | {
|
|---|
| 328 | headers PT_PHDR PHDRS ;
|
|---|
| 329 | interp PT_INTERP ;
|
|---|
| 330 | text PT_LOAD FILEHDR PHDRS ;
|
|---|
| 331 | data PT_LOAD ;
|
|---|
| 332 | dynamic PT_DYNAMIC ;
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | SECTIONS
|
|---|
| 336 | {
|
|---|
| 337 | . = SIZEOF_HEADERS;
|
|---|
| 338 | .interp : { *(.interp) } :text :interp
|
|---|
| 339 | .text : { *(.text) } :text
|
|---|
| 340 | .rodata : { *(.rodata) } /* defaults to :text */
|
|---|
| 341 | ...
|
|---|
| 342 | . = . + 0x1000; /* move to a new page in memory */
|
|---|
| 343 | .data : { *(.data) } :data
|
|---|
| 344 | .dynamic : { *(.dynamic) } :data :dynamic
|
|---|
| 345 | ...
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 |
|
|---|
| 349 | File: ld.info, Node: VERSION, Next: Expressions, Prev: PHDRS, Up: Scripts
|
|---|
| 350 |
|
|---|
| 351 | VERSION Command
|
|---|
| 352 | ===============
|
|---|
| 353 |
|
|---|
| 354 | The linker supports symbol versions when using ELF. Symbol versions
|
|---|
| 355 | are only useful when using shared libraries. The dynamic linker can use
|
|---|
| 356 | symbol versions to select a specific version of a function when it runs
|
|---|
| 357 | a program that may have been linked against an earlier version of the
|
|---|
| 358 | shared library.
|
|---|
| 359 |
|
|---|
| 360 | You can include a version script directly in the main linker script,
|
|---|
| 361 | or you can supply the version script as an implicit linker script. You
|
|---|
| 362 | can also use the `--version-script' linker option.
|
|---|
| 363 |
|
|---|
| 364 | The syntax of the `VERSION' command is simply
|
|---|
| 365 | VERSION { version-script-commands }
|
|---|
| 366 |
|
|---|
| 367 | The format of the version script commands is identical to that used
|
|---|
| 368 | by Sun's linker in Solaris 2.5. The version script defines a tree of
|
|---|
| 369 | version nodes. You specify the node names and interdependencies in the
|
|---|
| 370 | version script. You can specify which symbols are bound to which
|
|---|
| 371 | version nodes, and you can reduce a specified set of symbols to local
|
|---|
| 372 | scope so that they are not globally visible outside of the shared
|
|---|
| 373 | library.
|
|---|
| 374 |
|
|---|
| 375 | The easiest way to demonstrate the version script language is with a
|
|---|
| 376 | few examples.
|
|---|
| 377 |
|
|---|
| 378 | VERS_1.1 {
|
|---|
| 379 | global:
|
|---|
| 380 | foo1;
|
|---|
| 381 | local:
|
|---|
| 382 | old*;
|
|---|
| 383 | original*;
|
|---|
| 384 | new*;
|
|---|
| 385 | };
|
|---|
| 386 |
|
|---|
| 387 | VERS_1.2 {
|
|---|
| 388 | foo2;
|
|---|
| 389 | } VERS_1.1;
|
|---|
| 390 |
|
|---|
| 391 | VERS_2.0 {
|
|---|
| 392 | bar1; bar2;
|
|---|
| 393 | } VERS_1.2;
|
|---|
| 394 |
|
|---|
| 395 | This example version script defines three version nodes. The first
|
|---|
| 396 | version node defined is `VERS_1.1'; it has no other dependencies. The
|
|---|
| 397 | script binds the symbol `foo1' to `VERS_1.1'. It reduces a number of
|
|---|
| 398 | symbols to local scope so that they are not visible outside of the
|
|---|
| 399 | shared library; this is done using wildcard patterns, so that any
|
|---|
| 400 | symbol whose name begins with `old', `original', or `new' is matched.
|
|---|
| 401 | The wildcard patterns available are the same as those used in the shell
|
|---|
| 402 | when matching filenames (also known as "globbing").
|
|---|
| 403 |
|
|---|
| 404 | Next, the version script defines node `VERS_1.2'. This node depends
|
|---|
| 405 | upon `VERS_1.1'. The script binds the symbol `foo2' to the version
|
|---|
| 406 | node `VERS_1.2'.
|
|---|
| 407 |
|
|---|
| 408 | Finally, the version script defines node `VERS_2.0'. This node
|
|---|
| 409 | depends upon `VERS_1.2'. The scripts binds the symbols `bar1' and
|
|---|
| 410 | `bar2' are bound to the version node `VERS_2.0'.
|
|---|
| 411 |
|
|---|
| 412 | When the linker finds a symbol defined in a library which is not
|
|---|
| 413 | specifically bound to a version node, it will effectively bind it to an
|
|---|
| 414 | unspecified base version of the library. You can bind all otherwise
|
|---|
| 415 | unspecified symbols to a given version node by using `global: *;'
|
|---|
| 416 | somewhere in the version script.
|
|---|
| 417 |
|
|---|
| 418 | The names of the version nodes have no specific meaning other than
|
|---|
| 419 | what they might suggest to the person reading them. The `2.0' version
|
|---|
| 420 | could just as well have appeared in between `1.1' and `1.2'. However,
|
|---|
| 421 | this would be a confusing way to write a version script.
|
|---|
| 422 |
|
|---|
| 423 | Node name can be omited, provided it is the only version node in the
|
|---|
| 424 | version script. Such version script doesn't assign any versions to
|
|---|
| 425 | symbols, only selects which symbols will be globally visible out and
|
|---|
| 426 | which won't.
|
|---|
| 427 |
|
|---|
| 428 | { global: foo; bar; local: *; };
|
|---|
| 429 |
|
|---|
| 430 | When you link an application against a shared library that has
|
|---|
| 431 | versioned symbols, the application itself knows which version of each
|
|---|
| 432 | symbol it requires, and it also knows which version nodes it needs from
|
|---|
| 433 | each shared library it is linked against. Thus at runtime, the dynamic
|
|---|
| 434 | loader can make a quick check to make sure that the libraries you have
|
|---|
| 435 | linked against do in fact supply all of the version nodes that the
|
|---|
| 436 | application will need to resolve all of the dynamic symbols. In this
|
|---|
| 437 | way it is possible for the dynamic linker to know with certainty that
|
|---|
| 438 | all external symbols that it needs will be resolvable without having to
|
|---|
| 439 | search for each symbol reference.
|
|---|
| 440 |
|
|---|
| 441 | The symbol versioning is in effect a much more sophisticated way of
|
|---|
| 442 | doing minor version checking that SunOS does. The fundamental problem
|
|---|
| 443 | that is being addressed here is that typically references to external
|
|---|
| 444 | functions are bound on an as-needed basis, and are not all bound when
|
|---|
| 445 | the application starts up. If a shared library is out of date, a
|
|---|
| 446 | required interface may be missing; when the application tries to use
|
|---|
| 447 | that interface, it may suddenly and unexpectedly fail. With symbol
|
|---|
| 448 | versioning, the user will get a warning when they start their program if
|
|---|
| 449 | the libraries being used with the application are too old.
|
|---|
| 450 |
|
|---|
|
|---|