<div dir="rtl"><div dir="ltr">There is an additional detail to .eh_frame registration you may wish to consider while preparing  the multi-module patch.</div><div dir="ltr"><br></div><div dir="ltr">With executable files, the linker combines .eh frames with four zero bytes from crtend to marking .eh_frame section end. See   <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-April/061768.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-April/061768.html</a></div>

<div dir="ltr">As <span style="color:rgb(0,0,0);white-space:pre-wrap">Rafael writes, this can't be done in codegen since it's a linker function done when all .eh_frames are combined.</span></div><div dir="ltr"><br>

</div><div dir="ltr">The dynamic linker must perform the same function, else __register_frame(eh_frame) might continue processing after .eh_frame, depending if there were four zero bytes - or not - by chance.</div><div dir="ltr">

<br></div><div dir="ltr">Possibly RuntimeDyldELF::registerEHFrames() will allocate a new buffer for the .eh_frame, four bytes larger set to zeros, and send this to MemMgr. Then decide who and when will free this allocation, while considering module unloading too.</div>

<div dir="ltr"><br></div><div dir="ltr">Yaron</div><div dir="ltr"><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div dir="ltr">2013/10/9 Kaylor, Andrew <span dir="ltr"><<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>></span></div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Yaron,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I’m in the process of updating the EH frame support in MCJIT and RuntimeDyld to handle registration of multiple generated or loaded objects.  These changes
 involve an update to the memory manager and RuntimeDyld interfaces for registering EH frame data.  They will also highlight complications which would need to be considered in your patch with regard to deregistration of frame data.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In addition, I would prefer to have a separate “deregister” function rather than overloading the behavior of the registerFrames function.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I’m attaching my current patch so you can see where this is going.  Also feel free to provide feedback on the patch.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Please wait for my multiple object patch to be committed.  After that we can discuss the details of how deregistration should work.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Andy<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Yaron Keren<br>
<b>Sent:</b> Wednesday, October 09, 2013 10:22 AM<br>
<b>To:</b> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> [PATCH]Unload EH frames in ~MCJIT<u></u><u></u></span></p><div class="im">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Module loaded with MCJIT register its EH frames with __register_frame to the runtime library. After MCJIT destructs and the module unloaded,  the runtime stays with invalid frames of the module, leading to faulty EH behaviour next time.<u></u><u></u></p>


</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">This patch calls __deregister_frame upon MCJIT destruction to keep proper runtime library EH state.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Yaron<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div>
</div>

</blockquote></div><br></div>