[lld] r249066 - Don't crash on files with no symbol table.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 13:26:38 PDT 2015


Author: rafael
Date: Thu Oct  1 15:26:37 2015
New Revision: 249066

URL: http://llvm.org/viewvc/llvm-project?rev=249066&view=rev
Log:
Don't crash on files with no symbol table.
Thanks to Roman Divacky for the test.

Added:
    lld/trunk/test/elf2/Inputs/no-symtab.o
    lld/trunk/test/elf2/no-symtab.s
Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=249066&r1=249065&r2=249066&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Oct  1 15:26:37 2015
@@ -78,6 +78,8 @@ ELFData<ELFT>::getSymbolsHelper(bool Loc
 }
 
 template <class ELFT> void ELFData<ELFT>::initStringTable() {
+  if (!Symtab)
+    return;
   ErrorOr<StringRef> StringTableOrErr = ELFObj.getStringTableForSymtab(*Symtab);
   error(StringTableOrErr.getError());
   StringTable = *StringTableOrErr;

Added: lld/trunk/test/elf2/Inputs/no-symtab.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/Inputs/no-symtab.o?rev=249066&view=auto
==============================================================================
Binary files lld/trunk/test/elf2/Inputs/no-symtab.o (added) and lld/trunk/test/elf2/Inputs/no-symtab.o Thu Oct  1 15:26:37 2015 differ

Added: lld/trunk/test/elf2/no-symtab.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/no-symtab.s?rev=249066&view=auto
==============================================================================
--- lld/trunk/test/elf2/no-symtab.s (added)
+++ lld/trunk/test/elf2/no-symtab.s Thu Oct  1 15:26:37 2015
@@ -0,0 +1,4 @@
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: lld -flavor gnu2 %t.o %p/Inputs/no-symtab.o -o %t
+.global _start
+_start:




More information about the llvm-commits mailing list