[llvm-readelf/obj] - Stop printing invalid names for unnamed section symbols.
authorGeorgii Rymar <grimar@accesssoftek.com>
Tue, 15 Sep 2020 13:17:08 +0000 (16:17 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Mon, 21 Sep 2020 10:05:46 +0000 (13:05 +0300)
commit095f6fbbd7b61af205d761f6951a869ec4a61722
treeb3127f2d016baf3e158beeb0c82e62bbecf656b7
parent13c73632c7cfcc2c8e70c93781d8fb9872153ede
[llvm-readelf/obj] - Stop printing invalid names for unnamed section symbols.

We have an issue with `ELFDumper<ELFT>::getSymbolSectionName`:
1) It is used deeply for both LLVM/GNU styles and might return LLVM-style only
   values to describe symbols: "Undefined", "Processor Specific", "Absolute", etc.

2) `getSymbolSectionName` is used by `getFullSymbolName` and these special values
   might appear instead of symbol names in many places.
   This occurs for unnamed section symbols currently.

This patch extracts the LLVM specific logic to `LLVMStyle<ELFT>::printSymbolSection`,
which seems to be the only place where we want to print the special values mentioned.
It also adds a meaningful new warning that is reported when we are unable to get
a section index for a section symbol.

Differential revision: https://reviews.llvm.org/D87764
llvm/test/tools/llvm-readobj/ELF/dyn-symbols.test
llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
llvm/test/tools/llvm-readobj/ELF/mips-got.test
llvm/test/tools/llvm-readobj/ELF/mips-plt.test
llvm/test/tools/llvm-readobj/ELF/symbol-shndx.test
llvm/tools/llvm-readobj/ELFDumper.cpp