diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-06-09 15:45:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-06-09 15:45:49 +0000 |
commit | 9e618cd7ec3805f1d0fc183ae9ca099e688af663 (patch) | |
tree | a06f50a714b4d69734d0d1be737f7eaecf754581 | |
parent | c6d0c564ab068aa7b54c99d15dbbcbc9b6169da9 (diff) |
Fix global version handling.
We should not ignore the symbol, just the version.
Fixes error with -z defs.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@272270 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | ELF/InputFiles.cpp | 8 | ||||
-rw-r--r-- | test/ELF/version-use.s | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/ELF/InputFiles.cpp b/ELF/InputFiles.cpp index 2f34377fa..afc1e7170 100644 --- a/ELF/InputFiles.cpp +++ b/ELF/InputFiles.cpp @@ -529,11 +529,13 @@ template <class ELFT> void SharedFile<ELFT>::parseRest() { if (Versym) { // Ignore local symbols and non-default versions. - if (VersymIndex == VER_NDX_LOCAL || VersymIndex == VER_NDX_GLOBAL || - (VersymIndex & VERSYM_HIDDEN)) + if (VersymIndex == VER_NDX_LOCAL || (VersymIndex & VERSYM_HIDDEN)) continue; } - elf::Symtab<ELFT>::X->addShared(this, Name, Sym, Verdefs[VersymIndex]); + + const Elf_Verdef *V = + VersymIndex == VER_NDX_GLOBAL ? nullptr : Verdefs[VersymIndex]; + elf::Symtab<ELFT>::X->addShared(this, Name, Sym, V); } } diff --git a/test/ELF/version-use.s b/test/ELF/version-use.s index 684679fdb..7ef12bc04 100644 --- a/test/ELF/version-use.s +++ b/test/ELF/version-use.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux -// RUN: ld.lld %t.o %p/Inputs/version-use.so -o %t.so -shared +// RUN: ld.lld %t.o %p/Inputs/version-use.so -o %t.so -shared -z defs // RUN: llvm-readobj -s %t.so | FileCheck %s |