diff options
| author | George Rimar <grimar@accesssoftek.com> | 2019-10-02 14:11:35 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2019-10-02 14:11:35 +0000 |
| commit | 4496f07497a883e44477b0d8f4e331cd030ffd6e (patch) | |
| tree | 690ae172b0cd9c6c8eaca4c8e6cb3bdbf670e7c7 /llvm/tools/llvm-readobj/ELFDumper.cpp | |
| parent | ed3b68e0dc3c038261bfa591e5223e7f9d1d8b8f (diff) | |
| download | bcm5719-llvm-4496f07497a883e44477b0d8f4e331cd030ffd6e.tar.gz bcm5719-llvm-4496f07497a883e44477b0d8f4e331cd030ffd6e.zip | |
[llvm-readelf] - Report a warning when .hash section contains a chain with a cycle.
It is possible to craft a .hash section that triggers an infinite loop
in llvm-readelf code. This patch fixes the issue and introduces
a warning.
Differential revision: https://reviews.llvm.org/D68086
llvm-svn: 373476
Diffstat (limited to 'llvm/tools/llvm-readobj/ELFDumper.cpp')
| -rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index af3d0e967d1..1b3e8f4851d 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -3437,10 +3437,21 @@ template <class ELFT> void GNUStyle<ELFT>::printHashSymbols(const ELFO *Obj) { for (uint32_t Buc = 0; Buc < SysVHash->nbucket; Buc++) { if (Buckets[Buc] == ELF::STN_UNDEF) continue; + std::vector<bool> Visited(SysVHash->nchain); for (uint32_t Ch = Buckets[Buc]; Ch < SysVHash->nchain; Ch = Chains[Ch]) { if (Ch == ELF::STN_UNDEF) break; + + if (Visited[Ch]) { + reportWarning( + createError(".hash section is invalid: bucket " + Twine(Ch) + + ": a cycle was detected in the linked chain"), + this->FileName); + break; + } + printHashedSymbol(Obj, &DynSyms[0], Ch, StringTable, Buc); + Visited[Ch] = true; } } } |

