[ELF] - Do not crash on absolute local symbol starting from ".L".

Absolute local symbols with name staring from ".L" were reason of crash.
The same could happen when using some broken inputs found by AFL.

Patch fixes that.

Differential revision: https://reviews.llvm.org/D25365

llvm-svn: 283731
This commit is contained in:
George Rimar 2016-10-10 09:59:34 +00:00
parent 0a259f3b9c
commit af58b07acc
2 changed files with 13 additions and 3 deletions

View File

@ -337,7 +337,7 @@ static bool shouldKeepInSymtab(InputSectionBase<ELFT> *Sec, StringRef SymName,
if (Config->Discard == DiscardPolicy::Locals)
return false;
return !(Sec->getSectionHdr()->sh_flags & SHF_MERGE);
return !Sec || !(Sec->getSectionHdr()->sh_flags & SHF_MERGE);
}
template <class ELFT> static bool includeInSymtab(const SymbolBody &B) {

View File

@ -1,5 +1,5 @@
// Check that symbol table is correctly populated with local symbols.
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: llvm-mc -save-temp-labels -filetype=obj -triple=x86_64-pc-linux %s -o %t
// RUN: ld.lld %t -o %t1
// RUN: llvm-readobj -t -s %t1 | FileCheck %s
// REQUIRES: x86
@ -14,7 +14,7 @@
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size:
// CHECK-NEXT: Link:
// CHECK-NEXT: Info: 5
// CHECK-NEXT: Info: 6
// CHECK: Symbols [
// CHECK-NEXT: Symbol {
@ -27,6 +27,15 @@
// CHECK-NEXT: Section: Undefined
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: .Labs
// CHECK-NEXT: Value: 0x2B
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: Absolute
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: abs
// CHECK-NEXT: Value: 0x2A
// CHECK-NEXT: Size: 0
@ -80,3 +89,4 @@ blah:
foo:
goo:
abs = 42
.Labs = 43