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.
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?
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.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.
Ok, I'll send an email, I don't understand how it can be correct though, it's only done on
x86
and only onx86
do you now have an explicit hard requirement to linkmingwex
beforentdll
for any math functions...Others might provide an answer for it: JonY? Kai?
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.
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.