diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-24 19:16:31 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-24 19:16:31 +0000 |
| commit | a9263c8963a94334fe9951147485b1e77892d0d1 (patch) | |
| tree | 053f03d697836cc417bb1379e1e5fe582e9fc542 | |
| parent | 349fe0aa87a4b4705101943aba743438efa94ec7 (diff) | |
| download | bcm5719-llvm-a9263c8963a94334fe9951147485b1e77892d0d1.tar.gz bcm5719-llvm-a9263c8963a94334fe9951147485b1e77892d0d1.zip | |
Fix lld crash introduced by r321154.
Since SyntheticSection::getParent() may return null, dereferencing
this pointer in ARMExidxSentinelSection::empty() call from
removeUnusedSyntheticSections() results in crashes when linking ARM
binaries.
Patch by vit9696!
llvm-svn: 323366
| -rw-r--r-- | lld/ELF/Writer.cpp | 2 | ||||
| -rw-r--r-- | lld/test/ELF/arm-exidx-discard.s | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index da2119e4f3a..1f93a4e54f9 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1309,7 +1309,7 @@ static void removeUnusedSyntheticSections() { if (!SS) return; OutputSection *OS = SS->getParent(); - if (!SS->empty() || !OS) + if (!OS || !SS->empty()) continue; std::vector<BaseCommand *>::iterator Empty = OS->SectionCommands.end(); diff --git a/lld/test/ELF/arm-exidx-discard.s b/lld/test/ELF/arm-exidx-discard.s new file mode 100644 index 00000000000..8c536831ac0 --- /dev/null +++ b/lld/test/ELF/arm-exidx-discard.s @@ -0,0 +1,14 @@ +// RUN: llvm-mc -filetype=obj -triple arm-gnu-linux-eabi -mcpu cortex-a7 -arm-add-build-attributes %s -o %t.o +// RUN: echo "ENTRY(__entrypoint) SECTIONS { . = 0x10000; .text : { *(.text .text.*) } /DISCARD/ : { *(.ARM.exidx*) *(.gnu.linkonce.armexidx.*) } }" > %t.script +// RUN: ld.lld -T %t.script %t.o -o %t.elf 2>&1 +// RUN: llvm-readobj -sections %t.elf | FileCheck %s +// REQUIRES: arm + +.globl __entrypoint +__entrypoint: + bx lr + +// Check that .ARM.exidx/.gnu.linkonce.armexidx +// are correctly removed if they were added. +// CHECK-NOT: .ARM.exidx +// CHECK-NOT: .gnu.linkonce.armexidx. |

