[llvm] r248194 - Avoid SEGFAULT if a requested symbol section is absent.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 12:17:18 PDT 2015


Author: rafael
Date: Mon Sep 21 14:17:18 2015
New Revision: 248194

URL: http://llvm.org/viewvc/llvm-project?rev=248194&view=rev
Log:
Avoid SEGFAULT if a requested symbol section is absent.

Patch by Igor Kudrin!

Added:
    llvm/trunk/test/Object/readobj-absent.test
Modified:
    llvm/trunk/tools/llvm-readobj/ELFDumper.cpp

Added: llvm/trunk/test/Object/readobj-absent.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/readobj-absent.test?rev=248194&view=auto
==============================================================================
--- llvm/trunk/test/Object/readobj-absent.test (added)
+++ llvm/trunk/test/Object/readobj-absent.test Mon Sep 21 14:17:18 2015
@@ -0,0 +1,2 @@
+// Don't crash if required information is absent
+RUN: llvm-readobj -dyn-symbols %p/Inputs/trivial-object-test.elf-x86-64

Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=248194&r1=248193&r2=248194&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Mon Sep 21 14:17:18 2015
@@ -1152,6 +1152,8 @@ void ELFDumper<ELFT>::printRelocation(El
 template<class ELFT>
 void ELFDumper<ELFT>::printSymbolsHelper(bool IsDynamic) {
   const Elf_Shdr *Symtab = (IsDynamic) ? DotDynSymSec : DotSymtabSec;
+  if (!Symtab)
+    return;
   ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
   error(StrTableOrErr.getError());
   StringRef StrTable = *StrTableOrErr;




More information about the llvm-commits mailing list