From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson) Subject: Re: DLLTOOL documentation? 27 Mar 1997 08:40:45 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199703260344.OAA01660.cygnus.gnu-win32@mundook.cs.mu.OZ.AU> Content-Type: text Original-To: bjames AT clear DOT net DOT nz (Bruce James) Original-Cc: gnu-win32 AT cygnus DOT com (gnu-win32) In-Reply-To: <199703250849.UAA06316@fep2-orange.clear.net.nz> from "Bruce James" at Mar 25, 97 08:52:19 pm X-Mailer: ELM [version 2.4 PL24] Original-Sender: owner-gnu-win32 AT cygnus DOT com Bruce James, you wrote: > > 2 x Q's: > > 1. Is there any documentation on DLLTOOL available? None that I know of, apart from some documentation in the source code (which I've appended below), and the output of `dlltool --help'. > 2. What's the Gnu equivalent of Borland's IMPLIB for generating an import > library from a DLL? I don't know what Borland's IMPLIB is, but I suspect that dlltool's `--output-lib' option is probably what you are looking for. See also . Cheers, Fergus. -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp. The following comes from src/binutils/dlltool.c from cdk-src.tar.gz. /* This program allows you to build the files necessary to create DLLs to run on a system which understands PE format image files. (eg, Windows NT) See "Peering Inside the PE: A Tour of the Win32 Portable Executable File Format", MSJ 1994, Volume 9 for more information. Also see "Microsoft Portable Executable and Common Object File Format, Specification 4.1" for more information. A DLL contains an export table which contains the information which the runtime loader needs to tie up references from a referencing program. The export table is generated by this program by reading in a .DEF file or scanning the .a and .o files which will be in the DLL. A .o file can contain information in special ".drectve" sections with export information. A DEF file contains any number of the following commands: NAME [ , ] The result is going to be .EXE LIBRARY [ , ] The result is going to be .DLL EXPORTS ( [ = ] [ @ ] [ NONAME ] [CONSTANT] ) * Declares name1 as an exported symbol from the DLL, with optional ordinal number IMPORTS ( [ = ] . ) * Ignored for compatibility DESCRIPTION Puts into output .exp file in the .rdata section [STACKSIZE|HEAPSIZE] [ , ] Generates --stack|--heap , in the output .drectve section. The linker will see this and act upon it. [CODE|DATA] + SECTIONS ( + )* = READ | WRITE | EXECUTE | SHARED Generates --attr in the output .drectve section. The linker will see this and act upon it. A -export: in a .drectve section in an input .o or .a file to this program is equivalent to a EXPORTS in a .DEF file. The program generates output files with the prefix supplied on the command line, or in the def file, or taken from the first supplied argument. The .exp.s file contains the information necessary to export the routines in the DLL. The .lib.s file contains the information necessary to use the DLL's routines from a referencing program. Example: file1.c: asm (".section .drectve"); asm (".ascii \"-export:adef\""); adef(char *s) { printf("hello from the dll %s\n",s); } bdef(char *s) { printf("hello from the dll and the other entry point %s\n",s); } file2.c: asm (".section .drectve"); asm (".ascii \"-export:cdef\""); asm (".ascii \"-export:ddef\""); cdef(char *s) { printf("hello from the dll %s\n",s); } ddef(char *s) { printf("hello from the dll and the other entry point %s\n",s); } printf() { return 9; } main.c main() { cdef(); } thedll.def LIBRARY thedll HEAPSIZE 0x40000, 0x2000 EXPORTS bdef @ 20 cdef @ 30 NONAME SECTIONS donkey READ WRITE aardvark EXECUTE # compile up the parts of the dll gcc -c file1.c gcc -c file2.c # put them in a library (you don't have to, you # could name all the .os on the dlltool line) ar qcv thedll.in file1.o file2.o ranlib thedll.in # run this tool over the library and the def file ./dlltool --def thedll.def --output-exp thedll.o --output-lib thedll.a # build the dll with the library with file1.o, file2.o and the export table ld -o thedll.dll thedll.o thedll.in # build the mainline gcc -c themain.c # link the executable with the import library ld -e main -Tthemain.ld -o themain.exe themain.o thedll.a */ - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".