From 854b9f74a0771368d78ecfa27a3876a0bd2b9c88 Mon Sep 17 00:00:00 2001 From: "hashimoto@chromium.org" Date: Tue, 3 Feb 2015 07:16:04 +0000 Subject: Follow debug link correctly As thestig@chromium.org pointed out in https://breakpad.appspot.com/9684002, LoadSymbols() should return false if |read_gnu_debug_link| is false. BUG=chromium:453498 R=thestig@chromium.org Review URL: https://breakpad.appspot.com/2844002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1422 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/module.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/common/module.cc') diff --git a/src/common/module.cc b/src/common/module.cc index f682e24a..d880ce57 100644 --- a/src/common/module.cc +++ b/src/common/module.cc @@ -79,6 +79,17 @@ void Module::AddFunction(Function *function) { // FUNC lines must not hold an empty name, so catch the problem early if // callers try to add one. assert(!function->name.empty()); + + // FUNCs are better than PUBLICs as they come with sizes, so remove an extern + // with the same address if present. + Extern ext(function->address); + ExternSet::iterator it_ext = externs_.lower_bound(&ext); + if (it_ext != externs_.end() && + (*it_ext)->address < function->address + function->size) { + delete *it_ext; + externs_.erase(it_ext); + } + std::pair ret = functions_.insert(function); if (!ret.second && (*ret.first != function)) { // Free the duplicate that was not inserted because this Module @@ -98,19 +109,10 @@ void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) { } void Module::AddExtern(Extern *ext) { - Function func(ext->name, 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 { + std::pair ret = externs_.insert(ext); + if (!ret.second) { + // Free the duplicate that was not inserted because this Module + // now owns it. delete ext; } } -- cgit v1.2.1