From 93d16c699360d86db811ba3471c7f7fb09cb2d4b Mon Sep 17 00:00:00 2001 From: bxing Date: Tue, 16 Jan 2007 08:11:09 +0000 Subject: [PATCH] 1. Change "BA" to "BaseAddress" and "EP" to "EntryPoint". 2. Sort modules by their preferred load address in ascending order. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2254 6f19259b-4bc3-4df7-8a09-765794883524 --- Tools/CCode/Source/GenFvMap/GenFvMap.cpp | 42 +++++++++++++++--------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/Tools/CCode/Source/GenFvMap/GenFvMap.cpp b/Tools/CCode/Source/GenFvMap/GenFvMap.cpp index 881251f03e..5da45abbbd 100644 --- a/Tools/CCode/Source/GenFvMap/GenFvMap.cpp +++ b/Tools/CCode/Source/GenFvMap/GenFvMap.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -349,31 +350,47 @@ CFvMapFile::CFvMapFile(const CIdAddressPathMap& idAddrPath) } } +CFvMapFile::~CFvMapFile(void) +{ + Cleanup(); +} + void CFvMapFile::Cleanup(void) { for (iterator i = begin(); i != end(); i++) delete i->second; } +static bool map_less(const CFvMapFile::const_iterator& l, const CFvMapFile::const_iterator& r) +{ + return l->second->m_ullLoadAddr < r->second->m_ullLoadAddr; +} + ostream& operator << (ostream& os, const CFvMapFile& fvMap) { - for (CFvMapFile::const_iterator i = fvMap.begin(); !!os && i != fvMap.end(); i++) + vector rgIter; + rgIter.reserve(fvMap.size()); + for (CFvMapFile::const_iterator i = fvMap.begin(); i != fvMap.end(); i++) + rgIter.push_back(i); + sort(rgIter.begin(), rgIter.end(), map_less); + + for (vector::const_iterator i = rgIter.begin(); i != rgIter.end(); i++) { - CMapFile::const_iterator j = i->second->begin(); - while (j != i->second->end() && j->m_strAddress != i->second->m_strEntryPoint) j++; - if (j == i->second->end()) + CMapFile::const_iterator j = (*i)->second->begin(); + while (j != (*i)->second->end() && j->m_strAddress != (*i)->second->m_strEntryPoint) j++; + if (j == (*i)->second->end()) throw runtime_error( __FUNCTION__ ":Entry point not found for module " + - i->second->m_strModuleName); + (*i)->second->m_strModuleName); os << hex - << i->second->m_strModuleName - << " (EP=" << j->m_ullRva - << ", BA=" << i->second->m_ullLoadAddr - << ", GUID=" << i->first + << (*i)->second->m_strModuleName + << " (EntryPoint=" << j->m_ullRva + << ", BaseAddress=" << (*i)->second->m_ullLoadAddr + << ", GUID=" << (*i)->first << ")" << endl << endl; - for (j = i->second->begin(); j != i->second->end(); j++) + for (j = (*i)->second->begin(); j != (*i)->second->end(); j++) os << " " << *j << endl; os << endl << endl; @@ -382,11 +399,6 @@ ostream& operator << (ostream& os, const CFvMapFile& fvMap) return os; } -CFvMapFile::~CFvMapFile(void) -{ - Cleanup(); -} - class CGenFvMapUsage : public invalid_argument { public: -- 2.39.2