[PATCH] D13050: [ELF2] Fix an assertion failure on 32-bit platform

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 03:57:33 PDT 2015


ikudrin created this revision.
ikudrin added a reviewer: rafael.
ikudrin added a subscriber: llvm-commits.
ikudrin added a project: lld.

As GOT section has lower address than PLT section, the Delta value is negative and should be calculated and stored in the signed variable.

http://reviews.llvm.org/D13050

Files:
  lld/trunk/ELF/OutputSections.cpp

Index: lld/trunk/ELF/OutputSections.cpp
===================================================================
--- lld/trunk/ELF/OutputSections.cpp
+++ lld/trunk/ELF/OutputSections.cpp
@@ -48,7 +48,8 @@
     Buf += Jmp.size();
 
     uintptr_t OffsetInPLT = (InstPos + 6) - Start;
-    uintptr_t Delta = GotSec.getEntryAddr(*E) - (this->getVA() + OffsetInPLT);
+    intptr_t Delta = static_cast<intptr_t>(GotSec.getEntryAddr(*E)) -
+                     static_cast<intptr_t>(this->getVA() + OffsetInPLT);
     assert(isInt<32>(Delta));
     support::endian::write32le(Buf, Delta);
     Buf += 4;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13050.35355.patch
Type: text/x-patch
Size: 594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150922/59f2c5e0/attachment.bin>


More information about the llvm-commits mailing list