Index: gen-doc.texi =================================================================== RCS file: /cvs/src/src/ld/gen-doc.texi,v retrieving revision 1.3 diff -u -3 -p -B -u -b -B -p -r1.3 gen-doc.texi --- gen-doc.texi 30 Oct 2001 15:20:10 -0000 1.3 +++ gen-doc.texi 18 Dec 2002 00:44:54 -0000 @@ -7,6 +7,7 @@ @set I960 @set MMIX @set TICOFF +@set WIN32 @c 3. Properties of this configuration @clear SingleFormat Index: ld.texinfo =================================================================== RCS file: /cvs/src/src/ld/ld.texinfo,v retrieving revision 1.77 diff -u -3 -p -B -u -b -B -p -r1.77 ld.texinfo --- ld.texinfo 2 Dec 2002 00:40:28 -0000 1.77 +++ ld.texinfo 18 Dec 2002 00:45:15 -0000 @@ -43,6 +43,7 @@ @set C54X @set V850 @set VAX +@set WIN32 @end ifset @c man end @@ -145,6 +146,9 @@ section entitled "GNU Free Documentation @ifset TICOFF * TI COFF:: ld and the TI COFF @end ifset +@ifset WIN32 +* Win32:: ld and WIN32 (cygwin/mingw) +@end ifset @end ifclear @ifclear SingleFormat * BFD:: BFD @@ -1789,8 +1792,8 @@ uwin, pw, etc. For instance, cygwin DLL @item --enable-auto-import Do sophisticated linking of @code{_symbol} to @code{__imp__symbol} for DATA imports from DLLs, and create the necessary thunking symbols when -building the DLLs with those DATA exports. This generally will 'just -work' -- but sometimes you may see this message: +building the import libraries with those DATA exports. This generally +will 'just work' -- but sometimes you may see this message: "variable '' can't be auto-imported. Please read the documentation for ld's @code{--enable-auto-import} for details." @@ -4380,6 +4383,9 @@ functionality are not listed. @ifset TICOFF * TI COFF:: @command{ld} and TI COFF @end ifset +@ifset WIN32 +* WIN32:: @command{ld} and WIN32 (cygwin/mingw) +@end ifset @end menu @end ifset @@ -4414,6 +4420,99 @@ page of memory, and changes them to use (That is: the linker turns @samp{mov.b @code{@@}@var{aa}:16} into @samp{mov.b @code{@@}@var{aa}:8} whenever the address @var{aa} is in the top page of memory). +@end table + +@ifclear GENERIC +@lowersections +@end ifclear +@end ifset + +@ifset WIN32 +@ifclear GENERIC +@raisesections +@end ifclear + +@node WIN32 +@section @command{ld} and WIN32 (cygwin/mingw) + +This section describes some of the win32 specific @command{ld} issuses. + +@table @emph +@cindex import libaries +@item import libaries +Standard windows linker creates and uses so called import libraries, which +contains stuff for linking to dll's. They are regular static archives and +could be handled as any other static archive. +The cygwin/mingw ports of chas specific support for creating such +libraries provided with the @samp{--out-implib} command line option. + +@cindex automatic data imports +@item automatic data imports +The standard windows dll format supports data imports from dlls only +by adding special decorations (dllimport/dllexport), which lets the +compiler produce specific assembler instructions to deal with this issue. +This increase the needed porting efforts, especially for big c++ libraries +and applications. +The auto-import feature, which was initial provided by Paul Sokolovsky, allows +to skip this decoration to archive a behavior more like ld on other platforms +does. This feature could be performed with the @samp{--enable-auto-import} +command-line option. + +@cindex direct linking to a dll +@item direct linking to a dll +The cygwin/mingw port of @command{ld} supports direct linking (including data symbols) +to a dll without the usage of any import libraries. Using this features saves +very much linking time and memory in case of bigger libaries or applications. +This is because bigger libaries, especially c++ libaries, gets very huge import +libaries (I have seen import libraries about 10 MB size). + +Linking directly to a dll could be done with the already known command line options +@samp{-L} and @samp{-l}. This is because @command{ld} has built in support for several +library names. See below, where @samp{xxx} means the basic library name like "png" for +the png library: + +@example +libxxx.dll.a +xxx.dll.a +libxxx.a +cygxxx.dll +libxxx.dll +xxx.dll +@end example + +The generic cygwin/mingw path layout uses a @samp{bin} directory for applications +and dll's and a @samp{lib} directory for the import libraries. + +@example +bin/ + cygxxx.dll + +lib/ + libxxx.dll.a (in case of dll's) + libxxx.a (in case of static archive) +@end example + +Linking to a dll could be done by two ways: + +1. use the dll directly by adding the @samp{bin} path to the link line +@example +gcc -Wl,-verbose -o a.exe -L../bin/ -lxxx +@end example + +2. create a symbolic link from the dll to a file in the @samp{lib} dir according to the above +mentioned search pattern. This should be used to avoid unwanted changes in the tools needed for making the app/dll. + +@example +ln -s bin/cygxxx.dll lib/[cyg|lib|]xxx.dll[.a] +@end example + +Then you can link without any make environment changes. + +@example +gcc -Wl,-verbose -o a.exe -L../lib/ -lxxx +@end example + + @end table @ifclear GENERIC