1. Change "BA" to "BaseAddress" and "EP" to "EntryPoint".
authorbxing <bxing@de2fecce-e211-0410-80a6-f3fac2684e05>
Tue, 16 Jan 2007 08:11:09 +0000 (08:11 +0000)
committerbxing <bxing@de2fecce-e211-0410-80a6-f3fac2684e05>
Tue, 16 Jan 2007 08:11:09 +0000 (08:11 +0000)
2. Sort modules by their preferred load address in ascending order.

git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@2254 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/Tools/CCode/Source/GenFvMap/GenFvMap.cpp

index 881251f..5da45ab 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdexcept>\r
 #include <list>\r
 #include <map>\r
+#include <vector>\r
 #include <iomanip>\r
 #include <fstream>\r
 #include <sstream>\r
@@ -349,31 +350,47 @@ CFvMapFile::CFvMapFile(const CIdAddressPathMap& idAddrPath)
     }\r
 }\r
 \r
+CFvMapFile::~CFvMapFile(void)\r
+{\r
+    Cleanup();\r
+}\r
+\r
 void CFvMapFile::Cleanup(void)\r
 {\r
     for (iterator i = begin(); i != end(); i++)\r
         delete i->second;\r
 }\r
 \r
+static bool map_less(const CFvMapFile::const_iterator& l, const CFvMapFile::const_iterator& r)\r
+{\r
+    return l->second->m_ullLoadAddr < r->second->m_ullLoadAddr;\r
+}\r
+\r
 ostream& operator << (ostream& os, const CFvMapFile& fvMap)\r
 {\r
-    for (CFvMapFile::const_iterator i = fvMap.begin(); !!os && i != fvMap.end(); i++)\r
+    vector<CFvMapFile::const_iterator> rgIter;\r
+    rgIter.reserve(fvMap.size());\r
+    for (CFvMapFile::const_iterator i = fvMap.begin(); i != fvMap.end(); i++)\r
+        rgIter.push_back(i);\r
+    sort(rgIter.begin(), rgIter.end(), map_less);\r
+\r
+    for (vector<CFvMapFile::const_iterator>::const_iterator i = rgIter.begin(); i != rgIter.end(); i++)\r
     {\r
-        CMapFile::const_iterator j = i->second->begin();\r
-        while (j != i->second->end() && j->m_strAddress != i->second->m_strEntryPoint) j++;\r
-        if (j == i->second->end())\r
+        CMapFile::const_iterator j = (*i)->second->begin();\r
+        while (j != (*i)->second->end() && j->m_strAddress != (*i)->second->m_strEntryPoint) j++;\r
+        if (j == (*i)->second->end())\r
             throw runtime_error(\r
                 __FUNCTION__ ":Entry point not found for module " +\r
-                i->second->m_strModuleName);\r
+                (*i)->second->m_strModuleName);\r
 \r
         os << hex\r
-            << i->second->m_strModuleName\r
-            << " (EP=" << j->m_ullRva\r
-            << ", BA=" << i->second->m_ullLoadAddr\r
-            << ", GUID=" << i->first\r
+            << (*i)->second->m_strModuleName\r
+            << " (EntryPoint=" << j->m_ullRva\r
+            << ", BaseAddress=" << (*i)->second->m_ullLoadAddr\r
+            << ", GUID=" << (*i)->first\r
             << ")" << endl << endl;\r
 \r
-        for (j = i->second->begin(); j != i->second->end(); j++)\r
+        for (j = (*i)->second->begin(); j != (*i)->second->end(); j++)\r
             os << "  " << *j << endl;\r
 \r
         os << endl << endl;\r
@@ -382,11 +399,6 @@ ostream& operator << (ostream& os, const CFvMapFile& fvMap)
     return os;\r
 }\r
 \r
-CFvMapFile::~CFvMapFile(void)\r
-{\r
-    Cleanup();\r
-}\r
-\r
 class CGenFvMapUsage : public invalid_argument\r
 {\r
 public:\r