<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 5, 2015 at 8:45 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Wed Aug 5 22:45:27 2015<br>
New Revision: 244191<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244191&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244191&view=rev</a><br>
Log:<br>
COFF: ARM: Sort .pdata section correctly.<br>
<br>
On ARM, exception handler entries in .pdata section are 8 byte long.<br>
<br>
Modified:<br>
lld/trunk/COFF/Writer.cpp<br>
<br>
Modified: lld/trunk/COFF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=244191&r1=244190&r2=244191&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=244191&r1=244190&r2=244191&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/COFF/Writer.cpp (original)<br>
+++ lld/trunk/COFF/Writer.cpp Wed Aug 5 22:45:27 2015<br>
@@ -724,14 +724,25 @@ void Writer::writeSections() {<br>
<br>
// Sort .pdata section contents according to PE/COFF spec 5.5.<br>
void Writer::sortExceptionTable() {<br>
- if (auto *Sec = findSection(".pdata")) {<br>
- // We assume .pdata contains function table entries only.<br>
+ OutputSection *Sec = findSection(".pdata");<br>
+ if (!Sec)<br>
+ return;<br>
+ // We assume .pdata contains function table entries only.<br>
+ uint8_t *Begin = Buffer->getBufferStart() + Sec->getFileOff();<br>
+ uint8_t *End = Begin + Sec->getVirtualSize();<br>
+ if (Config->Machine == AMD64) {<br>
struct Entry { ulittle32_t Begin, End, Unwind; };<br>
- uint8_t *Buf = Buffer->getBufferStart() + Sec->getFileOff();<br>
- std::sort(reinterpret_cast<Entry *>(Buf),<br>
- reinterpret_cast<Entry *>(Buf + Sec->getVirtualSize()),<br>
+ std::sort((Entry *)Begin, (Entry *)End,<br>
[](const Entry &A, const Entry &B) { return A.Begin < B.Begin; });<br>
+ return;<br>
}<br>
+ if (Config->Machine == ARMNT) {<br>
+ struct Entry { ulittle32_t Begin, Unwind; };<br></blockquote><div><br></div><div>Do we really want to recreate the data structures for the pdata here? Is a dependency on LLVMSupport something you are trying to avoid?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ std::sort((Entry *)Begin, (Entry *)End,<br>
+ [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; });<br>
+ return;<br>
+ }<br>
+ errs() << "warning: don't know how to handle .pdata.\n";<br>
}<br>
<br>
OutputSection *Writer::findSection(StringRef Name) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>