This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Patch/PE-COFF: Provide default suffix to NAME or LIBRARY names in .def files
- From: Danny Smith <danny_smith_0000 at yahoo dot co dot nz>
- To: dannysmith at users dot sourceforge dot net, binutils <binutils at sources dot redhat dot com>
- Date: Wed, 1 Feb 2006 13:40:28 +1300 (NZDT)
- Subject: Re: Patch/PE-COFF: Provide default suffix to NAME or LIBRARY names in .def files
- Reply-to: dannysmith at users dot sourceforge dot net
--- Danny Smith <danny_smith_0000@yahoo.co.nz> wrote:
> Hello
The last message omitted the doco part of the patch. Sorry. Here it is again:
Hello
According to MS doc's (and comments in binutils/dlltool.c). the suffix
of the internal names of images defaults to ".exe" if the name is
specified by NAME statement in a .def file, and to ".dll" if specified
by a LIBRARY statement. Failing to append a suffix so can cause dll
import problems since it is this internal name that is put into the
import lib and used when searching for the libary at load time. An
example of this problem is at:
https://sourceforge.net/tracker/index.php?func=detail&aid=1401442&group_id=2435&atid=102435
This fixes by appending a default suffix, if necessary, when we parse
the .def file.
ChangeLog
2006-02-01 Danny Smith <dannysmith@users.sourceforge.net>
* deffilep.y (def_image_name): If the image name does not have a
suffix, append the default.
*ld.texinfo: Document NAME, LIBRARY usage in PE-COFF .def files.
Index: deffilep.y
===================================================================
RCS file: /cvs/src/src/ld/deffilep.y,v
retrieving revision 1.20
diff -c -3 -p -r1.20 deffilep.y
*** deffilep.y 12 May 2005 07:32:02 -0000 1.20
--- deffilep.y 1 Feb 2006 00:33:46 -0000
*************** def_image_name (const char *name, int ba
*** 654,660 ****
def_filename, linenumber, is_dll ? "LIBRARY" : "NAME", name);
if (def->name)
free (def->name);
! def->name = xstrdup (image_name);
def->base_address = base;
def->is_dll = is_dll;
}
--- 654,669 ----
def_filename, linenumber, is_dll ? "LIBRARY" : "NAME", name);
if (def->name)
free (def->name);
! /* Append the default suffix, if none specified. */
! if (strchr (image_name, '.') == 0)
! {
! int len = strlen (image_name);
! def->name = xmalloc (len + 5);
! memcpy (def->name, image_name, len);
! memcpy (def->name + len, is_dll ? ".dll\0" : ".exe\0", 5);
! }
! else
! def->name = xstrdup (image_name);
def->base_address = base;
def->is_dll = is_dll;
}
Index: ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.155
diff -c -3 -p -r1.155 ld.texinfo
*** ld.texinfo 31 Jan 2006 22:13:41 -0000 1.155
--- ld.texinfo 1 Feb 2006 00:34:08 -0000
*************** by "forwarding" to another module and tr
*** 5598,5603 ****
--- 5598,5619 ----
@code{afoo} exported from the DLL @samp{abc.dll}. The final symbol
@code{var1} is declared to be a data object.
+ The optional @code{LIBRARY <name>} command indicates the @emph{internal}
+ name of the output DLL. If @samp{<name>} does not include a suffix,
+ the default library suffix, @samp{.DLL} is appended.
+
+ When the .DEF file is used to build an application. rather than a
+ library, the @code{NAME <name>} command shoud be used instead of
+ @code{LIBRARY}. If @samp{<name>} does not include a suffix, the default
+ executable suffix, @samp{.EXE} is appended.
+
+ With either @code{LIBRARY <name>} or @code{NAME <name>} the optional
+ specification @code{BASE = <number>} may be used to specify a
+ non-default base address for the image.
+
+ If neither @code{LIBRARY <name>} nor @code{NAME <name>} is specified,
+ the internal name is the same as the filename specified on the command line.
+
The complete specification of an export symbol is:
@example
Send instant messages to your online friends http://au.messenger.yahoo.com