]> granicus.if.org Git - llvm/commit
[llvm-readobj/libObject] - Introduce a custom warning handler for `ELFFile<ELFT>...
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 8 Aug 2019 07:17:35 +0000 (07:17 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 8 Aug 2019 07:17:35 +0000 (07:17 +0000)
commitf8ceab4641e43ea4c6c43220e2338deb13325314
tree329162b54f75aa68aa0fb9f52c9dd8b81be99831
parente672e187e16650431e41bee704e0574b3be93110
[llvm-readobj/libObject] - Introduce a custom warning handler for `ELFFile<ELFT>` methods.

Currently, we have a code duplication in llvm-readobj which was introduced in D63266.
The duplication was introduced to allow llvm-readobj to dump the partially
broken object. Methods in ELFFile<ELFT> perform a strict validation of the inputs,
what is itself good, but not for dumper tools, that might want to dump the information,
even if some pieces are broken/unexpected.

This patch introduces a warning handler which can be passed to ELFFile<ELFT> methods
and can allow skipping the non-critical errors when needed/possible.

For demonstration, I removed the duplication from llvm-readobj and implemented a warning using
the new custom warning handler. It also deduplicates the strings printed, making the output less verbose.

Differential revision: https://reviews.llvm.org/D65515

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368260 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Object/ELF.h
test/Object/invalid.test
test/tools/llvm-readobj/elf-wrong-shstrtab-type.test
tools/llvm-readobj/ELFDumper.cpp
tools/llvm-readobj/llvm-readobj.cpp
tools/llvm-readobj/llvm-readobj.h