diff options
author | 2018-01-15 16:37:38 +0000 | |
---|---|---|
committer | 2018-01-15 16:37:38 +0000 | |
commit | d8f2702c2a56ac64bf8b69c831d566c4a38b88b8 (patch) | |
tree | 73476797bc821d74f0810b98c220192f658f8965 /compiler/linker | |
parent | fa0b0db6fbdcbf20bf78c53500ac98cfc3a26208 (diff) |
Properly de-duplicate debug symbol names.
The simple approach was good up till now, but the interpreter
methods names are not near the compiled methods name, so use
proper full map to ensure we do not store the same name twice.
Bug: 71579677
Test: testrunner.py --host -t 137
Change-Id: I529a3b097ed20a68ad46454b47a8f8c3223f534d
Diffstat (limited to 'compiler/linker')
-rw-r--r-- | compiler/linker/elf_builder.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/compiler/linker/elf_builder.h b/compiler/linker/elf_builder.h index 3145497091..1c875189c5 100644 --- a/compiler/linker/elf_builder.h +++ b/compiler/linker/elf_builder.h @@ -18,6 +18,7 @@ #define ART_COMPILER_LINKER_ELF_BUILDER_H_ #include <vector> +#include <unordered_map> #include "arch/instruction_set.h" #include "arch/mips/instruction_set_features_mips.h" @@ -309,27 +310,24 @@ class ElfBuilder FINAL { /* info */ 0, align, /* entsize */ 0), - current_offset_(0), - last_offset_(0) { + current_offset_(0) { } Elf_Word Write(const std::string& name) { if (current_offset_ == 0) { DCHECK(name.empty()); - } else if (name == last_name_) { - return last_offset_; // Very simple string de-duplication. } - last_name_ = name; - last_offset_ = current_offset_; - this->WriteFully(name.c_str(), name.length() + 1); - current_offset_ += name.length() + 1; - return last_offset_; + auto res = written_names_.emplace(name, current_offset_); + if (res.second) { // Inserted. + this->WriteFully(name.c_str(), name.length() + 1); + current_offset_ += name.length() + 1; + } + return res.first->second; // Offset. } private: Elf_Word current_offset_; - std::string last_name_; - Elf_Word last_offset_; + std::unordered_map<std::string, Elf_Word> written_names_; // Dedup strings. }; // Writer of .dynsym and .symtab sections. |