Menu

#596 gendef seems to generate incorrect DATA entries on x86

v1.0 (example)
closed-invalid
nobody
None
5
2017-03-20
2017-03-17
Phyx-
No

gendef on x86 seems to incorrectly tag certain functions as being constant data. For instance the undocumented atan in ntdll.dll.

The x86_64 version does correctly see it as a function.

I also don't quite get why the default for is_data seems to be true https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-tools/gendef/src/gendef.c#l368.

This is causing an annoying link interaction between libmingex and ntdll in which libmingwex always has to come before ntdll or a duplicate symbol error occurs.

Changing the default from 1 to 0 in gendef seems to fix the issue.

Discussion

  • Ozkan Sezer

    Ozkan Sezer - 2017-03-18

    Please clarify: what do you mean by 'gendef on x86'? I suppose that
    you run whatever gendef version on an x86 version of a dll, yes?

    I can't reproduce this. I ran gendef on x86 versions of ntdll.dll
    from winxp, win8.1, and win10 (the last two are x64 versions and I
    did take ntdll.dll from SysWOW64), atan is not reported as DATA for
    me. (My gendef is built from the latest code in git master branch.)
    Can you give precise instructions to reproduce?

     
  • Phyx-

    Phyx- - 2017-03-18

    Ugh, you're right, calling gendef directly produces the right results. I had thought the def files were being generated on the fly, but it turns out they're checked in. So it seems https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/lib32/ntdll.def was generated using an buggy version of gendef.

    Tamar@Kino MINGW64 /r/mingw-w64-mingw-w64
    $ find -iname ntdll.def | xargs grep atan
    ./mingw-w64-crt/lib32/ntdll.def:atan DATA
    ./mingw-w64-crt/lib64/ntdll.def:atan
    ./mingw-w64-crt/libarm32/ntdll.def:atan
    
     
  • Ozkan Sezer

    Ozkan Sezer - 2017-03-18
    • status: open --> closed-invalid
     
  • Ozkan Sezer

    Ozkan Sezer - 2017-03-18

    I believe the 'atan' entry in that ntdll.def is hand-edited to appear as DATA,
    because mingwex provides its own version of atan() and as I understand it
    that causes a linkage problem: It would be best to close this issue and
    open a new ticket (or better send a mail to the mingw-w64-public list first)
    describing the actual linkage issue.

    I am closing this particular ticket as invalid.

     
  • Phyx-

    Phyx- - 2017-03-18

    Ok, I'll send an email, I don't understand how it can be correct though, it's only done on x86 and only on x86 do you now have an explicit hard requirement to link mingwex before ntdll for any math functions...

     
  • Ozkan Sezer

    Ozkan Sezer - 2017-03-18

    Others might provide an answer for it: JonY? Kai?

     
  • Jonathan Yong

    Jonathan Yong - 2017-03-19

    I don't really have a good answer for this, since it really depends on which dll you are trying to import it from, and depending on your use case, you may prefer one of the other.

    The X64 version probably needs to match the 32bit version, but so far nobody has asked for it yet.

     
  • Kai Tietz

    Kai Tietz - 2017-03-20

    Gendef doesn't add here the entry to DATA. That was done manually, and by intention. There are some symbols in ntdll.dll (and other places MS decided to provide C-runtime like entries, too), which are colliding with our crt's math. So they are turn off to be callable directly. They are just reachable through their import stub, which is in common fine.
    There is no good reason for us to modifiy this, as we otherwise get a cane of worms.

     

Log in to post a comment.