[lld] r268077 - Be sure to always increment the Versym pointer.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 10:46:07 PDT 2016
Author: rafael
Date: Fri Apr 29 12:46:07 2016
New Revision: 268077
URL: http://llvm.org/viewvc/llvm-project?rev=268077&view=rev
Log:
Be sure to always increment the Versym pointer.
It was getting out of sync if we had undefined symbols at the start of
the symbol table.
Added:
lld/trunk/test/ELF/Inputs/version-undef-sym.so (with props)
lld/trunk/test/ELF/version-undef-sym.s
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=268077&r1=268076&r2=268077&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Apr 29 12:46:07 2016
@@ -490,16 +490,19 @@ template <class ELFT> void SharedFile<EL
uint32_t NumSymbols = std::distance(Syms.begin(), Syms.end());
SymbolBodies.reserve(NumSymbols);
for (const Elf_Sym &Sym : Syms) {
+ unsigned VersymIndex = 0;
+ if (Versym) {
+ VersymIndex = Versym->vs_index;
+ ++Versym;
+ }
+
StringRef Name = check(Sym.getName(this->StringTable));
if (Sym.isUndefined()) {
Undefs.push_back(Name);
continue;
}
- unsigned VersymIndex = 0;
if (Versym) {
- VersymIndex = Versym->vs_index;
- ++Versym;
// Ignore local symbols and non-default versions.
if (VersymIndex == 0 || (VersymIndex & VERSYM_HIDDEN))
continue;
Added: lld/trunk/test/ELF/Inputs/version-undef-sym.so
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/version-undef-sym.so?rev=268077&view=auto
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/version-undef-sym.so (added) and lld/trunk/test/ELF/Inputs/version-undef-sym.so Fri Apr 29 12:46:07 2016 differ
Propchange: lld/trunk/test/ELF/Inputs/version-undef-sym.so
------------------------------------------------------------------------------
svn:executable = *
Added: lld/trunk/test/ELF/version-undef-sym.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-undef-sym.s?rev=268077&view=auto
==============================================================================
--- lld/trunk/test/ELF/version-undef-sym.s (added)
+++ lld/trunk/test/ELF/version-undef-sym.s Fri Apr 29 12:46:07 2016
@@ -0,0 +1,21 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: llvm-readobj --dyn-symbols %p/Inputs/version-undef-sym.so | FileCheck %s
+
+
+// Show that the input .so has undefined symbols before bar. That is what would
+// get our version parsing out of sync.
+
+// CHECK: Section: Undefined
+// CHECK: Section: Undefined
+// CHECK: Section: Undefined
+// CHECK: Section: Undefined
+// CHECK: Section: Undefined
+// CHECK: Name: bar
+
+// But now we can successfully find bar.
+// RUN: ld.lld %t %p/Inputs/version-undef-sym.so -o %t.exe
+
+ .global _start
+_start:
+ call bar at plt
More information about the llvm-commits
mailing list