Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1131 LD generates a non syntax valid definition file

closed-fixed
Danny Smith
binutils (105)
2008-07-09
2008-02-24
jkarretero
No

Option --output-def of LD generates a non syntax valid definition file.

Using:
Windows XP SP2
mingw-runtime-3.14
binutils-2.18.50-20080109
gcc-core-3.4.5-20060117-1
w32api-3.11

Steps to reproduce the bug:

We want to generate a dll with functions in function.c, and export its definition file.

1. Compile function.c. This function uses WlanReasonCodeToString in wlanapi.dll.
gcc -c -Wall function.c -o function.o

2. Generate the dll and its definition file (if you don't have
wlanapi.dll, you can use one of the wlanapi folder)
ld -L./ -shared -o library.dll --output-def bad_syntax.def function.o -lwlanapi

The generated DEF file may be used as a reference to automatically or
implicitly exported symbols.
In step 3 we are going to use the DEF file in this mentioned way. So
we could check its syntax.

3. Create the dll using DEF file to indicate what symbols will be exported.
ld -L./ -shared -o library.dll bad_syntax.def function.o -lwlanapi

Ld gives the following error in step 3:

ld: bad_syntax.def:2: syntax error
ld:bad_syntax.def: file format not recognized; treating as linker script
ld:bad_syntax.def:2: syntax error

As we can see, --output-def of LD has generated a non syntax valid definition file.

Discussion

  • jkarretero
    jkarretero
    2008-02-24

    Sources to reproduce the bug

     
    Attachments
  • Danny Smith
    Danny Smith
    2008-06-16

    • labels: --> binutils
    • assigned_to: nobody --> dannysmith
     
  • Danny Smith
    Danny Smith
    2008-06-16

    Logged In: YES
    user_id=11494
    Originator: NO

    Hi,
    I see the problem. GNU ld does not treat the ILF (short format) MS import lib wlanapi.lib as an archive, as it does for the long format import libs that mingw and cygwin use.

    If you create an import lib for wlanapi.dll using dlltool, and use that implib, it will create a good def file and dll.

    I will investigate further.

     
  • Danny Smith
    Danny Smith
    2008-07-09

    Logged In: YES
    user_id=11494
    Originator: NO

    Fixed in binutils CVS
    Danny

     
  • Danny Smith
    Danny Smith
    2008-07-09

    • status: open --> closed-fixed