[llvm-readelf/obj] - Improve the error reporting in printStackSize().
authorGeorgii Rymar <grimar@accesssoftek.com>
Tue, 17 Nov 2020 13:15:45 +0000 (16:15 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Tue, 24 Nov 2020 08:49:00 +0000 (11:49 +0300)
commit245052ac3080681915c4da59e871d43ea583debb
treebdc6152adaa67f85ad9881211e75e806ac4dd92d
parent50bd686695ac2ca25996be7994808f93a2b753c5
[llvm-readelf/obj] - Improve the error reporting in printStackSize().

This stops using `RelocationRef` API in the `printStackSize` method
and starts using the "regular" API that is used in almost all other places
in ELFDumper.cpp.

This is not only makes the code to be more consistent, but helps to diagnose
issues better, because the `ELFObjectFile` API, which is used
currently to implement stack sized dumping sometimes has a behavior
that just doesn't work well for broken inputs.

E.g see how it gets the `symbol_end` iterator. It will just not work
well for a case when the `sh_size` is broken.

```
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
...
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
  return basic_symbol_iterator(SymbolRef(Sym, this));
}
```

Differential revision: https://reviews.llvm.org/D91624
llvm/test/tools/llvm-readobj/ELF/stack-sizes.test
llvm/tools/llvm-readobj/ELFDumper.cpp