[PATCH] D29482: Object: Handle files without a dynamic symbol table.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 3 07:31:50 PST 2017
LGTM
Peter Collingbourne via Phabricator <reviews at reviews.llvm.org> writes:
> pcc created this revision.
>
> https://reviews.llvm.org/D29482
>
> Files:
> llvm/include/llvm/Object/ELFObjectFile.h
> llvm/test/Object/nm-shared-object.test
>
>
> Index: llvm/test/Object/nm-shared-object.test
> ===================================================================
> --- llvm/test/Object/nm-shared-object.test
> +++ llvm/test/Object/nm-shared-object.test
> @@ -29,3 +29,5 @@
> RUN: | FileCheck %s -check-prefix ERROR
>
> ERROR: File format has no dynamic symbol table.
> +
> +RUN: llvm-nm -D %p/Inputs/trivial-object-test.elf-i386 | count 0
> Index: llvm/include/llvm/Object/ELFObjectFile.h
> ===================================================================
> --- llvm/include/llvm/Object/ELFObjectFile.h
> +++ llvm/include/llvm/Object/ELFObjectFile.h
> @@ -895,6 +895,8 @@
> template <class ELFT>
> elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
> const Elf_Shdr *SymTab = DotDynSymSec;
> + if (!SymTab)
> + return dynamic_symbol_begin();
> DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
> return basic_symbol_iterator(SymbolRef(Sym, this));
> }
>
>
> Index: llvm/test/Object/nm-shared-object.test
> ===================================================================
> --- llvm/test/Object/nm-shared-object.test
> +++ llvm/test/Object/nm-shared-object.test
> @@ -29,3 +29,5 @@
> RUN: | FileCheck %s -check-prefix ERROR
>
> ERROR: File format has no dynamic symbol table.
> +
> +RUN: llvm-nm -D %p/Inputs/trivial-object-test.elf-i386 | count 0
> Index: llvm/include/llvm/Object/ELFObjectFile.h
> ===================================================================
> --- llvm/include/llvm/Object/ELFObjectFile.h
> +++ llvm/include/llvm/Object/ELFObjectFile.h
> @@ -895,6 +895,8 @@
> template <class ELFT>
> elf_symbol_iterator ELFObjectFile<ELFT>::dynamic_symbol_end() const {
> const Elf_Shdr *SymTab = DotDynSymSec;
> + if (!SymTab)
> + return dynamic_symbol_begin();
> DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
> return basic_symbol_iterator(SymbolRef(Sym, this));
> }
More information about the llvm-commits
mailing list