[llvm-readobj/elf] - Add a testing for --stackmap and refine the implementation.
authorGeorgii Rymar <grimar@accesssoftek.com>
Tue, 4 Aug 2020 12:19:36 +0000 (15:19 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 5 Aug 2020 10:09:04 +0000 (13:09 +0300)
commitf97019ad6e3a96995dda3f759ee692eb81abcc4c
tree05b3d3fd20e52899bf92158210e97a99b38df56e
parentc558c22cab9a555d2e521102b775759381e9727f
[llvm-readobj/elf] - Add a testing for --stackmap and refine the implementation.

Currently, we only test the `--stackmap` option here:
https://github.com/llvm/llvm-project/blob/master/llvm/test/Object/stackmap-dump.test
it uses a precompiled MachO binary currently and I've found no tests for this option for ELF.

The implementation also has issues. For example, it might assert on a wrong version
of the .llvm-stackmaps section. Or it might crash on an empty or truncated section.

This patch introduces a new tools/llvm-readobj/ELF test file as well as implements a few
basic checks to catch simple crashes/issues

It also eliminates `unwrapOrError` calls in `printStackMap()`.

Differential revision: https://reviews.llvm.org/D85208
llvm/include/llvm/Object/StackMapParser.h
llvm/lib/CodeGen/StackMaps.cpp
llvm/test/tools/llvm-readobj/ELF/stackmap.test [new file with mode: 0644]
llvm/tools/llvm-readobj/COFFDumper.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp