From 8127f56dffb94defc5c5dbf93caf211195ba8aec Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Mon, 3 Nov 2014 18:25:43 +0000 Subject: Read dynamic symbols table even if binary contains debug info A=Wander Lairson Costa . R=ted at https://breakpad.appspot.com/9684002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1400 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/linux/dump_symbols.cc | 75 +++++++++++++++++++--------------------- src/common/module.cc | 19 +++++++--- 2 files changed, 51 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index a4686d25..5a74d805 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -689,6 +689,8 @@ bool LoadSymbols(const string& obj_file, names_end, elf_header->e_shnum); if (gnu_debuglink_section) { if (!info->debug_dirs().empty()) { + found_debug_info_section = true; + const char* debuglink_contents = GetOffset(elf_header, gnu_debuglink_section->sh_offset); @@ -707,50 +709,45 @@ bool LoadSymbols(const string& obj_file, fprintf(stderr, "%s does not contain a .gnu_debuglink section.\n", obj_file.c_str()); } - } else { - if (options.symbol_data != ONLY_CFI) { - // The caller doesn't want to consult .gnu_debuglink. - // See if there are export symbols available. - const Shdr* dynsym_section = - FindElfSectionByName(".dynsym", SHT_DYNSYM, - sections, names, names_end, - elf_header->e_shnum); - const Shdr* dynstr_section = - FindElfSectionByName(".dynstr", SHT_STRTAB, - sections, names, names_end, - elf_header->e_shnum); - if (dynsym_section && dynstr_section) { - info->LoadedSection(".dynsym"); - - const uint8_t* dynsyms = - GetOffset(elf_header, - dynsym_section->sh_offset); - const uint8_t* dynstrs = - GetOffset(elf_header, - dynstr_section->sh_offset); - bool result = - ELFSymbolsToModule(dynsyms, - dynsym_section->sh_size, - dynstrs, - dynstr_section->sh_size, - big_endian, - ElfClass::kAddrSize, - module); - found_usable_info = found_usable_info || result; - } - } + } + } - // Return true if some usable information was found, since - // the caller doesn't want to use .gnu_debuglink. - return found_usable_info; + if (options.symbol_data != ONLY_CFI) { + const Shdr* dynsym_section = + FindElfSectionByName(".dynsym", SHT_DYNSYM, + sections, names, names_end, + elf_header->e_shnum); + const Shdr* dynstr_section = + FindElfSectionByName(".dynstr", SHT_STRTAB, + sections, names, names_end, + elf_header->e_shnum); + if (dynsym_section && dynstr_section) { + info->LoadedSection(".dynsym"); + + const uint8_t* dynsyms = + GetOffset(elf_header, + dynsym_section->sh_offset); + const uint8_t* dynstrs = + GetOffset(elf_header, + dynstr_section->sh_offset); + bool result = + ELFSymbolsToModule(dynsyms, + dynsym_section->sh_size, + dynstrs, + dynstr_section->sh_size, + big_endian, + ElfClass::kAddrSize, + module); + found_usable_info = found_usable_info || result; } + } - // No debug info was found, let the user try again with .gnu_debuglink - // if present. - return false; + if (read_gnu_debug_link) { + return found_debug_info_section; } - return true; + // Return true if some usable information was found + return found_usable_info; } // Return the breakpad symbol file identifier for the architecture of diff --git a/src/common/module.cc b/src/common/module.cc index 244fc988..9a8e64cf 100644 --- a/src/common/module.cc +++ b/src/common/module.cc @@ -98,10 +98,21 @@ void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) { } void Module::AddExtern(Extern *ext) { - std::pair ret = externs_.insert(ext); - if (!ret.second) { - // Free the duplicate that was not inserted because this Module - // now owns it. + Function func; + func.name = ext->name; + func.address = ext->address; + + // Since parsing debug section and public info are not necessarily + // mutually exclusive, check if the symbol has already been read + // as a function to avoid duplicates. + if (functions_.find(&func) == functions_.end()) { + std::pair ret = externs_.insert(ext); + if (!ret.second) { + // Free the duplicate that was not inserted because this Module + // now owns it. + delete ext; + } + } else { delete ext; } } -- cgit v1.2.1