HomePhabricator

[Object/llvm-readelf/llvm-readobj] - Improve error reporting when e_shstrndx is…

Description

[Object/llvm-readelf/llvm-readobj] - Improve error reporting when e_shstrndx is broken.

When e_shstrndx is broken, it is impossible to get a section name.
In this patch I improved the error message we show and
added tests for Object and for llvm-readelf/llvm-readobj

Message was changed in two places:

  1. llvm-readelf/llvm-readobj previously used a code from Object/ELF.h,

now they have a modified version of it (it has less checks and allows
dumping broken things).

  1. Code in Object/ELF.h is still used for generic cases.

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