I suspect this comes down to how your linking module A. If you directly
pointing MCJIT at the object file, the common declaration is fine. If
not, you probably need to mark this as an explicit symbol.
According to the LangRef, a common symbol is not necessarily exported
from the link step. As a result, if you're building a shared library,
the symbol won't be exported.
Philip
On 07/10/2014 02:16 AM, Juan Manuel Martinez Caamaño
wrote:> Hello,
> I'm having a problem while accessing a global variable from a Module
> compiled by the MCJIT.
>
> For context, I have two modules (namely A and B). /Module A/ is
> compiled by clang, while /Module B /is compiled by the MCJIT.
>
> In /Module A/ I defined a global variable like this:
> /@A = common global [800 x [800 x double]] zeroinitializer, align 16/
>
> /Module B/, references that global like this:
> /@A = external global [800 x [800 x double]]/
>
> The problem that I have is that the MCJIT is not able to solve the
> symbol for @A. I get the following error:
>
> /LLVM ERROR: Program used external function 'A' which could not be
> resolved!/
>
> As far as I know, the MCJIT by default uses dlsym to solve the
> symbols. I tried to get the address for /@A/ using dlsym, but i get NULL.
>
> After compiling /Module A/, I used llvm-nm to check the symbol table:
>
> *0000000000608540 B A*
> 0000000000aea540 B B
> 0000000000fcc540 B C
> 00000000006081c8 d _DYNAMIC
> 0000000000608480 d _GLOBAL_OFFSET_TABLE_
> 0000000000402460 R _IO_stdin_used
> ....
>
> Any clues?
>
> Thank you,
> --
> Juan Manuel Martinez Caamaño, MSc.
> PhD. Student, IRMA - Université de Strasbourg
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140710/91f99203/attachment.html>