Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Improper Name Mangling for Windows Kernel APIs #19107

Closed Quuxplusone closed 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR19108
Status RESOLVED INVALID
Importance P normal
Reported by JB Feldman (jb.feldman@kyrus-tech.com)
Reported on 2014-03-11 16:45:48 -0700
Last modified on 2014-03-26 10:31:35 -0700
Version unspecified
Hardware PC Windows 2000
CC anton@korobeynikov.info, llvm-bugs@lists.llvm.org, rnk@google.com
Fixed by commit(s)
Attachments msvc-preprocessor.c (357821 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 12212
Preprocessor output of CL.exe

Clang is emitting incorrect name manglings which result in failed linking.

For example: clang emits __imp__KeInitializeEvent, while cl emits
__imp__KeInitializeEvent@12

Similar issues exist for
KeWaitForSingleObject
IoDetachDevice
IoDeleteDevice
PoStartNextPowerIrp
PoCallDriver
IoCreateDevice
IoAttachDeviceToDeviceStack
KeSetEvent

Attached is the source code, as preprocessed by cl.exe
Quuxplusone commented 10 years ago

Attached msvc-preprocessor.c (357821 bytes, text/plain): Preprocessor output of CL.exe

Quuxplusone commented 10 years ago
After further discussion on IRC. We realized that by specifying:
clang-cl -Xclang -mrtd -c msvc-preprocessor.c

The output does properly link. This specifies the default calling convention as
stdcall instead of cdecl.
Quuxplusone commented 10 years ago

clang performs correct here. The switch to stdcall calling convention is performed via the command line.

Quuxplusone commented 10 years ago

I know nothing about building Windows drivers, but probably we should add support to clang-cl for the flag equivalent to -mrtd.