imgtools/imglib/symbolutil/symbolprocessunit.cpp
changeset 712 df89378e9223
parent 695 46ca13b54f56
child 714 e5a58c351011
equal deleted inserted replaced
697:818fe0ed324b 712:df89378e9223
    18 #include "symbolprocessunit.h"
    18 #include "symbolprocessunit.h"
    19 #include "e32image.h"
    19 #include "e32image.h"
    20 #include "symbolgenerator.h"
    20 #include "symbolgenerator.h"
    21 #include "h_utl.h"
    21 #include "h_utl.h"
    22 
    22 
    23 
    23 #ifdef _MSC_VER
       
    24 #define snprintf _snprintf
       
    25 #endif 
    24 #define MAX_LINE 65535
    26 #define MAX_LINE 65535
    25 
    27 
    26 #if defined(__LINUX__)
    28 #if defined(__LINUX__)
    27 #define PATH_SEPARATOR '/'
    29 #define PATH_SEPARATOR '/'
    28 #else
    30 #else
   534 	else {
   536 	else {
   535 		if(!fMap.good()) fMap.clear();
   537 		if(!fMap.good()) fMap.clear();
   536 	    boost::regex regARMV5("ARMV5", boost::regex::icase);
   538 	    boost::regex regARMV5("ARMV5", boost::regex::icase);
   537 	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
   539 	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
   538 	    boost::cmatch what;
   540 	    boost::cmatch what;
   539 	    if(regex_search(aFile, what, regARMV5)) {
   541 	    if(regex_search(aFile.c_str(), what, regARMV5)) {
   540 	        ProcessArmv5File(aFile, fMap);
   542 	        ProcessArmv5File(aFile, fMap);
   541 	    }
   543 	    }
   542 	    else if(regex_search(aFile, what, regGCCEoARMV4)) {
   544 	    else if(regex_search(aFile.c_str(), what, regGCCEoARMV4)) {
   543 	        ProcessGcceOrArm4File(aFile, fMap);
   545 	        ProcessGcceOrArm4File(aFile, fMap);
   544 	    }
   546 	    }
   545 	    else {
   547 	    else {
   546 	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
   548 	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
   547 	        iStdoutLog.push_back(str);
   549 	        iStdoutLog.push_back(str);
   674         while(aMap.getline(str,MAX_LINE)) {
   676         while(aMap.getline(str,MAX_LINE)) {
   675             if(strlen(str) == 0)
   677             if(strlen(str) == 0)
   676                 break;
   678                 break;
   677             else if(regex_search(str, what, reg1)) {
   679             else if(regex_search(str, what, reg1)) {
   678                 sLibFile.assign(what[4].first,what[4].second-what[4].first);
   680                 sLibFile.assign(what[4].first,what[4].second-what[4].first);
   679                 if(!regex_search(sLibFile, what1, reg)) {
   681                 if(!regex_search(sLibFile.c_str(), what1, reg)) {
   680                     sTmp.assign(what[2].first,what[2].second-what[2].first);
   682                     sTmp.assign(what[2].first,what[2].second-what[2].first);
   681                     addr = strtol(sTmp.c_str(), NULL, 16);
   683                     addr = strtol(sTmp.c_str(), NULL, 16);
   682                     sTmp.assign(what[3].first,what[3].second-what[3].first);
   684                     sTmp.assign(what[3].first,what[3].second-what[3].first);
   683                     len = strtol(sTmp.c_str(), NULL, 16);
   685                     len = strtol(sTmp.c_str(), NULL, 16);
   684                     syms[addr+len] = "";
   686                     syms[addr+len] = "";
   685                     if(regex_search(sLibFile, what, reg3)) {
   687                     if(regex_search(sLibFile.c_str(), what, reg3)) {
   686                         stubhex = addr;
   688                         stubhex = addr;
   687                     }
   689                     }
   688                 }
   690                 }
   689             }
   691             }
   690             else if(regex_search(str, what, reg2)) {
   692             else if(regex_search(str, what, reg2)) {
   776 	else {
   778 	else {
   777 		if(!fMap.good()) fMap.clear();
   779 		if(!fMap.good()) fMap.clear();
   778 	    boost::regex regARMV5("ARMV5", boost::regex::icase);
   780 	    boost::regex regARMV5("ARMV5", boost::regex::icase);
   779 	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
   781 	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
   780 	    boost::cmatch what;
   782 	    boost::cmatch what;
   781 	    if(regex_search(aFile, what, regARMV5)) {
   783 	    if(regex_search(aFile.c_str(), what, regARMV5)) {
   782 	        ProcessArmv5File(aFile, fMap);
   784 	        ProcessArmv5File(aFile, fMap);
   783 	    }
   785 	    }
   784 	    else if(regex_search(aFile, what, regGCCEoARMV4)) {
   786 	    else if(regex_search(aFile.c_str(), what, regGCCEoARMV4)) {
   785 	        ProcessGcceOrArm4File(aFile, fMap);
   787 	        ProcessGcceOrArm4File(aFile, fMap);
   786 	    }
   788 	    }
   787 	    else {
   789 	    else {
   788 	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
   790 	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
   789 	        iStdoutLog.push_back(str);
   791 	        iStdoutLog.push_back(str);
   877                     baseOffset = addr;
   879                     baseOffset = addr;
   878                 unsigned int k = addr - baseOffset;
   880                 unsigned int k = addr - baseOffset;
   879                 if( (syms.find(k) == syms.end()) || size != 0)
   881                 if( (syms.find(k) == syms.end()) || size != 0)
   880                 {
   882                 {
   881                 	TSymbolPCEntry tmpEntry;
   883                 	TSymbolPCEntry tmpEntry;
   882                 	if(regex_search(sSym, what, regScope))
   884                 	if(regex_search(sSym.c_str(), what, regScope))
   883                 	{
   885                 	{
   884                 		scopeName.assign(what[1].first, what[1].second-what[1].first);
   886                 		scopeName.assign(what[1].first, what[1].second-what[1].first);
   885                 		symName.assign(what[2].first, what[2].second-what[2].first);
   887                 		symName.assign(what[2].first, what[2].second-what[2].first);
   886                 		tmpEntry.iScopeName = scopeName;
   888                 		tmpEntry.iScopeName = scopeName;
   887                 		tmpEntry.iName = symName;
   889                 		tmpEntry.iName = symName;
   960         while(aMap.getline(str,MAX_LINE)) {
   962         while(aMap.getline(str,MAX_LINE)) {
   961             if(strlen(str) == 0)
   963             if(strlen(str) == 0)
   962                 break;
   964                 break;
   963             else if(regex_search(str, what, reg1)) {
   965             else if(regex_search(str, what, reg1)) {
   964                 sLibFile.assign(what[4].first,what[4].second-what[4].first);
   966                 sLibFile.assign(what[4].first,what[4].second-what[4].first);
   965                 if(!regex_search(sLibFile, what1, reg)) {
   967                 if(!regex_search(sLibFile.c_str(), what1, reg)) {
   966                     sTmp.assign(what[2].first,what[2].second-what[2].first);
   968                     sTmp.assign(what[2].first,what[2].second-what[2].first);
   967                     addr = strtol(sTmp.c_str(), NULL, 16);
   969                     addr = strtol(sTmp.c_str(), NULL, 16);
   968                     sTmp.assign(what[3].first,what[3].second-what[3].first);
   970                     sTmp.assign(what[3].first,what[3].second-what[3].first);
   969                     len = strtol(sTmp.c_str(), NULL, 16);
   971                     len = strtol(sTmp.c_str(), NULL, 16);
   970                     syms[addr+len] = "";
   972                     syms[addr+len] = "";
   971                     if(regex_search(sLibFile, what, reg3)) {
   973                     if(regex_search(sLibFile.c_str(), what, reg3)) {
   972                         stubhex = addr;
   974                         stubhex = addr;
   973                     }
   975                     }
   974                 }
   976                 }
   975             }
   977             }
   976             else if(regex_search(str, what, reg2)) {
   978             else if(regex_search(str, what, reg2)) {