changeset 93e2bd032c3b in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=93e2bd032c3b
description:
base: Fix multiple names to one address bug in SymbolTable
The SymbolTable class currently assumes that at most one symbol can
point to a given address. If multiple symbols point to the same
address, only the first one gets added to the internal symbol table
since there is already a match in the address table.
This changeset converts the address table from a map into a multimap
to be able to handle cases where an address maps to multiple
symbols. Additionally, the insert method is changed to not fail if
there is a match in the address table.
Change-Id: I6b4f1d5560c21e49a4af33220efb2a8302961768
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
Reviewed-by: Andreas Hansson <[email protected]>
Reviewed-by: Gabor Dozsa <[email protected]>
diffstat:
src/base/loader/symtab.cc | 7 ++++---
src/base/loader/symtab.hh | 4 +++-
2 files changed, 7 insertions(+), 4 deletions(-)
diffs (40 lines):
diff -r fdfc2455b091 -r 93e2bd032c3b src/base/loader/symtab.cc
--- a/src/base/loader/symtab.cc Sat Jun 18 13:02:13 2016 -0400
+++ b/src/base/loader/symtab.cc Mon Jun 20 14:39:48 2016 +0100
@@ -56,11 +56,12 @@
if (symbol.empty())
return false;
- if (!addrTable.insert(make_pair(address, symbol)).second)
+ if (!symbolTable.insert(make_pair(symbol, address)).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 -r fdfc2455b091 -r 93e2bd032c3b src/base/loader/symtab.hh
--- a/src/base/loader/symtab.hh Sat Jun 18 13:02:13 2016 -0400
+++ b/src/base/loader/symtab.hh Mon Jun 20 14:39:48 2016 +0100
@@ -42,7 +42,7 @@
class SymbolTable
{
public:
- typedef std::map<Addr, std::string> ATable;
+ typedef std::multimap<Addr, std::string> ATable;
typedef std::map<std::string, Addr> STable;
private:
@@ -87,6 +87,8 @@
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;
}
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev