[llvm] r229759 - [Objdump] Fixing crash when printing symbols in ELF sections with special types.

Colin LeMahieu colinl at codeaurora.org
Wed Feb 18 15:00:23 PST 2015


Author: colinl
Date: Wed Feb 18 17:00:22 2015
New Revision: 229759

URL: http://llvm.org/viewvc/llvm-project?rev=229759&view=rev
Log:
[Objdump] Fixing crash when printing symbols in ELF sections with special types.

Added:
    llvm/trunk/test/tools/llvm-objdump/Inputs/proc-specific-section-elf   (with props)
    llvm/trunk/test/tools/llvm-objdump/proc-specific-section-elf.test
Modified:
    llvm/trunk/include/llvm/Object/ELFObjectFile.h

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=229759&r1=229758&r2=229759&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Wed Feb 18 17:00:22 2015
@@ -314,8 +314,11 @@ std::error_code ELFObjectFile<ELFT>::get
       ESym->getType() == ELF::STT_FUNC)
     Result &= ~1;
 
-  if (Header->e_type == ELF::ET_REL)
-    Result += EF.getSection(ESym)->sh_addr;
+  if (Header->e_type == ELF::ET_REL) {
+    const typename ELFFile<ELFT>::Elf_Shdr * Section = EF.getSection(ESym);
+    if (Section != nullptr)
+      Result += Section->sh_addr;
+  }
 
   return object_error::success;
 }

Added: llvm/trunk/test/tools/llvm-objdump/Inputs/proc-specific-section-elf
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/proc-specific-section-elf?rev=229759&view=auto
==============================================================================
Binary file - no diff available.

Propchange: llvm/trunk/test/tools/llvm-objdump/Inputs/proc-specific-section-elf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm/trunk/test/tools/llvm-objdump/proc-specific-section-elf.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/proc-specific-section-elf.test?rev=229759&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/proc-specific-section-elf.test (added)
+++ llvm/trunk/test/tools/llvm-objdump/proc-specific-section-elf.test Wed Feb 18 17:00:22 2015
@@ -0,0 +1,3 @@
+// RUN: llvm-objdump -t %p/Inputs/proc-specific-section-elf | FileCheck %s
+
+CHECK: 00000000         *UND*  00000000 print





More information about the llvm-commits mailing list