aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@freebsd.org>2016-05-25 14:45:28 +0000
committerEd Maste <emaste@freebsd.org>2016-05-25 14:45:28 +0000
commitc0c60e9dd0de03d751ea148ce1ad5086b65b9709 (patch)
treecb3fd43a7e058b7f4f7735cdfbbaed89c4de136c
parenta677405263e268780d62570042a75a709eda1458 (diff)
ELF: Handle empty CIE augmentation string
"A zero length string indicates that no augmentation data is present." The FreeBSD/mips toolchain (GCC 4.2.1) generates .debug_frame sections containing CIE records that have an empty augmentation string. Differential Revision: http://reviews.llvm.org/D19928 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@270706 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--ELF/EhFrame.cpp2
-rw-r--r--test/ELF/Inputs/no-augmentation.obin0 -> 3640 bytes
-rw-r--r--test/ELF/no-augmentation.test10
3 files changed, 11 insertions, 1 deletions
diff --git a/ELF/EhFrame.cpp b/ELF/EhFrame.cpp
index 00a5faef5..b130ac1ca 100644
--- a/ELF/EhFrame.cpp
+++ b/ELF/EhFrame.cpp
@@ -111,7 +111,7 @@ template <class ELFT> uint8_t getFdeEncoding(ArrayRef<uint8_t> D) {
if (Version != 1 && Version != 3)
fatal("FDE version 1 or 3 expected, but got " + Twine((unsigned)Version));
- const unsigned char *AugEnd = std::find(D.begin() + 1, D.end(), '\0');
+ const unsigned char *AugEnd = std::find(D.begin(), D.end(), '\0');
if (AugEnd == D.end())
fatal("corrupted CIE");
StringRef Aug(reinterpret_cast<const char *>(D.begin()), AugEnd - D.begin());
diff --git a/test/ELF/Inputs/no-augmentation.o b/test/ELF/Inputs/no-augmentation.o
new file mode 100644
index 000000000..8b9ff5e59
--- /dev/null
+++ b/test/ELF/Inputs/no-augmentation.o
Binary files differ
diff --git a/test/ELF/no-augmentation.test b/test/ELF/no-augmentation.test
new file mode 100644
index 000000000..4a2604aae
--- /dev/null
+++ b/test/ELF/no-augmentation.test
@@ -0,0 +1,10 @@
+// RUN: llvm-mc -filetype=obj -triple=mips64-unknown-freebsd %s -o %t.o
+// RUN: ld.lld --eh-frame-hdr %t.o %p/Inputs/no-augmentation.o -o %t \
+// RUN: | FileCheck -allow-empty %s
+
+// REQUIRES: mips
+
+// CHECK-NOT: corrupted or unsupported CIE information
+
+.global __start
+__start: