[PATCH] D25365: [ELF] - Do not crash on absolute local symbol starting from ".L".
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 08:12:25 PDT 2016
grimar retitled this revision from "[ELF] - Do not crash on invalid local symbol." to "[ELF] - Do not crash on absolute local symbol starting from ".L".".
grimar updated the summary for this revision.
grimar updated this revision to Diff 73933.
grimar added a comment.
- Updated.
https://reviews.llvm.org/D25365
Files:
ELF/Writer.cpp
test/ELF/local.s
Index: test/ELF/local.s
===================================================================
--- test/ELF/local.s
+++ 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 @@
foo:
goo:
abs = 42
+.Labs = 43
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -308,7 +308,8 @@
}
template <class ELFT>
-static bool shouldKeepInSymtab(InputSectionBase<ELFT> *Sec, StringRef SymName,
+static bool shouldKeepInSymtab(elf::ObjectFile<ELFT> *F,
+ InputSectionBase<ELFT> *Sec, StringRef SymName,
const SymbolBody &B) {
if (B.isFile())
return false;
@@ -335,7 +336,7 @@
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) {
@@ -374,7 +375,7 @@
fatal(getFilename(F) + ": invalid symbol name offset");
StringRef SymName(StrTab.data() + B->getNameOffset());
InputSectionBase<ELFT> *Sec = DR->Section;
- if (!shouldKeepInSymtab<ELFT>(Sec, SymName, *B))
+ if (!shouldKeepInSymtab<ELFT>(F, Sec, SymName, *B))
continue;
++Out<ELFT>::SymTab->NumLocals;
if (Config->Relocatable)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25365.73933.patch
Type: text/x-patch
Size: 2418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/647f27c6/attachment.bin>
More information about the llvm-commits
mailing list