imgtools/imglib/symbolutil/symbolprocessunit.cpp
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 13:59:58 +0800
changeset 712 df89378e9223
parent 695 46ca13b54f56
child 714 e5a58c351011
permissions -rw-r--r--
Fix these errors: Some cases of PREQ1230 fail because of buildrom issue rombuild crashs when create ext-romimage readimage crashes on reading wk42 vasco_ui core image vc2008 compiling issues
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     1
/*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     8
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    11
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    12
* Contributors:
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    13
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    14
* Description: 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    15
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    16
*/
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    17
#include <boost/regex.hpp>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    18
#include "symbolprocessunit.h"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    19
#include "e32image.h"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    20
#include "symbolgenerator.h"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    21
#include "h_utl.h"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    22
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    23
#ifdef _MSC_VER
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    24
#define snprintf _snprintf
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    25
#endif 
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    26
#define MAX_LINE 65535
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    27
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    28
#if defined(__LINUX__)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    29
#define PATH_SEPARATOR '/'
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    30
#else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    31
#define PATH_SEPARATOR '\\'
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    32
#endif
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    33
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    34
void SymbolProcessUnit::ProcessEntry(const TPlacedEntry& aEntry)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    35
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    36
	if(aEntry.iFileName == "")
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    37
		return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    38
	else if(aEntry.iExecutable)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    39
		ProcessExecutableFile(aEntry.iFileName);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    40
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    41
		ProcessDataFile(aEntry.iFileName);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    42
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    43
// CommenRomSymbolProcessUnit start
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    44
void CommenRomSymbolProcessUnit::FlushStdOut(ostream& aOut)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    45
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    46
	for(int i = 0; i < (int) iStdoutLog.size(); i++)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    47
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    48
		aOut << iStdoutLog[i];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    49
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    50
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    51
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    52
void CommenRomSymbolProcessUnit::FlushSymbolContent(ostream &aOut)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    53
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    54
	for(int i = 0; i < (int) iSymbolContentLog.size(); i++)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    55
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    56
		aOut << iSymbolContentLog[i];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    57
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    58
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    59
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    60
void CommenRomSymbolProcessUnit::ResetContentLog()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    61
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    62
	iStdoutLog.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    63
	iSymbolContentLog.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    64
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    65
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    66
void CommenRomSymbolProcessUnit::ProcessEntry(const TPlacedEntry& aEntry)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    67
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    68
	iPlacedEntry = aEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    69
	SymbolProcessUnit::ProcessEntry(aEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    70
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    71
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    72
void CommenRomSymbolProcessUnit::ProcessExecutableFile(const string& aFile)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    73
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    74
	ResetContentLog();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    75
	char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    76
	string outString;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    77
	outString = "\nFrom    ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    78
	outString += aFile + "\n\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    79
	iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    80
	string mapFile2 = aFile+".map";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    81
	size_t dot = aFile.rfind('.');
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    82
	string mapFile = aFile.substr(0,dot)+".map";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    83
	ifstream fMap;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    84
	fMap.open(mapFile2.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    85
	if(!fMap.is_open()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    86
		fMap.open(mapFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    87
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    88
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    89
	if(!fMap.is_open()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    90
		sprintf(str, "\nWarning: Can't open \"%s\" or \"%s\"\n",mapFile2.c_str(),mapFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    91
		iStdoutLog.push_back(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    92
	    memset(str,0,sizeof(str));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    93
	    sprintf(str, "%08x    %04x    ", (unsigned int)iPlacedEntry.iCodeAddress, (unsigned int)iPlacedEntry.iTotalSize);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    94
	    outString = str;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    95
	    outString += aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    96
	    iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    97
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    98
	else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    99
	    if(!fMap.good()) fMap.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   100
	    char buffer[100];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   101
	    fMap.getline(buffer, 100);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   102
	    boost::regex regARMV5("ARM Linker", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   103
	    boost::regex regGCCEoARMV4("Archive member included", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   104
	    boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   105
	    if(regex_search(buffer, what, regARMV5)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   106
	        ProcessArmv5File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   107
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   108
	    else if(regex_search(buffer, what, regGCCEoARMV4)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   109
	        ProcessGcceOrArm4File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   110
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   111
	    else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   112
		fMap.seekg(0, ios_base::beg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   113
		ProcessX86File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   114
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   115
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   116
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   117
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   118
void CommenRomSymbolProcessUnit::ProcessDataFile(const string& aFile)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   119
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   120
	ResetContentLog();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   121
	char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   122
	memset(str,0,sizeof(str));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   123
	string basename = aFile.substr(aFile.rfind(PATH_SEPARATOR)+1);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   124
	sprintf(str, "\nFrom    %s\n\n%08x    0000    %s\n", aFile.c_str(), (unsigned int) iPlacedEntry.iDataAddress, basename.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   125
	iSymbolContentLog.push_back(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   126
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   127
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   128
struct ArmSymbolInfo {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   129
	string name ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   130
	TUint size ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   131
	string section ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   132
};
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   133
typedef multimap<TUint32,ArmSymbolInfo> ArmSymMap ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   134
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   135
#define SKIP_WS(p)	 while((*p) == ' ' ||  (*p) == '\t') (p)++ 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   136
#define FIND_WS(p)	 while((*p) != ' ' &&  (*p) != '\t' && (*p) != 0) (p)++ 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   137
static void split(char* str, vector<char*>& result) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   138
	result.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   139
	while(*str) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   140
		SKIP_WS(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   141
		char* saved = str ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   142
		FIND_WS(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   143
		bool end = (0 == *str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   144
		*str = 0 ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   145
		if(saved != str)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   146
			result.push_back(saved);		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   147
		if(!end) str ++ ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   148
	}	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   149
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   150
static void make_lower(char* str){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   151
	while(*str){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   152
		if(*str >= 'A' && *str >= 'Z') {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   153
			*str += ('a' - 'A');
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   154
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   155
		str++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   156
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   157
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   158
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   159
void CommenRomSymbolProcessUnit::ProcessArmv5File(const string& aFile, ifstream& aMap)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   160
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   161
	string symName ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   162
	ArmSymMap symbols ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   163
	vector<char*> words ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   164
	ArmSymbolInfo info;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   165
	char* lineStart ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   166
	char buffer[MAX_LINE];  
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   167
	while(aMap.good() && (!aMap.eof())){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   168
		*buffer = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   169
		aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   170
		lineStart = buffer ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   171
		SKIP_WS(lineStart);	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   172
		if(strstr(lineStart,"Global Symbols"))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   173
			break ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   174
		char* armstamp = strstr(lineStart,"ARM Code");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   175
		if(0 == armstamp)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   176
			armstamp = strstr(lineStart,"Thumb Code") ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   177
		if(0 == armstamp) continue ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   178
		*(armstamp - 1) = 0 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   179
		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   180
		char* hexStr = lineStart ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   181
		char* nameEnd;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   182
		while(1) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   183
			hexStr = strstr(hexStr,"0x");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   184
			if(0 == hexStr) break ; 		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   185
			nameEnd = hexStr - 1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   186
			if(*nameEnd == ' ' || *nameEnd == '\t') break ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   187
			hexStr += 2 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   188
		}	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   189
		if(0 == hexStr) continue ; 	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   190
		while(nameEnd > lineStart && (*nameEnd == ' ' || *nameEnd == '\t'))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   191
			nameEnd -- ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   192
		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   193
		nameEnd[1] = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   194
		info.name = lineStart;		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   195
		char* temp ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   196
		TUint32 addr = strtoul(hexStr + 2,&temp,16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   197
		char* decStr ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   198
		if(*armstamp == 'A')
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   199
			decStr = armstamp + 9 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   200
		else 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   201
			decStr = armstamp + 11 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   202
		SKIP_WS(decStr);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   203
		info.size = strtoul(decStr,&temp,10);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   204
		SKIP_WS(temp);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   205
		info.section = temp;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   206
		if(info.section.find("(StubCode)") != string::npos )
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   207
			info.size = 8 ; 			
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   208
		if(addr > 0){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   209
			symbols.insert(pair<TUint32,ArmSymbolInfo>(addr,info));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   210
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   211
	}	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   212
	size_t lenOfFileName = iPlacedEntry.iFileName.length();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   213
	while(aMap.good() && (!aMap.eof())){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   214
		*buffer = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   215
		aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   216
		lineStart = buffer ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   217
		SKIP_WS(lineStart); 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   218
		char* hexStr = lineStart ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   219
		char* nameEnd;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   220
		while(1) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   221
			hexStr = strstr(hexStr,"0x");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   222
			if(0 == hexStr) break ; 		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   223
			nameEnd = hexStr - 1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   224
			if(*nameEnd == ' ' || *nameEnd == '\t') 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   225
				break ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   226
			hexStr += 2 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   227
		}	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   228
		if(0 == hexStr) continue ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   229
		while(nameEnd > lineStart && (*nameEnd == ' ' || *nameEnd == '\t')){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   230
			nameEnd -- ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   231
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   232
		nameEnd[1] = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   233
		info.name = lineStart; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   234
		char *temp ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   235
		TUint32 addr = strtoul(hexStr + 2,&temp,16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   236
		while(*temp < '0' || *temp > '9' )//[^\d]*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   237
			temp++ ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   238
		char* decStr = temp ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   239
		info.size = strtoul(decStr,&temp,10);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   240
		SKIP_WS(temp);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   241
		info.section = temp;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   242
		if(info.section.find("(StubCode)") != string::npos )
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   243
			info.size = 8 ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   244
		if(addr > 0){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   245
			symbols.insert(pair<TUint32,ArmSymbolInfo>(addr,info));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   246
		} 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   247
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   248
	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   249
	TUint32 textSectAddr = 0x00008000;  // .text gets linked at 0x00008000
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   250
	TUint32 dataSectAddr = 0x00400000 ; // .data gets linked at 0x00400000
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   251
	vector<pair<int,char*> > lines ;	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   252
	size_t allocBytes;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   253
	for( ArmSymMap::iterator it = symbols.begin(); it != symbols.end() ; it++){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   254
		TUint32 thisAddr = it->first ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   255
		TUint32 romAddr ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   256
		ArmSymbolInfo& info = it->second; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   257
		if (thisAddr >= textSectAddr && thisAddr <= (textSectAddr + iPlacedEntry.iTextSize)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   258
				romAddr = thisAddr - textSectAddr + iPlacedEntry.iCodeAddress ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   259
		} 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   260
		else if ( iPlacedEntry.iDataAddress && 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   261
			( thisAddr >= dataSectAddr && thisAddr <= (dataSectAddr + iPlacedEntry.iTextSize))) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   262
			romAddr = thisAddr-dataSectAddr + iPlacedEntry.iDataBssLinearBase;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   263
		} 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   264
		else if ( iPlacedEntry.iDataBssLinearBase && 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   265
			( thisAddr >= dataSectAddr && thisAddr <= (dataSectAddr+ iPlacedEntry.iTotalDataSize))) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   266
			romAddr = thisAddr - dataSectAddr + iPlacedEntry.iDataBssLinearBase;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   267
		} 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   268
		else { 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   269
			allocBytes = info.name.length() + 60;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   270
			char* msg = new char[allocBytes] ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   271
			snprintf(msg,allocBytes,"\r\nWarning: Symbol %s @ 0x%08x not in text or data segments\r\n", \
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   272
				info.name.c_str() ,(unsigned int)thisAddr) ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   273
			iStdoutLog.push_back(msg);	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   274
			allocBytes = lenOfFileName + 80;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   275
			msg = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   276
			snprintf(msg,allocBytes,"Warning:  The map file for binary %s is out-of-sync with the binary itself\r\n\r\n",iPlacedEntry.iFileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   277
			iStdoutLog.push_back(msg);	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   278
			continue ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   279
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   280
		allocBytes =  info.section.length() + info.name.length() + 140;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   281
		char* outputLine = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   282
		int len = snprintf(outputLine,allocBytes,"%08x    %04x    %-40s  %s\r\n",(unsigned int)romAddr,info.size,
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   283
			info.name.c_str(),info.section.c_str()); 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   284
		if((size_t)len > allocBytes) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   285
			allocBytes = len + 4 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   286
			delete []outputLine;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   287
			outputLine = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   288
			len = snprintf(outputLine,allocBytes,"%08x    %04x    %-40s  %s\r\n",(unsigned int)romAddr,info.size,
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   289
			info.name.c_str(),info.section.c_str()); 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   290
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   291
		lines.push_back(pair<int,char*>(len,outputLine));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   292
	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   293
	} 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   294
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   295
	for (vector<pair<int,char*> >::iterator i = lines.begin() ; i < lines.end(); i ++ ) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   296
		char* line = i->second; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   297
		iSymbolContentLog.push_back(line);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   298
		delete[] line;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   299
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   300
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   301
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   302
template<typename M, typename K,typename V> 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   303
static void put_to_map(M& m,const K& k, const V& v) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   304
	typedef typename M::iterator iterator;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   305
	iterator it = m.find(k);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   306
	if(m.end() == it){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   307
		m.insert(pair<K,V>(k,v));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   308
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   309
	else { 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   310
		it->second = v ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   311
	}	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   312
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   313
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   314
void CommenRomSymbolProcessUnit::ProcessGcceOrArm4File(const string& aFile, ifstream& aMap)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   315
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   316
	char* lineStart; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   317
	vector<char*> words ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   318
	char buffer[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   319
	while(aMap.good() && (!aMap.eof())){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   320
		aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   321
		lineStart = buffer ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   322
		SKIP_WS(lineStart);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   323
		if( 0 == strncmp(lineStart,".text",5)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   324
			lineStart += 5;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   325
			break ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   326
		}		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   327
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   328
	split(lineStart,words);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   329
	TUint32 codeAddr , codeSize;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   330
	size_t allocBytes ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   331
	if(words.size() != 2 ||
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   332
	KErrNone != Val(codeAddr,words.at(0)) || 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   333
	KErrNone != Val(codeSize,words.at(1))) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   334
		allocBytes = iPlacedEntry.iFileName.length() + 60;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   335
		char* msg = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   336
		snprintf(msg,allocBytes,"\nError: Can't get .text section info for \"%s\"\r\n",iPlacedEntry.iFileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   337
		iStdoutLog.push_back(msg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   338
		return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   339
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   340
	map<TUint32,string> symbols ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   341
	TUint32 stubHex = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   342
	//Slurp symbols 'til the end of the text section
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   343
	while(aMap.good() && (!aMap.eof())){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   344
		aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   345
		lineStart = buffer ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   346
		SKIP_WS(lineStart); 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   347
		if(0 == *lineStart) break ; //blank line marks the end of the text section
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   348
		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   349
		// .text <addr> <len>  <library(member)>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   350
		// .text$something
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   351
		//       <addr> <len>  <library(member)>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   352
		//       <addr> <len>  LONG 0x0
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   353
		// (/^\s(\.text)?\s+(0x\w+)\s+(0x\w+)\s+(.*)$/io)	 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   354
		if(strncmp(lineStart,".text",5) == 0){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   355
			lineStart += 5 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   356
			SKIP_WS(lineStart);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   357
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   358
		char* hex1 = NULL ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   359
		char* hex2 = NULL ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   360
		char* strAfterhex1 = NULL ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   361
		TUint32 addr,size ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   362
		if(strncmp(lineStart,"0x",2) == 0){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   363
			hex1 = lineStart + 2;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   364
			char* temp ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   365
			addr = strtoul(hex1,&temp,16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   366
			SKIP_WS(temp);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   367
			strAfterhex1 = temp ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   368
			if(strncmp(temp,"0x",2) == 0){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   369
				hex2 = temp + 2 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   370
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   371
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   372
		if(NULL != hex2){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   373
			char* libraryfile ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   374
			size = strtoul(hex2,&libraryfile,16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   375
			SKIP_WS(libraryfile);  
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   376
			TUint32 key = addr + size ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   377
			put_to_map(symbols,key,string(""));//impossible symbol as end marker 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   378
			make_lower(libraryfile); 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   379
			// EUSER.LIB(ds01423.o)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   380
			// EUSER.LIB(C:/TEMP/d1000s_01423.o)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   381
			size_t len = strlen(libraryfile);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   382
			char* p1 = strstr(libraryfile,".lib(");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   383
			if(NULL == p1) 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   384
				continue ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   385
			p1 += 5;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   386
			if(strcmp(libraryfile + len - 3,".o)")!= 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   387
				continue ;		 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   388
			len -= 3 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   389
			libraryfile[len] = 0; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   390
			if(EFalse == IsValidNumber(libraryfile + len - 5))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   391
				continue ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   392
			len -= 7 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   393
			if('_' == libraryfile[len])
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   394
				len -- ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   395
			if('s' != libraryfile[len])
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   396
				continue ;		 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   397
			char* p2 = libraryfile + len - 1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   398
			while(p2 > p1 ) { 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   399
				if(*p2 < '0' || *p2 > '9')
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   400
					break ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   401
				p2 -- ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   402
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   403
			if(*p2 != 'd') 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   404
				continue ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   405
			stubHex = addr ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   406
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   407
		else if(NULL != hex1 && NULL != strAfterhex1){ 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   408
			//#  <addr>  <symbol name possibly including spaces>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   409
			//(/^\s+(\w+)\s\s+([a-zA-Z_].+)/o) 			 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   410
			char* symName = strAfterhex1; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   411
			if((*symName >= 'A' && *symName <= 'Z') ||
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   412
				(*symName >= 'a' && *symName <= 'z') || *symName == '_') {				 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   413
				string symbol(symName);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   414
				if(addr == stubHex) 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   415
					symbol.insert(0,"stub ");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   416
			 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   417
				put_to_map(symbols,addr,symbol);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   418
				 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   419
			}			
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   420
		}		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   421
	}  
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   422
	map<TUint32,string>::iterator it = symbols.begin();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   423
	TUint32 lastAddr = it->first;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   424
	string lastSymName = it->second;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   425
	vector<pair<int,char*> >lines ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   426
	it ++ ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   427
	while(it != symbols.end()) {		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   428
		TUint32 addr = it->first ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   429
		unsigned int fixedupAddr = lastAddr - codeAddr + iPlacedEntry.iCodeAddress;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   430
		TUint size = addr - lastAddr ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   431
		if(!lastSymName.empty()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   432
			allocBytes = lastSymName.length() + 40;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   433
			char* outputLine = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   434
			int n = snprintf(outputLine,allocBytes,"%08x    %04x    %s\r\n", fixedupAddr,size,lastSymName.c_str()); 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   435
			lines.push_back(pair<int,char*>(n,outputLine));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   436
		}		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   437
		lastAddr = addr ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   438
		lastSymName = it->second;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   439
		it ++ ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   440
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   441
	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   442
	vector<pair<int,char*> >::iterator i; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   443
	for ( i = lines.begin() ; i < lines.end(); i ++ ) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   444
		char* line = i->second ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   445
		iSymbolContentLog.push_back(line);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   446
		delete []line ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   447
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   448
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   449
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   450
void CommenRomSymbolProcessUnit::ProcessX86File(const string& aFile, ifstream& aMap)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   451
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   452
	char buffer[MAX_LINE]; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   453
	char* lineStart; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   454
	while(aMap.good() && (!aMap.eof())){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   455
		aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   456
		lineStart = buffer ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   457
		SKIP_WS(lineStart);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   458
		if( 0 == strncmp(lineStart,"Address",7)) { 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   459
			break ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   460
		}		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   461
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   462
	aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   463
	string lastName ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   464
	TUint32 lastAddr = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   465
	size_t allocBytes ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   466
	vector<pair<int, char*> >lines ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   467
	while(aMap.good() && (!aMap.eof())){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   468
		aMap.getline(buffer,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   469
		lineStart = buffer ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   470
		SKIP_WS(lineStart);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   471
		if(0 != strncmp(lineStart,"0001:",5))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   472
			break ;		 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   473
		char* end ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   474
		TUint32 addr = strtoul(lineStart + 5,&end,16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   475
		char* name = end + 1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   476
		SKIP_WS(name);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   477
		end = name + 1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   478
		FIND_WS(end);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   479
		*end = 0 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   480
		if(!lastName.empty()){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   481
			unsigned int size = addr - lastAddr ; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   482
			unsigned int romAddr = lastAddr + iPlacedEntry.iCodeAddress;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   483
			allocBytes = lastName.length() + 40;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   484
			char* outputLine = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   485
			int n = snprintf(outputLine,allocBytes,"%08x    %04x    %s\r\n",romAddr,size,lastName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   486
			lines.push_back(pair<int, char*>(n,outputLine));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   487
		}		
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   488
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   489
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   490
	vector<pair<int,char*> >::iterator it; 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   491
	for ( it = lines.begin() ; it < lines.end(); it ++ ) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   492
		char* line = it->second  ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   493
		iSymbolContentLog.push_back(line);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   494
		delete []line ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   495
	}	
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   496
	if(!lastName.empty()){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   497
		allocBytes = lastName.length() + 40 ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   498
		char* outputLine = new char[allocBytes];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   499
		unsigned int romAddr = lastAddr + iPlacedEntry.iCodeAddress;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   500
		snprintf(outputLine,allocBytes,"%08x    0000    %s\r\n",romAddr,lastName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   501
		iSymbolContentLog.push_back(outputLine);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   502
		delete []outputLine ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   503
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   504
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   505
// CommenRomSymbolProcessUnit end
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   506
// CommenRofsSymbolProcessUnit start 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   507
void CommenRofsSymbolProcessUnit::ProcessExecutableFile(const string& aFile)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   508
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   509
	ResetContentLog();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   510
	char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   511
	string outString;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   512
	outString = "\nFrom    ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   513
	outString += aFile + "\n\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   514
	iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   515
	string mapFile2 = aFile+".map";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   516
	size_t dot = aFile.rfind('.');
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   517
	string mapFile = aFile.substr(0,dot)+".map";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   518
	ifstream fMap;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   519
	fMap.open(mapFile2.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   520
	if(!fMap.is_open()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   521
		fMap.open(mapFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   522
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   523
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   524
	if(!fMap.is_open()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   525
		sprintf(str, "%s\nWarning: Can't open \"%s\" or \"%s\"\n",aFile.c_str(),mapFile2.c_str(),mapFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   526
		iStdoutLog.push_back(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   527
	    int binSize = GetSizeFromBinFile(aFile);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   528
	    memset(str,0,sizeof(str));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   529
	    sprintf(str,"%04x", binSize);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   530
	    outString = "00000000    ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   531
	    outString += str;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   532
	    outString += "    ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   533
	    outString += aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   534
	    iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   535
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   536
	else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   537
		if(!fMap.good()) fMap.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   538
	    boost::regex regARMV5("ARMV5", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   539
	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   540
	    boost::cmatch what;
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   541
	    if(regex_search(aFile.c_str(), what, regARMV5)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   542
	        ProcessArmv5File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   543
	    }
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   544
	    else if(regex_search(aFile.c_str(), what, regGCCEoARMV4)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   545
	        ProcessGcceOrArm4File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   546
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   547
	    else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   548
	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   549
	        iStdoutLog.push_back(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   550
	        outString = "00000000    0000    ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   551
	        outString += aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   552
	        iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   553
	        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   554
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   555
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   556
void CommenRofsSymbolProcessUnit::ProcessDataFile(const string& aFile)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   557
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   558
	ResetContentLog();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   559
	string line = "\nFrom    "+aFile+"\n\n00000000    0000    "+aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   560
	iSymbolContentLog.push_back(line);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   561
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   562
void CommenRofsSymbolProcessUnit::FlushStdOut(ostream& aOut)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   563
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   564
	for(int i = 0; i < (int) iStdoutLog.size(); i++)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   565
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   566
		aOut << iStdoutLog[i];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   567
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   568
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   569
void CommenRofsSymbolProcessUnit::FlushSymbolContent(ostream &aOut)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   570
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   571
	for(int i = 0; i < (int) iSymbolContentLog.size(); i++)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   572
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   573
		aOut << iSymbolContentLog[i];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   574
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   575
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   576
void CommenRofsSymbolProcessUnit::ResetContentLog()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   577
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   578
	iStdoutLog.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   579
	iSymbolContentLog.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   580
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   581
void CommenRofsSymbolProcessUnit::ProcessArmv5File( const string& fileName, ifstream& aMap ){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   582
    aMap.seekg (0, ios::beg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   583
    char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   584
    char outbuffer[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   585
    string outString;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   586
    aMap.getline(str,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   587
    boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   588
    boost::regex reg("^ARM Linker");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   589
    if(!regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   590
        sprintf(outbuffer, "\nWarning: expecting %s to be generated by ARM linker\n", fileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   591
        iStdoutLog.push_back(outbuffer);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   592
        outString = "00000000    0000    "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   593
        iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   594
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   595
    reg.assign("Global Symbols");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   596
    while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   597
        if(regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   598
            break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   599
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   600
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   601
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   602
    reg.assign("^\\s*(.+)\\s*0x(\\S+)\\s+[^\\d]*(\\d+)\\s+(.*)$");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   603
    string sSym,sTmp,sSection;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   604
    unsigned int addr,size,baseOffset = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   605
    map<unsigned int,string> syms;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   606
    char symString[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   607
    while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   608
        if(regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   609
            sSym.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   610
            sTmp.assign(what[2].first,what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   611
            addr = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   612
            sTmp.assign(what[3].first,what[3].second-what[3].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   613
            size = strtol(sTmp.c_str(), NULL, 10);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   614
            sSection.assign(what[4].first,what[4].second-what[4].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   615
            if(sSection.find("(StubCode)") != string::npos)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   616
                size = 8;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   617
            if(addr > 0) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   618
                memset(symString,0,sizeof(symString));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   619
                sprintf(symString,"%04x    ",size);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   620
                outString = symString;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   621
                outString += sSym+" ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   622
                outString += sSection;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   623
                if(baseOffset == 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   624
                    baseOffset = addr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   625
                unsigned int k = addr - baseOffset;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   626
                if( (syms.find(k) == syms.end()) || size != 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   627
                    syms[k] = outString;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   628
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   629
            // end of addr>0
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   630
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   631
        // end of regex_search
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   632
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   633
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   634
    map<unsigned int,string>::iterator it;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   635
    for(it = syms.begin(); it != syms.end(); it++) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   636
        memset(str,0,sizeof(str));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   637
        sprintf(str,"%08x",it->first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   638
        outString = str;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   639
        outString += "    ";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   640
        outString += it->second+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   641
        iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   642
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   643
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   644
void CommenRofsSymbolProcessUnit::ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   645
    aMap.seekg (0, ios_base::beg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   646
    char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   647
    char outbuffer[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   648
    aMap.getline(str,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   649
    boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   650
    boost::regex reg("^\\.text\\s+");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   651
    while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   652
        if(regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   653
            break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   654
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   655
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   656
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   657
    reg.assign("^\\.text\\s+(\\w+)\\s+\\w+");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   658
    if(!regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   659
        sprintf(outbuffer, "ERROR: Can't get .text section info for \"%s\"\n",fileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   660
        iStdoutLog.push_back(outbuffer);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   661
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   662
    else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   663
        string sTmp, sLibFile;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   664
        sTmp.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   665
        unsigned int imgText = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   666
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   667
        reg.assign("^LONG 0x.*", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   668
        boost::cmatch what1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   669
        boost::regex reg1("^\\s(\\.text)?\\s+(0x\\w+)\\s+(0x\\w+)\\s+(.*)$", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   670
        boost::regex reg2("^\\s+(\\w+)\\s\\s+([a-zA-Z_].+)", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   671
        boost::regex reg3(".*lib\\(.*d\\d*s_?\\d{5}.o\\)$", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   672
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   673
        map<unsigned int,string> syms;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   674
        unsigned int addr, len, stubhex;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   675
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   676
        while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   677
            if(strlen(str) == 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   678
                break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   679
            else if(regex_search(str, what, reg1)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   680
                sLibFile.assign(what[4].first,what[4].second-what[4].first);
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   681
                if(!regex_search(sLibFile.c_str(), what1, reg)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   682
                    sTmp.assign(what[2].first,what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   683
                    addr = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   684
                    sTmp.assign(what[3].first,what[3].second-what[3].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   685
                    len = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   686
                    syms[addr+len] = "";
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   687
                    if(regex_search(sLibFile.c_str(), what, reg3)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   688
                        stubhex = addr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   689
                    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   690
                }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   691
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   692
            else if(regex_search(str, what, reg2)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   693
                sTmp.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   694
                addr = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   695
                sTmp.assign(what[2].first,what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   696
                syms[addr] = (addr == stubhex)? ("stub "+sTmp) : sTmp;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   697
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   698
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   699
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   700
        map<unsigned int,string>::iterator it = syms.begin();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   701
        map<unsigned int,string>::iterator itp = it++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   702
        string outString;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   703
        for(; it != syms.end(); itp = it++) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   704
            if(itp->second != "") {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   705
                memset(str,0,sizeof(str));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   706
                sprintf(str,"%08x    %04x    ",(itp->first-imgText), (it->first-itp->first));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   707
                outString = str;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   708
                outString += it->second+"\n";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   709
                iSymbolContentLog.push_back(outString);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   710
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   711
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   712
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   713
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   714
// CommenRofsSymbolProcessUnit end
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   715
int SymbolProcessUnit::GetSizeFromBinFile( const string& fileName ){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   716
    TInt ret = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   717
    //char outbuffer[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   718
    ifstream aIf(fileName.c_str(), ios_base::binary);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   719
    if( !aIf.is_open() ) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   720
        printf("Warning: Cannot open file %s\n", fileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   721
        //iStdoutLog.push_back(outbuffer);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   722
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   723
    else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   724
        E32ImageFile e32Image;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   725
        TUint32 aSz;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   726
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   727
        aIf.seekg(0,ios_base::end);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   728
        aSz = aIf.tellg();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   729
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   730
        e32Image.Adjust(aSz);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   731
        e32Image.iFileSize = aSz;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   732
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   733
        aIf.seekg(0,ios_base::beg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   734
        aIf >> e32Image;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   735
        ret = e32Image.iOrigHdr->iCodeSize;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   736
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   737
    return ret;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   738
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   739
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   740
// for BSym
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   741
void BsymRofsSymbolProcessUnit::ProcessEntry(const TPlacedEntry& aEntry)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   742
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   743
	SymbolProcessUnit::ProcessEntry(aEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   744
	if(aEntry.iFileName == "")
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   745
		return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   746
	else if(aEntry.iExecutable)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   747
		ProcessExecutableFile(aEntry.iFileName);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   748
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   749
		ProcessDataFile(aEntry.iFileName);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   750
	iMapFileInfo.iDbgUnitPCEntry.iPCName = aEntry.iFileName;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   751
	iMapFileInfo.iDbgUnitPCEntry.iDevName = aEntry.iDevFileName;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   752
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   753
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   754
void BsymRofsSymbolProcessUnit::ProcessExecutableFile(const string& aFile)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   755
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   756
	ResetContentLog();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   757
	char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   758
	string mapFile2 = aFile+".map";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   759
	size_t dot = aFile.rfind('.');
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   760
	string mapFile = aFile.substr(0,dot)+".map";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   761
	ifstream fMap;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   762
	fMap.open(mapFile2.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   763
	if(!fMap.is_open()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   764
		fMap.open(mapFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   765
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   766
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   767
	if(!fMap.is_open()) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   768
		sprintf(str, "%s\nWarning: Can't open \"%s\" or \"%s\"\n",aFile.c_str(),mapFile2.c_str(),mapFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   769
		iStdoutLog.push_back(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   770
	    int binSize = GetSizeFromBinFile(aFile);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   771
	    TSymbolPCEntry tmpEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   772
	    tmpEntry.iSymbolEntry.iAddress = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   773
	    tmpEntry.iSymbolEntry.iLength = binSize;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   774
	    tmpEntry.iName = aFile.substr(aFile.rfind(PATH_SEPARATOR)+1);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   775
	    iMapFileInfo.iSymbolPCEntrySet.push_back(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   776
	    iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iDataSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   777
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   778
	else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   779
		if(!fMap.good()) fMap.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   780
	    boost::regex regARMV5("ARMV5", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   781
	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   782
	    boost::cmatch what;
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   783
	    if(regex_search(aFile.c_str(), what, regARMV5)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   784
	        ProcessArmv5File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   785
	    }
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   786
	    else if(regex_search(aFile.c_str(), what, regGCCEoARMV4)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   787
	        ProcessGcceOrArm4File(aFile, fMap);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   788
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   789
	    else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   790
	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   791
	        iStdoutLog.push_back(str);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   792
	    	TSymbolPCEntry tmpEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   793
	    	tmpEntry.iSymbolEntry.iAddress = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   794
	    	tmpEntry.iSymbolEntry.iLength = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   795
	    	tmpEntry.iName = aFile.substr(aFile.rfind(PATH_SEPARATOR)+1);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   796
	    	iMapFileInfo.iSymbolPCEntrySet.push_back(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   797
	    	iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iDataSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   798
	        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   799
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   800
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   801
void BsymRofsSymbolProcessUnit::ProcessDataFile(const string& aFile)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   802
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   803
	ResetContentLog();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   804
	TSymbolPCEntry tmpEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   805
	tmpEntry.iSymbolEntry.iAddress = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   806
	tmpEntry.iSymbolEntry.iLength = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   807
	tmpEntry.iName = aFile.substr(aFile.rfind(PATH_SEPARATOR)+1);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   808
	iMapFileInfo.iSymbolPCEntrySet.push_back(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   809
	iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iDataSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   810
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   811
void BsymRofsSymbolProcessUnit::FlushStdOut(ostream& aOut)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   812
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   813
	for(int i = 0; i < (int) iStdoutLog.size(); i++)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   814
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   815
		aOut << iStdoutLog[i];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   816
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   817
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   818
void BsymRofsSymbolProcessUnit::FlushSymbolContent(ostream &aOut)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   819
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   820
	iSymbolGeneratorPtr->AppendMapFileInfo(iMapFileInfo);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   821
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   822
void BsymRofsSymbolProcessUnit::ResetContentLog()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   823
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   824
	iStdoutLog.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   825
	iMapFileInfo.iDbgUnitPCEntry.iPCName = "";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   826
	iMapFileInfo.iDbgUnitPCEntry.iDevName = "";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   827
	iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.Reset();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   828
	iMapFileInfo.iSymbolPCEntrySet.clear();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   829
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   830
void BsymRofsSymbolProcessUnit::ProcessArmv5File( const string& fileName, ifstream& aMap ){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   831
    aMap.seekg (0, ios::beg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   832
    char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   833
    char outbuffer[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   834
    aMap.getline(str,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   835
    boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   836
    boost::regex reg("^ARM Linker");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   837
    if(!regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   838
        sprintf(outbuffer, "\nWarning: expecting %s to be generated by ARM linker\n", fileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   839
        iStdoutLog.push_back(outbuffer);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   840
	return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   841
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   842
    reg.assign("Global Symbols");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   843
    boost::regex bss_search("^\\s*\\.bss\\s*0x(\\S+)\\s*.*$");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   844
    bool hasValue = false;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   845
    string bssStart;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   846
    TUint32 bssSection = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   847
    while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   848
	if(!hasValue && regex_search(str, what, bss_search))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   849
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   850
	    hasValue = true;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   851
            bssStart.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   852
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   853
        if(regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   854
            break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   855
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   856
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   857
    if(!bssStart.empty())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   858
    {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   859
	bssSection = strtol(bssStart.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   860
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   861
    reg.assign("^\\s*(.+)\\s*0x(\\S+)\\s+[^\\d]*(\\d+)\\s+(.*)$");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   862
    string sSym,sTmp,sSection,scopeName, symName;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   863
    boost::regex regScope("^\\s*(\\w+)\\s*::\\s*(.*)$");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   864
    unsigned int addr,size,baseOffset = 0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   865
    map<unsigned int, TSymbolPCEntry> syms;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   866
    TUint32 dataStart = 0x400000;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   867
    while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   868
        if(regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   869
            sSym.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   870
            sTmp.assign(what[2].first,what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   871
            addr = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   872
            sTmp.assign(what[3].first,what[3].second-what[3].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   873
            size = strtol(sTmp.c_str(), NULL, 10);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   874
            sSection.assign(what[4].first,what[4].second-what[4].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   875
            if(sSection.find("(StubCode)") != string::npos)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   876
                size = 8;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   877
            if(addr > 0) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   878
                if(baseOffset == 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   879
                    baseOffset = addr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   880
                unsigned int k = addr - baseOffset;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   881
                if( (syms.find(k) == syms.end()) || size != 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   882
                {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   883
                	TSymbolPCEntry tmpEntry;
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   884
                	if(regex_search(sSym.c_str(), what, regScope))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   885
                	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   886
                		scopeName.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   887
                		symName.assign(what[2].first, what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   888
                		tmpEntry.iScopeName = scopeName;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   889
                		tmpEntry.iName = symName;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   890
                		tmpEntry.iSecName = sSection;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   891
                	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   892
                	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   893
                	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   894
                		tmpEntry.iScopeName = "";
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   895
                		tmpEntry.iName = sSym;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   896
                		tmpEntry.iSecName = sSection;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   897
                	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   898
                	tmpEntry.iSymbolEntry.iAddress = k;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   899
                	tmpEntry.iSymbolEntry.iLength = size;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   900
			syms[k]=tmpEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   901
                }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   902
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   903
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   904
            // end of addr>0
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   905
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   906
        // end of regex_search
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   907
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   908
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   909
    map<unsigned int, TSymbolPCEntry>::iterator it;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   910
    for(it = syms.begin(); it != syms.end(); it++) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   911
	    unsigned int addr = it->first;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   912
	    if(addr < dataStart)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   913
	    {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   914
	        iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iCodeSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   915
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   916
	    else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   917
	    {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   918
	        if(bssSection > 0 && addr >= bssSection)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   919
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   920
		    iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iBssSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   921
	        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   922
		else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   923
	        {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   924
		    iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iDataSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   925
	        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   926
	    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   927
            iMapFileInfo.iSymbolPCEntrySet.push_back(it->second);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   928
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   929
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   930
void BsymRofsSymbolProcessUnit::ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ){
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   931
    aMap.seekg (0, ios_base::beg);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   932
    char str[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   933
    char outbuffer[MAX_LINE];
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   934
    aMap.getline(str,MAX_LINE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   935
    boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   936
    boost::regex reg("^\\.text\\s+");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   937
    while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   938
        if(regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   939
            break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   940
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   941
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   942
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   943
    reg.assign("^\\.text\\s+(\\w+)\\s+\\w+");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   944
    if(!regex_search(str, what, reg)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   945
        sprintf(outbuffer, "ERROR: Can't get .text section info for \"%s\"\n",fileName.c_str());
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   946
        iStdoutLog.push_back(outbuffer);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   947
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   948
    else {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   949
        string sTmp, sLibFile;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   950
        sTmp.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   951
        unsigned int imgText = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   952
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   953
        reg.assign("^LONG 0x.*", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   954
        boost::cmatch what1;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   955
        boost::regex reg1("^\\s(\\.text)?\\s+(0x\\w+)\\s+(0x\\w+)\\s+(.*)$", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   956
        boost::regex reg2("^\\s+(\\w+)\\s\\s+([a-zA-Z_].+)", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   957
        boost::regex reg3(".*lib\\(.*d\\d*s_?\\d{5}.o\\)$", boost::regex::icase);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   958
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   959
        map<unsigned int,string> syms;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   960
        unsigned int addr, len, stubhex;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   961
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   962
        while(aMap.getline(str,MAX_LINE)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   963
            if(strlen(str) == 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   964
                break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   965
            else if(regex_search(str, what, reg1)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   966
                sLibFile.assign(what[4].first,what[4].second-what[4].first);
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   967
                if(!regex_search(sLibFile.c_str(), what1, reg)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   968
                    sTmp.assign(what[2].first,what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   969
                    addr = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   970
                    sTmp.assign(what[3].first,what[3].second-what[3].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   971
                    len = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   972
                    syms[addr+len] = "";
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   973
                    if(regex_search(sLibFile.c_str(), what, reg3)) {
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   974
                        stubhex = addr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   975
                    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   976
                }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   977
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   978
            else if(regex_search(str, what, reg2)) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   979
                sTmp.assign(what[1].first,what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   980
                addr = strtol(sTmp.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   981
                sTmp.assign(what[2].first,what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   982
                syms[addr] = (addr == stubhex)? ("stub "+sTmp) : sTmp;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   983
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   984
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   985
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   986
        map<unsigned int,string>::iterator it = syms.begin();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   987
        map<unsigned int,string>::iterator itp = it++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   988
        TSymbolPCEntry tmpSymbolEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   989
        for(; it != syms.end(); itp = it++) {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   990
           if(itp->second != "") {
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   991
                tmpSymbolEntry.iSymbolEntry.iAddress = itp->first-imgText;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   992
                tmpSymbolEntry.iSymbolEntry.iLength = it->first-itp->first;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   993
                tmpSymbolEntry.iName = it->second;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   994
		iMapFileInfo.iDbgUnitPCEntry.iDbgUnitEntry.iCodeSymbolCount++;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   995
                iMapFileInfo.iSymbolPCEntrySet.push_back(tmpSymbolEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   996
            }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   997
        }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   998
    }
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   999
}