[PATCH] D42471: [ARM] Fix lld crash introduced by r321154

vit9696 via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 08:40:04 PST 2018


vit9696 updated this revision to Diff 131280.
vit9696 added a comment.
Herald added a subscriber: javed.absar.

Added a test case and restyled the check like Igor suggested.


https://reviews.llvm.org/D42471

Files:
  ELF/SyntheticSections.cpp
  ELF/Writer.cpp
  test/ELF/arm-exidx-discard.s


Index: test/ELF/arm-exidx-discard.s
===================================================================
--- test/ELF/arm-exidx-discard.s
+++ test/ELF/arm-exidx-discard.s
@@ -0,0 +1,8 @@
+// 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
+// REQUIRES: arm
+
+.globl  __entrypoint
+__entrypoint:
+    bx  lr
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1309,7 +1309,7 @@
     if (!SS)
       return;
     OutputSection *OS = SS->getParent();
-    if (!SS->empty() || !OS)
+    if (!OS || !SS->empty())
       continue;
 
     std::vector<BaseCommand *>::iterator Empty = OS->SectionCommands.end();
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -2586,6 +2586,8 @@
 // The sentinel has to be removed if there are no other .ARM.exidx entries.
 bool ARMExidxSentinelSection::empty() const {
   OutputSection *OS = getParent();
+  if (!OS)
+    return true;
   for (auto *B : OS->SectionCommands)
     if (auto *ISD = dyn_cast<InputSectionDescription>(B))
       for (auto *S : ISD->Sections)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42471.131280.patch
Type: text/x-patch
Size: 1462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180124/927b8f3c/attachment-0001.bin>


More information about the llvm-commits mailing list