[PATCH] D67390: [LLDB][ELF] Load both, .symtab and .dynsym sections
Jan Kratochvil via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 04:45:00 PDT 2019
jankratochvil added inline comments.
================
Comment at: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h:446
+ std::size_t h2 = std::hash<const char *>()(s.st_name_string.AsCString());
+ std::size_t h3 = std::hash<const char *>()(s.st_section_name_string.AsCString());
+ return llvm::hash_combine(h1, h2, h3);
----------------
I find better to rather define `std::hash<ConstString>` (or provide `ConstString::Hasher` which I do in my DWZ patchset).
================
Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2205
+ needle.st_section_name_string = ConstString(symbol_section_sp->GetName());
+ if (unique_elf_symbols.find(needle) == unique_elf_symbols.end()) {
+ symtab->AddSymbol(dc_symbol);
----------------
labath wrote:
> something like `if (unique_elf_symbols.insert(needle).second)` would be more efficient, as you don't need to mess with the map twice.
I would unconditionally add all the symbols to `std::vector<NamedElfSymbol> unique_elf_symbols` (with `unique_elf_symbols.reserve` in advance for the sym of `.symtab`+`.dynsym` sizes) and then after processing both `.symtab` and `.dynsym` and can `llvm::sort(unique_elf_symbols)` and add to `symtab` only those which are unique. I believe it will be much faster, one could benchmark it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67390/new/
https://reviews.llvm.org/D67390
More information about the llvm-commits
mailing list