[Objdump] Fixing crash when printing symbols in ELF sections with special types.
authorColin LeMahieu <colinl@codeaurora.org>
Wed, 18 Feb 2015 23:00:22 +0000 (23:00 +0000)
committerColin LeMahieu <colinl@codeaurora.org>
Wed, 18 Feb 2015 23:00:22 +0000 (23:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229759 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELFObjectFile.h
test/tools/llvm-objdump/Inputs/proc-specific-section-elf [new file with mode: 0644]
test/tools/llvm-objdump/proc-specific-section-elf.test [new file with mode: 0644]

index 125fdd17743c45590f44b03b4945c856d3c7810e..e7eba976fd4f2820a10e6f420f5085b8178e3db0 100644 (file)
@@ -314,8 +314,11 @@ std::error_code ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb,
       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;
 }
diff --git a/test/tools/llvm-objdump/Inputs/proc-specific-section-elf b/test/tools/llvm-objdump/Inputs/proc-specific-section-elf
new file mode 100644 (file)
index 0000000..7c3d613
Binary files /dev/null and b/test/tools/llvm-objdump/Inputs/proc-specific-section-elf differ
diff --git a/test/tools/llvm-objdump/proc-specific-section-elf.test b/test/tools/llvm-objdump/proc-specific-section-elf.test
new file mode 100644 (file)
index 0000000..b3067d4
--- /dev/null
@@ -0,0 +1,3 @@
+// RUN: llvm-objdump -t %p/Inputs/proc-specific-section-elf | FileCheck %s
+
+CHECK: 00000000         *UND*  00000000 print