<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Stanislav, Lang<div class=""><br class=""></div><div class="">I have a version of objc metadata parser based on LLVM which can handle objc2 metadata from MachO object and bitcode (bitcode version is even swift compatible). I don't know if there is enough interest for me to upstream it. It probably requires some work to clean up the interface and complete it by adding objc1 support and other object format support.</div><div class=""><br class=""></div><div class="">Steven</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 18, 2016, at 2:10 PM, Lang Hames via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Stanislav,<div class=""><br class=""></div><div class="">I actually looked into this recently. It is possible, but takes some non-trivial effort right now: You have to hook into the JIT memory allocator, parse the objective C metadata sections in the object file, then call the objective C runtime to register any newly added classes, protocols and selectors.</div><div class=""><br class=""></div><div class="">I can't release my code as-is: I built it against a hacked up copy of the runtime. The right way to do this would be to write parsers for the objective C metadata, and an Objective-C registration call that uses the parsers and calls the runtime. These should be made available conditionally if the objective C runtime headers are available. This is something that I'd like to get to eventually, but I have a long to-do list. If you or anyone you know is interested in working on it I'd be happy to provide pointers and code review.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Lang.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Oct 18, 2016 at 1:33 PM, Stanislav Pankevich via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hello,<div class=""><br class=""></div><div class="">Is it possible to execute Objective-C code using LLVM JIT?</div><div class=""><br class=""></div><div class="">The original point for my research is this topic on StackOverflow: </div><div class=""><br class=""></div><div class="">All selectors unrecognised when invoking Objective-C methods using the LLVM ExecutionEngine <a href="http://stackoverflow.com/questions/10375324/all-selectors-unrecognised-when-invoking-objective-c-methods-using-the-llvm-exec" target="_blank" class="">http://<wbr class="">stackoverflow.com/questions/<wbr class="">10375324/all-selectors-<wbr class="">unrecognised-when-invoking-<wbr class="">objective-c-methods-using-the-<wbr class="">llvm-exec</a></div><div class=""><br class=""></div><div class="">Running that example with lli produces the following output:</div><div class=""><br class=""></div><div class=""><div class="">2016-10-18 21:25:58.332 lli[12970:169282] *** NSForwarding: warning: selector (0x10356a38f) for message 'alloc' does not match selector known to Objective C runtime (0x7fff8e93afb5)-- abort</div><div class="">2016-10-18 21:25:58.334 lli[12970:169282] +[NSAutoreleasePool alloc]: unrecognized selector sent to class 0x7fff7a562130</div><div class="">2016-10-18 21:25:58.338 lli[12970:169282] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSAutoreleasePool alloc]: unrecognized selector sent to class 0x7fff7a562130'</div></div><div class=""><br class=""></div><div class="">See also additional discussion here: <a href="https://twitter.com/sbpankevich/status/783363161537798144" target="_blank" class="">https://twitter.com/<wbr class="">sbpankevich/status/<wbr class="">783363161537798144</a>.</div><div class=""><br class=""></div><div class="">Thanks.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Stanislav Pankevich</div><div class=""><br class=""></div></font></span></div><br class="">______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>