summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Richardson <arichardson.kde@gmail.com>2017-10-05 23:28:34 +0000
committerAlexander Richardson <arichardson.kde@gmail.com>2017-10-05 23:28:34 +0000
commitb9aa9a55006add424a18dd19a518064994a4eed4 (patch)
tree3f3bdaf347933ec4e9fae89984c7b84b9e3eda0e
parent57f089775b23cabdbafd5a84eebd78d830bf8d9d (diff)
downloadbcm5719-llvm-b9aa9a55006add424a18dd19a518064994a4eed4.tar.gz
bcm5719-llvm-b9aa9a55006add424a18dd19a518064994a4eed4.zip
[ELF] Don't crash when parsing a file with out-of-bounds version references
Summary: We were crashing when linking telnetd in FreeBSD because lld was emitting corrupted output files for --norosegment. In this file the version index of some symbols was set to 9 but lld only found 8 version definitions. I am not sure how to create a minimal .so file that also exposes this behaviour so I just added the one that initially caused the error to Inputs/ This partially addresses https://bugs.llvm.org/show_bug.cgi?id=34705 Reviewers: ruiu, rafael, pcc, grimar Reviewed By: ruiu Subscribers: emaste, krytarowski Tags: #lld Differential Revision: https://reviews.llvm.org/D38397 llvm-svn: 315036
-rw-r--r--lld/ELF/InputFiles.cpp4
-rw-r--r--lld/test/ELF/corrupted-version-reference.s4
2 files changed, 3 insertions, 5 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index a0a38de0d8a..cf3672c60b9 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -780,9 +780,7 @@ template <class ELFT> void SharedFile<ELFT>::parseRest() {
if (VersymIndex >= Verdefs.size()) {
error("corrupt input file: version definition index " +
Twine(VersymIndex) + " for symbol " + Name +
- " is greater than the maximum value " +
- Twine(Verdefs.size() - 1) + "\n>>> symbol is defined in " +
- toString(this));
+ " is out of bounds\n>>> defined in " + toString(this));
continue;
}
V = Verdefs[VersymIndex];
diff --git a/lld/test/ELF/corrupted-version-reference.s b/lld/test/ELF/corrupted-version-reference.s
index 15fbbeeaa14..ce027c27f48 100644
--- a/lld/test/ELF/corrupted-version-reference.s
+++ b/lld/test/ELF/corrupted-version-reference.s
@@ -1,8 +1,8 @@
# RUN: llvm-mc -triple=mips64-unknown-freebsd %s -filetype=obj -o %t.o
# RUN: not ld.lld %t.o %S/Inputs/corrupt-version-reference.so -o %t.exe 2>&1 | FileCheck %s
-# CHECK: error: corrupt input file: version definition index 9 for symbol __cxa_finalize is greater than the maximum value 8
-# CHECK: >>> symbol is defined in {{.+}}/corrupt-version-reference.so
+# CHECK: error: corrupt input file: version definition index 9 for symbol __cxa_finalize is out of bounds
+# CHECK: >>> defined in {{.+}}/corrupt-version-reference.so
.globl __start
__start:
OpenPOWER on IntegriCloud