This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: dlltool -N [PATCH]
Shaun Jackman wrote:
> I'm using dlltool to create static library wrappers around
> pre-existing DLLs (such as coredll.dll and winsock.dll). The dllimport
> names, such as malloc, do not have an initial underscore. gcc, otoh,
No, the names in the .def don't, but dlltool adds one. See below.
> expects malloc() to be called _malloc. So, -N adds an underscore to
Yes. All regular C symbols on PECOFF 386 having a leading underscore in
the asm name (the low-level symbol name). dlltool automatically adds a
single leading underscore to any symbol it creates to ensure proper C
linkage.
> the external symbol, but not the dllimport name.
This is a transcript from a terminal using vanilla release binutils 2.15
on i686-pc-mingw32:
$ cat elishacuthbert.def
LIBRARY elishacuthbert.dll
EXPORTS
gorgeous
$ dlltool -d elishacuthbert.def -l libelishacuthbert.a
$ objdump -t libelishacuthbert.a | grep gorgeous
[ 7](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _gorgeous
[ 8](sec 5)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__gorgeous
$
Notice that dlltool has already added a single leading underscore to the
imported external symbol asm name, as per the ABI. (The other __imp__
name is the dllimport name.)
In other words, I don't see why -N would be necessary. Are you saying
that you have some function with a C name of "_malloc" with an asm name
of "__malloc", that is called malloc in the .def file? If so, I'd be
curious to know why its called _malloc instead of malloc, as it is named
in the .def file.
> I'm not familiar with --ext-prefix-alias. I didn't see any reference
> to it in dlltool(1). Is it a switch to another program?
It is in CVS, but not yet in any binutils release. It adds aliases with
a specific external prefix to the external symbols in an import library.
See http://sources.redhat.com/ml/binutils/2004-07/msg00130.html for
details.
Aaron W. LaFramboise