[all-commits] [llvm/llvm-project] bccd2e: [llvm-readobj/elf] - Simplify and refine the imple...
Georgii Rymar via All-commits
all-commits at lists.llvm.org
Tue Sep 15 01:57:35 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: bccd2ec3e216fed04c46df7077462165435703a1
https://github.com/llvm/llvm-project/commit/bccd2ec3e216fed04c46df7077462165435703a1
Author: Georgii Rymar <grimar at accesssoftek.com>
Date: 2020-09-15 (Tue, 15 Sep 2020)
Changed paths:
M llvm/tools/llvm-readobj/ELFDumper.cpp
Log Message:
-----------
[llvm-readobj/elf] - Simplify and refine the implementation which dumps .stack_sizes
Our implementation of stack sizes section dumping heavily uses `ELFObjectFile<ELFT>`,
while the rest of the code uses `ELFFile<ELFT>`.
That APIs are very different. `ELFObjectFile<ELFT>` is very generic
and has `SectionRef`, `RelocationRef`, `SymbolRef` and other generic concepts.
The `ELFFile<ELFT>` class works directly with `Elf_Shdr`, `Elf_Rel[a]`, `Elf_Sym` etc,
what is probably much cleaner for ELF dumper.
Also, `ELFObjectFile<ELFT>` API does not always provide a way to check
for possible errors. E.g. the implementation of `symbol_end()` does not verify the `sh_size`:
```
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
const Elf_Shdr *SymTab = DotSymtabSec;
if (!SymTab)
return symbol_begin();
DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
return basic_symbol_iterator(SymbolRef(Sym, this));
}
```
There are many other examples which makes me thing we might win from
switching to `ELFFile<ELFT>` API, where we heavily validate an input data already.
This patch is the first step in this direction. I've converted the large portion of the code
to use `ELFFile<ELFT>`.
Differential revision: https://reviews.llvm.org/D87362
More information about the All-commits
mailing list