Handle a VersymIndex of 0 as an error.

I noticed that the continue this patch deletes was not tested. Trying
to add a test I realized that we never put a VER_NDX_LOCAL symbol in
the dynamic symbol table. There doesn't seem to be any reason for a
linker to use VER_NDX_LOCAL for a defined shared symbol.

llvm-svn: 320817
This commit is contained in:
Rafael Espindola 2017-12-15 14:52:40 +00:00
parent 4c2eb8b244
commit 75ebe9a3bf
2 changed files with 5 additions and 5 deletions

View File

@ -793,7 +793,7 @@ template <class ELFT> void SharedFile<ELFT>::parseRest() {
// Add symbols to the symbol table.
Elf_Sym_Range Syms = this->getGlobalELFSyms();
for (const Elf_Sym &Sym : Syms) {
unsigned VersymIndex = 0;
unsigned VersymIndex = VER_NDX_GLOBAL;
if (Versym) {
VersymIndex = Versym->vs_index;
++Versym;
@ -813,12 +813,9 @@ template <class ELFT> void SharedFile<ELFT>::parseRest() {
continue;
}
// Ignore local symbols.
if (Versym && VersymIndex == VER_NDX_LOCAL)
continue;
const Elf_Verdef *Ver = nullptr;
if (VersymIndex != VER_NDX_GLOBAL) {
if (VersymIndex >= Verdefs.size()) {
if (VersymIndex >= Verdefs.size() || VersymIndex == VER_NDX_LOCAL) {
error("corrupt input file: version definition index " +
Twine(VersymIndex) + " for symbol " + Name +
" is out of bounds\n>>> defined in " + toString(this));

View File

@ -5,6 +5,9 @@
# CHECK: error: corrupt input file: version definition index 9 for symbol __cxa_finalize is out of bounds
# CHECK: >>> defined in {{.+}}/corrupt-version-reference.so
# CHECK: error: corrupt input file: version definition index 0 for symbol _Jv_RegisterClasses is out of bounds
# CHECK-NEXT: >>> defined in {{.*}}/corrupt-version-reference.so
.globl __start
__start:
dla $a0, __cxa_finalize