mirror of
https://github.com/intel/llvm.git
synced 2026-01-31 16:29:50 +08:00
[ELF] Don't crash when parsing a file with external version definition 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: 315035
This commit is contained in:
@@ -775,9 +775,18 @@ template <class ELFT> void SharedFile<ELFT>::parseRest() {
|
||||
// Ignore local symbols.
|
||||
if (Versym && VersymIndex == VER_NDX_LOCAL)
|
||||
continue;
|
||||
|
||||
const Elf_Verdef *V =
|
||||
VersymIndex == VER_NDX_GLOBAL ? nullptr : Verdefs[VersymIndex];
|
||||
const Elf_Verdef *V = nullptr;
|
||||
if (VersymIndex != VER_NDX_GLOBAL) {
|
||||
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));
|
||||
continue;
|
||||
}
|
||||
V = Verdefs[VersymIndex];
|
||||
}
|
||||
|
||||
if (!Hidden)
|
||||
Symtab->addShared(Name, this, Sym, V);
|
||||
|
||||
Reference in New Issue
Block a user