summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-10-10 09:59:34 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-10-10 09:59:34 +0000
commitaf58b07acc0d9955fe3a619702155f22a98386fa (patch)
tree92c580852d0458e18a4c91a234d1c1edcb7400ca
parent0a259f3b9c752729851fbb09a1d2b8f1d8433012 (diff)
downloadbcm5719-llvm-af58b07acc0d9955fe3a619702155f22a98386fa.tar.gz
bcm5719-llvm-af58b07acc0d9955fe3a619702155f22a98386fa.zip
[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
-rw-r--r--lld/ELF/Writer.cpp2
-rw-r--r--lld/test/ELF/local.s14
2 files changed, 13 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index f968c78d829..1cb47b81adf 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -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) {
diff --git a/lld/test/ELF/local.s b/lld/test/ELF/local.s
index cc879e15c0d..f11f869808b 100644
--- a/lld/test/ELF/local.s
+++ b/lld/test/ELF/local.s
@@ -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
OpenPOWER on IntegriCloud