Gaier, Bjoern via llvm-dev
2018-Aug-06 11:20 UTC
[llvm-dev] JIT client - late cross references
Hello everyone, I'm still a beginner with the LLVM and the process of jitting a BC file at runtime as a JIT client - but I'm really interested into this subject. In my current use case I have two BC files which have cross references to each other, normally I could just add them both to the llvm::ExecutionEngine and they will be resolved. But I would like to resolve these cross references by myself, through the llvm::JITSymbolResolver but I see no way for this, since both files references each other. If I jit A, it will reach the undefined function from file B. So at this point I would have to jit B, but B references a function from A, which isn't completely resolved yet. Is there a way to get the addresses of the functions before the jit process is completed? Maybe via the section addresses and some kind of offset or so? Thank you for any response! Kind greetings Björn -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180806/eb9808a9/attachment.html>
David Blaikie via llvm-dev
2018-Aug-13 15:44 UTC
[llvm-dev] JIT client - late cross references
+Lang On Mon, Aug 6, 2018 at 4:20 AM Gaier, Bjoern via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello everyone, > > > > I'm still a beginner with the LLVM and the process of jitting a BC file at > runtime as a JIT client - but I'm really interested into this subject. > > > > In my current use case I have two BC files which have cross references to > each other, normally I could just add them both to the > llvm::ExecutionEngine and they will be resolved. > > But I would like to resolve these cross references by myself, through the > llvm::JITSymbolResolver but I see no way for this, since both files > references each other. > > > > If I jit A, it will reach the undefined function from file B. So at this > point I would have to jit B, but B references a function from A, which > isn't completely resolved yet. > > Is there a way to get the addresses of the functions before the jit > process is completed? Maybe via the section addresses and some kind of > offset or so? > > > > Thank you for any response! > > > > Kind greetings > > Björn > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180813/edd4a331/attachment.html>
Gaier, Bjoern via llvm-dev
2018-Aug-21 05:29 UTC
[llvm-dev] JIT client - late cross references
Still no answer to this? Besides from adding Lang? Was I at least able to explain good enough what my problem is? From: David Blaikie <dblaikie at gmail.com> Sent: Montag, 13. August 2018 17:45 To: Gaier, Bjoern <Bjoern.Gaier at horiba.com>; Lang Hames <lhames at gmail.com> Cc: llvm-dev <llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] JIT client - late cross references +Lang On Mon, Aug 6, 2018 at 4:20 AM Gaier, Bjoern via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hello everyone, I'm still a beginner with the LLVM and the process of jitting a BC file at runtime as a JIT client - but I'm really interested into this subject. In my current use case I have two BC files which have cross references to each other, normally I could just add them both to the llvm::ExecutionEngine and they will be resolved. But I would like to resolve these cross references by myself, through the llvm::JITSymbolResolver but I see no way for this, since both files references each other. If I jit A, it will reach the undefined function from file B. So at this point I would have to jit B, but B references a function from A, which isn't completely resolved yet. Is there a way to get the addresses of the functions before the jit process is completed? Maybe via the section addresses and some kind of offset or so? Thank you for any response! Kind greetings Björn _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180821/eefdebbc/attachment.html>
Lang Hames via llvm-dev
2018-Aug-21 15:49 UTC
[llvm-dev] JIT client - late cross references
Hi Bjoern, I do not think there is any practical way to do this yourself, short of writing your own RuntimeDyld implementation. The reason is that you cannot resolve a symbol to an address until you have compiled it down to an object file, but in the case of circular reference you would need to compile both IR Modules to object files before either could be patched up, and by that stage it is too late to patch either up at the IR level. What is the use case for trying to resolve these references yourself, rather than letting RuntimeDyld do it for you? Cheers, Lang. On Mon, Aug 6, 2018 at 4:20 AM Gaier, Bjoern via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello everyone, > > > > I'm still a beginner with the LLVM and the process of jitting a BC file at > runtime as a JIT client - but I'm really interested into this subject. > > > > In my current use case I have two BC files which have cross references to > each other, normally I could just add them both to the > llvm::ExecutionEngine and they will be resolved. > > But I would like to resolve these cross references by myself, through the > llvm::JITSymbolResolver but I see no way for this, since both files > references each other. > > > > If I jit A, it will reach the undefined function from file B. So at this > point I would have to jit B, but B references a function from A, which > isn't completely resolved yet. > > Is there a way to get the addresses of the functions before the jit > process is completed? Maybe via the section addresses and some kind of > offset or so? > > > > Thank you for any response! > > > > Kind greetings > > Björn > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180821/d0bc1468/attachment.html>
Gaier, Bjoern via llvm-dev
2018-Aug-29 05:38 UTC
[llvm-dev] JIT client - late cross references
Hello Lang, thank you for your response! So the use case would be some kind of wrapping or just taking control. Taking that Module 'A' has function a() and Module 'B' has function b() and c() - also a() calls b(). The normal resolving process would resolve the function call correct. But for some reason (like having a wrapper) I would prefer to resolve calls to b() with a call to c(), but only for module 'A'. For my own hobby-project I tried working with custom section names. When I came to allocating the memory for these sections I just kept the address and used it. Would this be suitable way too? That I allocate 'points of interest' in their own sections and keep the address? Or could it happen that these sections merge into one? Would this have negative consequences? Like using more memory or so? Kind greetings Björn From: Lang Hames <lhames at gmail.com> Sent: Dienstag, 21. August 2018 17:49 To: Gaier, Bjoern <Bjoern.Gaier at horiba.com> Cc: LLVM Developers Mailing List <llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] JIT client - late cross references Hi Bjoern, I do not think there is any practical way to do this yourself, short of writing your own RuntimeDyld implementation. The reason is that you cannot resolve a symbol to an address until you have compiled it down to an object file, but in the case of circular reference you would need to compile both IR Modules to object files before either could be patched up, and by that stage it is too late to patch either up at the IR level. What is the use case for trying to resolve these references yourself, rather than letting RuntimeDyld do it for you? Cheers, Lang. On Mon, Aug 6, 2018 at 4:20 AM Gaier, Bjoern via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hello everyone, I'm still a beginner with the LLVM and the process of jitting a BC file at runtime as a JIT client - but I'm really interested into this subject. In my current use case I have two BC files which have cross references to each other, normally I could just add them both to the llvm::ExecutionEngine and they will be resolved. But I would like to resolve these cross references by myself, through the llvm::JITSymbolResolver but I see no way for this, since both files references each other. If I jit A, it will reach the undefined function from file B. So at this point I would have to jit B, but B references a function from A, which isn't completely resolved yet. Is there a way to get the addresses of the functions before the jit process is completed? Maybe via the section addresses and some kind of offset or so? Thank you for any response! Kind greetings Björn _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180829/0cd1dd61/attachment.html>