diff --git a/src/base/loader/symtab.cc b/src/base/loader/symtab.cc index 439394852..853d98cc4 100644 --- a/src/base/loader/symtab.cc +++ b/src/base/loader/symtab.cc @@ -56,12 +56,13 @@ SymbolTable::insert(Addr address, string symbol) if (symbol.empty()) return false; - if (!addrTable.insert(make_pair(address, symbol)).second) - return false; - if (!symbolTable.insert(make_pair(symbol, address)).second) return false; + // There can be multiple symbols for the same address, so always + // update the addrTable multimap when we see a new symbol name. + addrTable.insert(make_pair(address, symbol)); + return true; } diff --git a/src/base/loader/symtab.hh b/src/base/loader/symtab.hh index 403cb13ac..bd0406b74 100644 --- a/src/base/loader/symtab.hh +++ b/src/base/loader/symtab.hh @@ -42,7 +42,7 @@ class SymbolTable { public: - typedef std::map ATable; + typedef std::multimap ATable; typedef std::map STable; private: @@ -87,6 +87,8 @@ class SymbolTable if (i == addrTable.end()) return false; + // There are potentially multiple symbols that map to the same + // address. For simplicity, just return the first one. symbol = (*i).second; return true; }