[cfe-dev] Calling a function from Visual Studio dll - name mangling issues

Daan Nijs nijs.daan at gmail.com
Sun Mar 20 16:06:40 PDT 2011


I'm trying to call a function in a dll compiled with Visual Studio from
JITed code. Unfortunately, the mangled name generated by the codegen does
not match the one that ends up being exported by the dll. LLVM generates a
*nix style mangled name() where it needs the windows mangled named.

my external header:

class __declspec(dllimport) mod_test
{
public:
    static void test();
};

my generated module after compiling:

; ModuleID = 'random'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i686-pc-win32"

define void @_Z5hellov() nounwind {
entry:
  call void @_ZN8mod_test4testEv()
  ret void
}

declare void @_ZN8mod_test4testEv()

...while the exported name is ?test at mod_test@SAXXZ. I use clang as a
library, without going through the Driver class. Since calls to the system
libraries work fine, I'm quite sure that I'm not trying to do something that
is not supported.

I would be grateful if anyone could shed some light on this.

-- 
Daan Nijs
http://www.bogartindustries.com/blog

BE: +32 494864702
DE +49 151 23308763
Skype : poptunes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110321/4daa4764/attachment.html>


More information about the cfe-dev mailing list