[lld] r283859 - [ELF] - Fixed assertion fail when symbol table has invalid sh_info value.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 11 02:07:14 PDT 2016
Author: grimar
Date: Tue Oct 11 04:07:14 2016
New Revision: 283859
URL: http://llvm.org/viewvc/llvm-project?rev=283859&view=rev
Log:
[ELF] - Fixed assertion fail when symbol table has invalid sh_info value.
This part was splitted from D25016.
When sh_info value was set in the way that non-local symbol was treated as local, lld
was asserting, patch fixes that.
Differential revision: https://reviews.llvm.org/D25371
Added:
lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info3.elf (with props)
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/invalid/symtab-sh-info.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=283859&r1=283858&r2=283859&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Oct 11 04:07:14 2016
@@ -366,6 +366,9 @@ template <class ELFT> void Writer<ELFT>:
for (elf::ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles()) {
StringRef StrTab = F->getStringTable();
for (SymbolBody *B : F->getLocalSymbols()) {
+ if (!B->IsLocal)
+ fatal(getFilename(F) +
+ ": broken object: getLocalSymbols returns a non-local symbol");
auto *DR = dyn_cast<DefinedRegular<ELFT>>(B);
// No reason to keep local undefined symbol in symtab.
if (!DR)
Added: lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info3.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info3.elf?rev=283859&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/ELF/invalid/Inputs/symtab-sh_info3.elf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: lld/trunk/test/ELF/invalid/symtab-sh-info.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/invalid/symtab-sh-info.s?rev=283859&r1=283858&r2=283859&view=diff
==============================================================================
--- lld/trunk/test/ELF/invalid/symtab-sh-info.s (original)
+++ lld/trunk/test/ELF/invalid/symtab-sh-info.s Tue Oct 11 04:07:14 2016
@@ -2,3 +2,8 @@
## so sh_info should be at least 1 in a valid ELF.
# RUN: not ld.lld %p/Inputs/symtab-sh_info2.elf -o %t2 2>&1 | FileCheck %s
# CHECK: invalid sh_info in symbol table
+
+## sh_info contains invalid value saying non-local symbol is local.
+# RUN: not ld.lld %p/Inputs/symtab-sh_info3.elf -o %t2 2>&1 | \
+# RUN: FileCheck --check-prefix=INVALID-SYMTAB-SHINFO %s
+# INVALID-SYMTAB-SHINFO: broken object: getLocalSymbols returns a non-local symbol
More information about the llvm-commits
mailing list