summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Smith <peter.smith@linaro.org>2017-04-13 08:52:58 +0000
committerPeter Smith <peter.smith@linaro.org>2017-04-13 08:52:58 +0000
commitcec1e260c30e16d3230cfc63105fef4015892ff4 (patch)
tree75fc25df72ea506a26adbbbb1c626d89ea97adb5
parent1c685cfe33af945b5b2bf745eee7c83655c8f3b2 (diff)
downloadbcm5719-llvm-cec1e260c30e16d3230cfc63105fef4015892ff4.tar.gz
bcm5719-llvm-cec1e260c30e16d3230cfc63105fef4015892ff4.zip
[ELF] Mark ARM Exceptions that refer to folded code as not live
ARM Exception Index Table sections .ARM.exidx have an implicit dependency on code sections via SHF_LINK_ORDER. When code sections are folded by ICF we must mark the unique .ARM.exidx table that describes it as not live to prevent an illegal entry in the exception table. Note that we do not try and follow the relocations from the .ARM.exidx section to the .ARM.extab sections to mark these as not live. Leaving these sections is not a correctness problem. In theory these could be removed via an application of garbage collection. Fixes https://bugs.llvm.org/show_bug.cgi?id=32614 Differential Revision: https://reviews.llvm.org/D31932 llvm-svn: 300182
-rw-r--r--lld/ELF/ICF.cpp9
-rw-r--r--lld/test/ELF/arm-icf-exidx.s31
2 files changed, 40 insertions, 0 deletions
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index a9de0fc71eb..dcf01ea8001 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -375,6 +375,15 @@ template <class ELFT> void ICF<ELFT>::run() {
Sections[Begin]->replace(Sections[I]);
}
});
+
+ // Mark ARM Exception Index table sections that refer to folded code
+ // sections as not live. These sections have an implict dependency
+ // via the link order dependency.
+ if (Config->EMachine == EM_ARM)
+ for (InputSectionBase *Sec : InputSections)
+ if (auto *S = dyn_cast<InputSection>(Sec))
+ if (S->Flags & SHF_LINK_ORDER)
+ S->Live = S->getLinkOrderDep()->Live;
}
// ICF entry point function.
diff --git a/lld/test/ELF/arm-icf-exidx.s b/lld/test/ELF/arm-icf-exidx.s
new file mode 100644
index 00000000000..cb801b7f242
--- /dev/null
+++ b/lld/test/ELF/arm-icf-exidx.s
@@ -0,0 +1,31 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t -o %t2 --icf=all
+// RUN: llvm-objdump -s -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
+
+ .syntax unified
+ .section .text.f,"axG",%progbits,f,comdat
+f:
+ .fnstart
+ bx lr
+ .fnend
+
+ .section .text.g,"axG",%progbits,g,comdat
+g:
+ .fnstart
+ bx lr
+ .fnend
+
+ .section .text.h
+ .global __aeabi_unwind_cpp_pr0
+__aeabi_unwind_cpp_pr0:
+ bx lr
+
+// CHECK: Disassembly of section .text:
+// CHECK-NEXT: f:
+// CHECK-NEXT: 11000: 1e ff 2f e1 bx lr
+// CHECK: __aeabi_unwind_cpp_pr0:
+// CHECK-NEXT: 11004: 1e ff 2f e1 bx lr
+
+// CHECK: Contents of section .ARM.exidx:
+// CHECK-NEXT: 100d4 2c0f0000 b0b0b080 280f0000 01000000
OpenPOWER on IntegriCloud