<div dir="ltr">Hi Bjoern,<div><br></div><div>The general answer is to scan the interface of whatever program representation you are adding to the JIT. In the object file case you would create an llvm::object::ObjectFile and then iterate over its symbols. As you noticed you have to be careful with linkage (e.g. private and available-externally definitions aren't really part of the interface) and you have to be aware that the compilation of higher level program representations can cause new definitions to be created (e.g. for constant pool entries).</div><div><br></div><div>What are you planning to do with the symbols once you have them? If you are going to issue a lookup you will have to be careful with the lookup and visibility flags. A lookup using JITDylibLookupFlags::MatchExportedSymbolsOnly will fail if you look up a hidden (i.e. non-exported) symbol. You can either not look up hidden symbols, or you can use JITDylibLookupFlags::MatchAllSymbols.</div><div><br></div><div>Regards,</div><div>Lang.</div><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 22, 2020 at 4:51 AM Gaier, Bjoern <<a href="mailto:Bjoern.Gaier@horiba.com">Bjoern.Gaier@horiba.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">





<div lang="DE">
<div class="gmail-m_-617621764734249062WordSection1">
<p class="MsoNormal"><span lang="EN-GB">Hello LLVM-Mailing-List and hello Lang (I figured somebody would add you….so I did it directly. Sorry),<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">I'm still playing around with the ORC JIT version which is available in LLVM 10. My goal is to get the address of every defined symbol in a module and an object file before the code is emitted. With the help of Lang I
 do this now with the lookup function of the Execution Session. Thank you for this!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">However, my next issue is: How can I find every defined symbol in my object files? Currently I attached a callback function with the "setNotifyLoaded" function of "RTDyldObjectLinkingLayer". Which is really handy, because
 I can simply iterate over the symbols of the object files.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">However this only works when I already know what is inside my object files, which kinda kills the purpose.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">For a workaround I iterate through all the global symbols and functions of the IR module I'm loading, skipping symbols that are not defined in the module. However, I noticed when I do a lookup on those symbols, I will
 get some "additional" symbols from the notify loaded callback function having addresses I will miss then. Also this does not help me when I'm loading an object file from disk cause I don't have such a function there.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Okay... explaining stuff is not my best practise so.... Here a tl;dr:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">How can I get all symbols from an object file when it is loaded/added to ORC JIT?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Sorry that I still have questions >o<<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Kind greetings<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Björn<u></u><u></u></span></p>
</div>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
</div>

</blockquote></div>