[lld] r244191 - COFF: ARM: Sort .pdata section correctly.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 22:35:04 PDT 2015
We may want to define these structs in libSupport (although in the linker
we are only interested in struct size and the first field value.) I'll take
a look at that tomorrow.
On Wed, Aug 5, 2015 at 10:26 PM, Saleem Abdulrasool <compnerd at compnerd.org>
wrote:
>
>
> On Wed, Aug 5, 2015 at 8:45 PM, Rui Ueyama <ruiu at google.com> wrote:
>
>> Author: ruiu
>> Date: Wed Aug 5 22:45:27 2015
>> New Revision: 244191
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=244191&view=rev
>> Log:
>> COFF: ARM: Sort .pdata section correctly.
>>
>> On ARM, exception handler entries in .pdata section are 8 byte long.
>>
>> Modified:
>> lld/trunk/COFF/Writer.cpp
>>
>> Modified: lld/trunk/COFF/Writer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=244191&r1=244190&r2=244191&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/COFF/Writer.cpp (original)
>> +++ lld/trunk/COFF/Writer.cpp Wed Aug 5 22:45:27 2015
>> @@ -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<Entry *>(Buf),
>> - reinterpret_cast<Entry *>(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; };
>>
>
> Do we really want to recreate the data structures for the pdata here? Is
> a dependency on LLVMSupport something you are trying to avoid?
>
>
>> + 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) {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150805/baed1897/attachment.html>
More information about the llvm-commits
mailing list