[lld] r270563 - Fix crash in .eh_frame marker section.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 07:52:00 PDT 2016


Author: rafael
Date: Tue May 24 09:51:50 2016
New Revision: 270563

URL: http://llvm.org/viewvc/llvm-project?rev=270563&view=rev
Log:
Fix crash in .eh_frame marker section.

Added:
    lld/trunk/test/ELF/eh-frame-marker.s
Modified:
    lld/trunk/ELF/InputSection.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=270563&r1=270562&r2=270563&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue May 24 09:51:50 2016
@@ -414,10 +414,10 @@ void EhInputSection<ELFT>::split() {
   ArrayRef<uint8_t> Data = this->getSectionData();
   for (size_t Off = 0, End = Data.size(); Off != End;) {
     size_t Size = readEhRecordSize<ELFT>(Data.slice(Off));
+    this->Pieces.emplace_back(Off, Data.slice(Off, Size));
     // The empty record is the end marker.
     if (Size == 4)
       break;
-    this->Pieces.emplace_back(Off, Data.slice(Off, Size));
     Off += Size;
   }
 }

Added: lld/trunk/test/ELF/eh-frame-marker.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/eh-frame-marker.s?rev=270563&view=auto
==============================================================================
--- lld/trunk/test/ELF/eh-frame-marker.s (added)
+++ lld/trunk/test/ELF/eh-frame-marker.s Tue May 24 09:51:50 2016
@@ -0,0 +1,6 @@
+// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
+// RUN: ld.lld %t.o -o %t.so -shared
+// We used to crash on this.
+        .section .eh_frame
+foo:
+        .long 0




More information about the llvm-commits mailing list