[PATCH] D76081: [Object] object::ELFObjectFile::dynamic_symbol_begin(): skip symbol index 0

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 05:54:53 PDT 2020


grimar added a comment.

In D76081#1931117 <https://reviews.llvm.org/D76081#1931117>, @Higuoxing wrote:

> In D76081#1930893 <https://reviews.llvm.org/D76081#1930893>, @grimar wrote:
>
> > This need test cases I think.
>
>
> Seems that we don't have any test on `sh_size % sizeof(Elf_Sym) != 0`. Do you have any suggestion on crafting such test?


You should be able to use yaml2obj tool, see its test suite for samples (llvm\test\tools\yaml2obj\ELF).

> There are 3 tools using this method: `llvm-nm`, `llvm-objdump`, `llvm-cxxdump`. I think we could write unit test for this in `llvm-nm` or `llvm-objdump` folder. What's your opinion?

I guess it could be a c++ unit test, like we have in llvm\unittests\Object, I am not sure we might want to create objects from YAML there though, like `ObjectYAMLTests` does.
So, probably, you can just select and test `llvm-objdump`.

Given the condition you have:

  if (!DotDynSymSec || !DotDynSymSec->sh_size ||
      DotDynSymSec->sh_size % sizeof(Elf_Sym) != 0) {

I think there should be 3 sub-tests: no dynamic section case, `sh_size == 0` and `sh_size % sizeof(Elf_Sym) != 0`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76081/new/

https://reviews.llvm.org/D76081





More information about the llvm-commits mailing list