From d8f2702c2a56ac64bf8b69c831d566c4a38b88b8 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Mon, 15 Jan 2018 16:37:38 +0000 Subject: 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 --- compiler/linker/elf_builder.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'compiler/linker/elf_builder.h') 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 +#include #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 written_names_; // Dedup strings. }; // Writer of .dynsym and .symtab sections. -- cgit v1.2.3-59-g8ed1b