[llvm-readobj] - Refactor how the code dumps relocations.
authorGeorgii Rymar <grimar@accesssoftek.com>
Wed, 15 Jul 2020 11:56:55 +0000 (14:56 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Mon, 20 Jul 2020 09:05:05 +0000 (12:05 +0300)
commit2a4df6a3250870910176eae8f0c2b199c6a8cdde
treebf6cbddd0a781941d136c544ecfbb2bde6a5c3aa
parent139e2a3f7b279ca886c71b676f983ea314c36568
[llvm-readobj] - Refactor how the code dumps relocations.

There is a strange "feature" of the code: it handles all relocations as `Elf_Rela`.
For handling `Elf_Rel` it converts them to `Elf_Rela` and passes `bool IsRela` to
specify the real type everywhere.

A related issue is that the
`decode_relrs` helper in lib/Object has to return `Expected<std::vector<Elf_Rela>>`
because of that, though it could return a vector of `Elf_Rel`.

I think we should just start using templates for relocation types, it makes the code
cleaner and shorter. This patch does it.

Differential revision: https://reviews.llvm.org/D83871
llvm/include/llvm/Object/ELF.h
llvm/lib/Object/ELF.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp