Read dynamic symbols table even if binary contains debug info

A=Wander Lairson Costa <wcosta@mozilla.com>. R=ted at https://breakpad.appspot.com/9684002/

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1400 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
ted.mielczarek@gmail.com 2014-11-03 18:25:43 +00:00
parent c971cf439c
commit 8127f56dff
2 changed files with 53 additions and 45 deletions

View file

@ -689,6 +689,8 @@ bool LoadSymbols(const string& obj_file,
names_end, elf_header->e_shnum); names_end, elf_header->e_shnum);
if (gnu_debuglink_section) { if (gnu_debuglink_section) {
if (!info->debug_dirs().empty()) { if (!info->debug_dirs().empty()) {
found_debug_info_section = true;
const char* debuglink_contents = const char* debuglink_contents =
GetOffset<ElfClass, char>(elf_header, GetOffset<ElfClass, char>(elf_header,
gnu_debuglink_section->sh_offset); gnu_debuglink_section->sh_offset);
@ -707,10 +709,10 @@ bool LoadSymbols(const string& obj_file,
fprintf(stderr, "%s does not contain a .gnu_debuglink section.\n", fprintf(stderr, "%s does not contain a .gnu_debuglink section.\n",
obj_file.c_str()); obj_file.c_str());
} }
} else { }
}
if (options.symbol_data != ONLY_CFI) { 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 = const Shdr* dynsym_section =
FindElfSectionByName<ElfClass>(".dynsym", SHT_DYNSYM, FindElfSectionByName<ElfClass>(".dynsym", SHT_DYNSYM,
sections, names, names_end, sections, names, names_end,
@ -740,19 +742,14 @@ bool LoadSymbols(const string& obj_file,
} }
} }
// Return true if some usable information was found, since if (read_gnu_debug_link) {
// the caller doesn't want to use .gnu_debuglink. return found_debug_info_section;
}
// Return true if some usable information was found
return found_usable_info; return found_usable_info;
} }
// No debug info was found, let the user try again with .gnu_debuglink
// if present.
return false;
}
return true;
}
// Return the breakpad symbol file identifier for the architecture of // Return the breakpad symbol file identifier for the architecture of
// ELF_HEADER. // ELF_HEADER.
template<typename ElfClass> template<typename ElfClass>

View file

@ -98,12 +98,23 @@ void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) {
} }
void Module::AddExtern(Extern *ext) { void Module::AddExtern(Extern *ext) {
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<ExternSet::iterator,bool> ret = externs_.insert(ext); std::pair<ExternSet::iterator,bool> ret = externs_.insert(ext);
if (!ret.second) { if (!ret.second) {
// Free the duplicate that was not inserted because this Module // Free the duplicate that was not inserted because this Module
// now owns it. // now owns it.
delete ext; delete ext;
} }
} else {
delete ext;
}
} }
void Module::GetFunctions(vector<Function *> *vec, void Module::GetFunctions(vector<Function *> *vec,