[PATCH] D91624: [llvm-readelf/obj] - Improve the error reporting in printStackSize().

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 05:25:49 PST 2020


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: rupprecht, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
grimar requested review of this revision.

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));
  }

This patch requires 2 more patches to be landed:

Depends on D91533 <https://reviews.llvm.org/D91533>.
Depends on D91530 <https://reviews.llvm.org/D91530>.


https://reviews.llvm.org/D91624

Files:
  llvm/test/tools/llvm-readobj/ELF/stack-sizes.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91624.305750.patch
Type: text/x-patch
Size: 10673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201117/29ebb502/attachment.bin>


More information about the llvm-commits mailing list