Changeset 609 for branches/GNU/src/binutils/ld/ldint.texinfo
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/ld/ldint.texinfo
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 85 85 * Emulations:: How linker emulations are generated 86 86 * Emulation Walkthrough:: A Walkthrough of a Typical Emulation 87 * Architecture Specific:: Some Architecture Specific Notes 87 88 * GNU Free Documentation License:: GNU Free Documentation License 88 89 @end menu … … 239 240 240 241 The @file{genscripts.sh} script will invoke the @file{scripttempl} 241 script 5 or 6times. Each time it will set the shell variable242 script 5 to 8 times. Each time it will set the shell variable 242 243 @code{LD_FLAG} to a different value. When the linker is run, the 243 244 options used will direct it to select a particular script. (Script … … 278 279 with the @code{-shared} option. The output has an extension of 279 280 @file{.xs}. 281 @item c 282 The @file{scripttempl} script is only invoked with @code{LD_FLAG} set to 283 this value if @code{GENERATE_COMBRELOC_SCRIPT} is defined in the 284 @file{emulparams} file or if @code{SCRIPT_NAME} is @code{elf}. The 285 @file{emultempl} script must arrange to use this script at the appropriate 286 time, normally when the linker is invoked with the @code{-z combreloc} 287 option. The output has an extension of 288 @file{.xc}. 289 @item cshared 290 The @file{scripttempl} script is only invoked with @code{LD_FLAG} set to 291 this value if @code{GENERATE_COMBRELOC_SCRIPT} is defined in the 292 @file{emulparams} file or if @code{SCRIPT_NAME} is @code{elf} and 293 @code{GENERATE_SHLIB_SCRIPT} is defined in the @file{emulparms} file. 294 The @file{emultempl} script must arrange to use this script at the 295 appropriate time, normally when the linker is invoked with the @code{-shared 296 -z combreloc} option. The output has an extension of @file{.xsc}. 280 297 @end table 281 298 … … 301 318 This will be set to a non-empty string when generating a @code{-shared} 302 319 script. 320 321 @item COMBRELOC 322 This will be set to a non-empty string when generating @code{-z combreloc} 323 scripts to a temporary file name which can be used during script generation. 303 324 @end table 304 325 … … 571 592 572 593 @end itemize 594 595 @node Architecture Specific 596 @chapter Some Architecture Specific Notes 597 598 This is the place for notes on the behavior of @code{ld} on 599 specific platforms. Currently, only Intel x86 is documented (and 600 of that, only the auto-import behavior for DLLs). 601 602 @menu 603 * ix86:: Intel x86 604 @end menu 605 606 @node ix86 607 @section Intel x86 608 609 @table @emph 610 @code{ld} can create DLLs that operate with various runtimes available 611 on a common x86 operating system. These runtimes include native (using 612 the mingw "platform"), cygwin, and pw. 613 614 @item auto-import from DLLs 615 @enumerate 616 @item 617 With this feature on, DLL clients can import variables from DLL 618 without any concern from their side (for example, without any source 619 code modifications). Auto-import can be enabled using the 620 @code{--enable-auto-import} flag, or disabled via the 621 @code{--disable-auto-import} flag. Auto-import is disabled by default. 622 623 @item 624 This is done completely in bounds of the PE specification (to be fair, 625 there's a minor violation of the spec at one point, but in practice 626 auto-import works on all known variants of that common x86 operating 627 system) So, the resulting DLL can be used with any other PE 628 compiler/linker. 629 630 @item 631 Auto-import is fully compatible with standard import method, in which 632 variables are decorated using attribute modifiers. Libraries of either 633 type may be mixed together. 634 635 @item 636 Overhead (space): 8 bytes per imported symbol, plus 20 for each 637 reference to it; Overhead (load time): negligible; Overhead 638 (virtual/physical memory): should be less than effect of DLL 639 relocation. 640 @end enumerate 641 642 Motivation 643 644 The obvious and only way to get rid of dllimport insanity is 645 to make client access variable directly in the DLL, bypassing 646 the extra dereference imposed by ordinary DLL runtime linking. 647 I.e., whenever client contains someting like 648 649 @code{mov dll_var,%eax,} 650 651 address of dll_var in the command should be relocated to point 652 into loaded DLL. The aim is to make OS loader do so, and than 653 make ld help with that. Import section of PE made following 654 way: there's a vector of structures each describing imports 655 from particular DLL. Each such structure points to two other 656 parellel vectors: one holding imported names, and one which 657 will hold address of corresponding imported name. So, the 658 solution is de-vectorize these structures, making import 659 locations be sparse and pointing directly into code. 660 661 Implementation 662 663 For each reference of data symbol to be imported from DLL (to 664 set of which belong symbols with name <sym>, if __imp_<sym> is 665 found in implib), the import fixup entry is generated. That 666 entry is of type IMAGE_IMPORT_DESCRIPTOR and stored in .idata$3 667 subsection. Each fixup entry contains pointer to symbol's address 668 within .text section (marked with __fuN_<sym> symbol, where N is 669 integer), pointer to DLL name (so, DLL name is referenced by 670 multiple entries), and pointer to symbol name thunk. Symbol name 671 thunk is singleton vector (__nm_th_<symbol>) pointing to 672 IMAGE_IMPORT_BY_NAME structure (__nm_<symbol>) directly containing 673 imported name. Here comes that "om the edge" problem mentioned above: 674 PE specification rambles that name vector (OriginalFirstThunk) should 675 run in parallel with addresses vector (FirstThunk), i.e. that they 676 should have same number of elements and terminated with zero. We violate 677 this, since FirstThunk points directly into machine code. But in 678 practice, OS loader implemented the sane way: it goes thru 679 OriginalFirstThunk and puts addresses to FirstThunk, not something 680 else. It once again should be noted that dll and symbol name 681 structures are reused across fixup entries and should be there 682 anyway to support standard import stuff, so sustained overhead is 683 20 bytes per reference. Other question is whether having several 684 IMAGE_IMPORT_DESCRIPTORS for the same DLL is possible. Answer is yes, 685 it is done even by native compiler/linker (libth32's functions are in 686 fact resident in windows9x kernel32.dll, so if you use it, you have 687 two IMAGE_IMPORT_DESCRIPTORS for kernel32.dll). Yet other question is 688 whether referencing the same PE structures several times is valid. 689 The answer is why not, prohibiting that (detecting violation) would 690 require more work on behalf of loader than not doing it. 691 692 @end table 573 693 574 694 @node GNU Free Documentation License -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.