From: Rui Ueyama Date: Thu, 6 Aug 2015 03:45:27 +0000 (+0000) Subject: COFF: ARM: Sort .pdata section correctly. X-Git-Tag: studio-1.4~721 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b000812a44316016abe214ae98212b3cdd079fc;p=platform%2Fupstream%2Fllvm.git COFF: ARM: Sort .pdata section correctly. On ARM, exception handler entries in .pdata section are 8 byte long. llvm-svn: 244191 --- diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index f08d948..c698aec 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -724,14 +724,25 @@ void Writer::writeSections() { // Sort .pdata section contents according to PE/COFF spec 5.5. void Writer::sortExceptionTable() { - if (auto *Sec = findSection(".pdata")) { - // We assume .pdata contains function table entries only. + OutputSection *Sec = findSection(".pdata"); + if (!Sec) + return; + // We assume .pdata contains function table entries only. + uint8_t *Begin = Buffer->getBufferStart() + Sec->getFileOff(); + uint8_t *End = Begin + Sec->getVirtualSize(); + if (Config->Machine == AMD64) { struct Entry { ulittle32_t Begin, End, Unwind; }; - uint8_t *Buf = Buffer->getBufferStart() + Sec->getFileOff(); - std::sort(reinterpret_cast(Buf), - reinterpret_cast(Buf + Sec->getVirtualSize()), + std::sort((Entry *)Begin, (Entry *)End, [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; }); + return; + } + if (Config->Machine == ARMNT) { + struct Entry { ulittle32_t Begin, Unwind; }; + std::sort((Entry *)Begin, (Entry *)End, + [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; }); + return; } + errs() << "warning: don't know how to handle .pdata.\n"; } OutputSection *Writer::findSection(StringRef Name) {