[PATCH] D25371: [ELF] - Fixed assertion fail when symbol table has invalid sh_info value.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 09:05:43 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
This part was splitted from https://reviews.llvm.org/D25016.
When sh_info value was set in the way that non-local symbol was treated as local, lld
was asserting, patch fixes that.
https://reviews.llvm.org/D25371
Files:
ELF/Writer.cpp
test/ELF/invalid/Inputs/symtab-sh_info3.elf
test/ELF/invalid/symtab-sh-info.s
Index: test/ELF/invalid/symtab-sh-info.s
===================================================================
--- test/ELF/invalid/symtab-sh-info.s
+++ test/ELF/invalid/symtab-sh-info.s
@@ -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: invalid sh_info in symbol table
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -364,6 +364,8 @@
for (elf::ObjectFile<ELFT> *F : Symtab<ELFT>::X->getObjectFiles()) {
StringRef StrTab = F->getStringTable();
for (SymbolBody *B : F->getLocalSymbols()) {
+ if (!B->IsLocal)
+ fatal(getFilename(F) + ": invalid sh_info in symbol table");
auto *DR = dyn_cast<DefinedRegular<ELFT>>(B);
// No reason to keep local undefined symbol in symtab.
if (!DR)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25371.73939.patch
Type: text/x-patch
Size: 1181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/3e76f8c7/attachment.bin>
More information about the llvm-commits
mailing list