diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2015-06-04 23:40:23 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2015-06-04 23:40:23 +0000 |
| commit | 24558d55200186d4ca9edbc9538941df0ba735eb (patch) | |
| tree | 91056d45c03b0f7ffdc7232a1d0aa22e704e84a8 /llvm | |
| parent | 8230e5ee51ed2a37d1339fa7c608f7ba5c5ed5c7 (diff) | |
| download | bcm5719-llvm-24558d55200186d4ca9edbc9538941df0ba735eb.tar.gz bcm5719-llvm-24558d55200186d4ca9edbc9538941df0ba735eb.zip | |
[Object, ELF] Fix segmentation fault in ELFFile::getSectionName().
Don't do a null dereference if .shstrtab section is missing.
llvm-svn: 239124
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Object/ELF.h | 2 | ||||
| -rw-r--r-- | llvm/test/DebugInfo/Inputs/invalid.elf.no-shstrtab | bin | 0 -> 52 bytes | |||
| -rw-r--r-- | llvm/test/DebugInfo/dwarfdump-invalid.test | 3 |
3 files changed, 4 insertions, 1 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index e87737dcce7..bca09bf7208 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -928,7 +928,7 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSymbolName(const Elf_Shdr *Section, template <class ELFT> ErrorOr<StringRef> ELFFile<ELFT>::getSectionName(const Elf_Shdr *Section) const { - if (Section->sh_name >= dot_shstrtab_sec->sh_size) + if (!dot_shstrtab_sec || Section->sh_name >= dot_shstrtab_sec->sh_size) return object_error::parse_failed; return StringRef(getString(dot_shstrtab_sec, Section->sh_name)); } diff --git a/llvm/test/DebugInfo/Inputs/invalid.elf.no-shstrtab b/llvm/test/DebugInfo/Inputs/invalid.elf.no-shstrtab Binary files differnew file mode 100644 index 00000000000..e5996951fb1 --- /dev/null +++ b/llvm/test/DebugInfo/Inputs/invalid.elf.no-shstrtab diff --git a/llvm/test/DebugInfo/dwarfdump-invalid.test b/llvm/test/DebugInfo/dwarfdump-invalid.test index da5b23e30ce..4236d4f85e4 100644 --- a/llvm/test/DebugInfo/dwarfdump-invalid.test +++ b/llvm/test/DebugInfo/dwarfdump-invalid.test @@ -4,3 +4,6 @@ RUN: llvm-dwarfdump %p/Inputs/invalid.elf 2>&1 | FileCheck %s --check-prefix=INV RUN: llvm-dwarfdump %p/Inputs/invalid.elf.2 2>&1 | FileCheck %s --check-prefix=INVALID-ELF RUN: llvm-dwarfdump %p/Inputs/invalid.elf.3 2>&1 | FileCheck %s --check-prefix=INVALID-ELF INVALID-ELF: Invalid data was encountered while parsing the file + +RUN: llvm-dwarfdump %p/Inputs/invalid.elf.no-shstrtab 2>&1 | FileCheck %s --check-prefix=EMPTY +EMPTY: .debug_info contents: |

