Issue Details (XML | Word | Printable)

Key: PCC-26
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Gregory McGarry
Reporter: Gregory McGarry
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

win32 __dllimport not correct

Created: 31/Jan/09 06:56 AM   Updated: 01/Apr/09 09:09 AM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Environment: win32


 Description  « Hide
Looks like __dllimport isn't working correctly.

Although the symbol is correctly prefixed with __imp_, the symbol should become an indirect reference through the import table. Therefore, a UMUL node needs to be inserted into the tree.

It's not clear whether all __dllimport symbols need the UMUL node, since it seems that some programs run and work fine.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Gregory McGarry added a comment - 11/Mar/09 02:26 AM
The symbols that are okay, are stdcall, not imported. So the problem affects all imported symbols.

The stack is also being unwound in the caller, rather than letting the callee do it. __dllimport implies __stdcall. pcc probably isn't doing this.


Gregory McGarry added a comment - 11/Mar/09 02:53 AM
Here's a concise explanation of how dllimport works:

__declspec(dllimport) hints the C compiler backend that the function resides in an external DLL. The compiler can decorate the function, lookup the export table and invoke the function in the DLL.

If __dclspec(dllimport) is omitted , then stubs are linked into the application from the import library. These stubs lookup the function in the export table and invoke the function in the DLL.


Gregory McGarry added a comment - 11/Mar/09 02:54 AM
So it's probably not strictly necessary to support dllimport yet.


Gregory McGarry added a comment - 01/Apr/09 09:09 AM
Fixed.