#755 Recent versions of ld.exe produce invalid libgmp-3.dll

OTHER
closed
Danny Smith
binutils (105)
works-for-me
No_User_Response
2013-01-31
2005-04-05
Richard Browne
No

Recent versions of MinGW ld.exe seem to produce
invalid PE DLLs when compiling GNU GMP.

Steps to reproduce:

- Get any recent version of MingMW (2003 or later)
- Download & extract GNU GMP 4.1.4 tarball
- ./configure --disable-static --enable-shared
- make

The resulting libgmp-3.dll seems to be an invalid WIN32
PE file. Attempts to link an app with this DLL cause the
process to fail to load. Attempting LoadLibrary() causes
an access violation (possibly in the MinGW crt startup
code - unsure).

A workaround is to use ld.exe from an old MinGW. The
ld.exe from binutils-2.13.90-20021006-2.tar.gz works
great & produces a usable DLL. The ld.exe from binutils-
2.13.90-20030111-1.tar.gz does NOT work nor do any
later versions.

Juro Bystricky discovered that the issue is something to
do with relocating the DLL to something other than its
preferred base address. More info here:

http://swox.com/list-archives/gmp-discuss/2004-
August/001290.html

Discussion

  • Danny Smith
    Danny Smith
    2005-04-06

    Logged In: YES
    user_id=11494

    What is the command line to build the dll?
    Danny

     
  • Richard Browne
    Richard Browne
    2005-04-06

    Logged In: YES
    user_id=828583

    It's a configure/libtool based build:

    $ ./configure --disable-static --enable-shared
    $ make

    Are you asking for just the ld command? It's libtool with
    default options as far as I know....

     
  • Danny Smith
    Danny Smith
    2005-04-07

    Logged In: YES
    user_id=11494

    I am asking for you to look at your libtool script and tell me
    what options are being passed to ld and (possibly) what
    happens to the dll after it is created (eg is the .reloc section
    stripped)

    It seems strange that other projects can produce relocatable
    dlls with new ld but gmp does not

    Danny

     
  • Danny Smith
    Danny Smith
    2005-08-10

    Logged In: YES
    user_id=11494

    No feedback in 4 months., It works for me, so closing.
    Danny

     
  • Danny Smith
    Danny Smith
    2005-08-10

    • status: open --> closed-works-for-me
     
  • Earnie Boyd
    Earnie Boyd
    2013-01-31

    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> No_User_Response
    • milestone: component_package --> OTHER