[PATCH] D42471: [ARM] Fix lld crash introduced by r321154
vit9696 via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 09:30:57 PST 2018
vit9696 updated this revision to Diff 131295.
vit9696 added a comment.
Updated with suggested test extension by Peter Smith.
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,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.
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.131295.patch
Type: text/x-patch
Size: 1679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180124/458e34f2/attachment.bin>
More information about the llvm-commits
mailing list