diff options
-rw-r--r-- | lld/ELF/Writer.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/linkerscript/exidx-crash.s | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 680ba93452a..1853f99bc60 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1330,7 +1330,7 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSections() { // 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>(); diff --git a/lld/test/ELF/linkerscript/exidx-crash.s b/lld/test/ELF/linkerscript/exidx-crash.s new file mode 100644 index 00000000000..dfaed7a3894 --- /dev/null +++ b/lld/test/ELF/linkerscript/exidx-crash.s @@ -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 |