[lld] r308382 - Fix a crash.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 14:46:27 PDT 2017


Author: rafael
Date: Tue Jul 18 14:46:27 2017
New Revision: 308382

URL: http://llvm.org/viewvc/llvm-project?rev=308382&view=rev
Log:
Fix a crash.

This is PR33821.

What we really want to check in here is if the output section was
created, not if the command was empty.

Added:
    lld/trunk/test/ELF/linkerscript/exidx-crash.s
Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=308382&r1=308381&r2=308382&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Jul 18 14:46:27 2017
@@ -1330,7 +1330,7 @@ template <class ELFT> void Writer<ELFT>:
   // ARM ABI requires .ARM.exidx to be terminated by some piece of data.
   // We have the terminater synthetic section class. Add that at the end.
   OutputSectionCommand *Cmd = findSectionCommand(".ARM.exidx");
-  if (!Cmd || Cmd->Commands.empty() || Config->Relocatable)
+  if (!Cmd || !Cmd->Sec || Config->Relocatable)
     return;
 
   auto *Sentinel = make<ARMExidxSentinelSection>();

Added: lld/trunk/test/ELF/linkerscript/exidx-crash.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/exidx-crash.s?rev=308382&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/exidx-crash.s (added)
+++ lld/trunk/test/ELF/linkerscript/exidx-crash.s Tue Jul 18 14:46:27 2017
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+
+# We used to crash on this.
+
+# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=aarch64-pc-linux
+# RUN: echo "SECTIONS { .ARM.exidx : { *(.foo) } }" > %t.script
+# RUN: ld.lld -T %t.script %t.o -o %t




More information about the llvm-commits mailing list