From: Colin LeMahieu Date: Wed, 18 Feb 2015 23:00:22 +0000 (+0000) Subject: [Objdump] Fixing crash when printing symbols in ELF sections with special types. X-Git-Tag: android-x86-7.1-r4~51595 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=03533724783d3c1bf9a88f814fcc3f42856b093b;p=android-x86%2Fexternal-llvm.git [Objdump] Fixing crash when printing symbols in ELF sections with special types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229759 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 125fdd17743..e7eba976fd4 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -314,8 +314,11 @@ std::error_code ELFObjectFile::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::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 index 00000000000..7c3d613cb87 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 index 00000000000..b3067d49af8 --- /dev/null +++ b/test/tools/llvm-objdump/proc-specific-section-elf.test @@ -0,0 +1,3 @@ +// RUN: llvm-objdump -t %p/Inputs/proc-specific-section-elf | FileCheck %s + +CHECK: 00000000 *UND* 00000000 print