forked from OSchip/llvm-project
[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 llvm-svn: 283859
This commit is contained in:
parent
5fecfaadc9
commit
78fe56e5ef
|
@ -366,6 +366,9 @@ template <class ELFT> void Writer<ELFT>::copyLocalSymbols() {
|
|||
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)
|
||||
|
|
Binary file not shown.
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue