diff options
| -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. |

