[PATCH] PE direct linking to dlls, accept any filename.

Pedro Alves pedro_alves@portugalmail.pt
Sat Dec 16 15:47:00 GMT 2006


Hi Danny,

First of all, thanks for taking the trouble of testing this.

I installed stock MinGW + msys + 'a few GnuWin32 (bison/texutils/flex/libiconv/libintl)
apps' to be able to build binutils.  It built fine, but I don't know yet how
to run the testsuite (no runtest/dejagnu).  So I ran the test manually.  More comments
below.

Danny Smith escreveu:

> 
> The new direct_dll.sl test fails on mingw32. 
> 
> gcc -B/develop/cvs/binutils/build/ld/tmpdir/ld/ -L/mingw/mingw32/lib
> -L/mingw/lib -L/usr/local/lib -L/lib -L/usr/lib  -o
> tmpdir/direct_client.exe tmpdir/direct_client.o tmpdir/direct_dll.sl
> tmpdir/direct_dll.sl: In function `atexit':
> C:/develop/cvs/winsup/src/winsup/mingw/dllcrt1.c:161: multiple
> definition of `atexit'
> c:/mingw/bin/../lib/gcc/i686-pc-mingw32dw2/4.2.0/../../../crt2.o:C:\deve
> lop\cvs\winsup\src\winsup\mingw/crt1.c:272: first defined here
> tmpdir/direct_dll.sl: In function `onexit':
> C:/develop/cvs/winsup/src/winsup/mingw/dllcrt1.c:177: multiple
> definition of `_onexit'
> c:/mingw/bin/../lib/gcc/i686-pc-mingw32dw2/4.2.0/../../../crt2.o:C:\deve
> lop\cvs\winsup\src\winsup\mingw/crt1.c:280: first defined here
> tmpdir/direct_dll.sl: In function `onexit':
> tmpdir/direct_client.o:direct_client.c:(.text+0x18): undefined reference
> to `_imp__dll_func'
> collect2: ld returned 1 exit status
> FAIL: linking client (.sl)>
> 

This is exactly what happens when linking with the unpatched ld.
Don't you have an ld.exe link/copy to ../../ld-new.exe in /develop/cvs/binutils/build/ld/tmpdir/ld/ ?
If there isn't one, then the one in the system will be picked up.
Maybe I missed something in direct.exp?
This is surelly a test bug, since my manual testing was successful
once I copied ld-new.exe to tmpdir/ld/ld.exe.

What does adding -Wl,-v show?
gcc -v -B/d/cegccsf/cegcc/cegcc/src/build-binutils_cvs_mingw/ld/tmpdir/ld/ \
    -o tmpdir/direct_client_dll.exe tmpdir/direct_client.o \
    tmpdir/direct_dll.sl -Wl,-v

It should show the something like:
GNU ld version 2.17.50 20061215

I will google a bit to see how to install/run dejagnu on msys/MinGW.  If you have any
hints, they would be appreciated.

Attached is an updated/cleanup patch.  Same functionality, just moved the dll detection
into pe-dll.c, and updated direct.exp to link both exes with different names.

Cheers,
Pedro Alves

----
ld/

2006-12-16  Pedro Alves  <pedro_alves@portugalmail.pt>

      * pe-dll.c (pe_bfd_is_dll): New function.
      * pe-dll.h (pe_bfd_is_dll): Declare.
      * emultempl/pe.em (gld_${EMULATION_NAME}_recognized_file):
      Recognize dlls using pe_bfd_is_dll instead of the filename extension.

ld/testsuite/

2006-12-16  Pedro Alves  <pedro_alves@portugalmail.pt>

      * ld-pe/direct.exp: New file.
      * ld-pe/direct_client.c: Likewise.
      * ld-pe/direct_dll.c: Likewise.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: direct2.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20061216/546eba91/attachment.ksh>


More information about the Binutils mailing list