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.

llvm-svn: 308382
This commit is contained in:
Rafael Espindola 2017-07-18 21:46:27 +00:00
parent 4158131512
commit afbb7be6d5
2 changed files with 8 additions and 1 deletions

View File

@ -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>();

View File

@ -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