# HG changeset patch # User Ross Qin # Date 1288237168 -28800 # Node ID ac2dc5c059f307a72f23a06d23b8513e3c9b9493 # Parent 76dc8e3e7f2e1768237dccace27e0c573d0c13f6# Parent fb8810d63524731a426d424c1658eca5ffe9875d merge with team repo diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/group/release.txt --- a/e32tools/elf2e32/group/release.txt Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/group/release.txt Thu Oct 28 11:39:28 2010 +0800 @@ -4,6 +4,11 @@ NOTESRC_RELEASE_REASON Postlinker(elf2e32) Release +version 2.2 build(6) +=============== +Released by Marvin Shi, 26/10/2010 + 1) Bug2979 [GCCE] elf2e32 --dump generates RVCT assembly + version 2.2 build(5) =============== Released by Zheng Shen, 11/07/2010 diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/include/h_ver.h --- a/e32tools/elf2e32/include/h_ver.h Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/include/h_ver.h Thu Oct 28 11:39:28 2010 +0800 @@ -18,7 +18,7 @@ const TInt MajorVersion=2; const TInt MinorVersion=2; -const TInt Build=5; +const TInt Build=6; #endif diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/deflatecompress.cpp --- a/e32tools/elf2e32/source/deflatecompress.cpp Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/deflatecompress.cpp Thu Oct 28 11:39:28 2010 +0800 @@ -30,13 +30,12 @@ const TInt KDeflateHashShift=24; #define COMPILE_TIME_ASSERT(e) \ - switch (0) \ - { \ - case 0: \ - case e: \ - ; \ - } - + switch (0) \ + { \ + case 0: \ + case e: \ + ; \ + } /** Class HDeflateHash @@ -136,23 +135,21 @@ { #if __GNUC__ >= 4 // Try to detect if the class' layout has changed. - COMPILE_TIME_ASSERT( sizeof(HDeflateHash) == 1028 ); - COMPILE_TIME_ASSERT( sizeof(TOffset) == 2 ); - COMPILE_TIME_ASSERT( offsetof(HDeflateHash, iHash) < offsetof(HDeflateHash, iOffset) ); + COMPILE_TIME_ASSERT( sizeof(HDeflateHash) == 1028 ); + COMPILE_TIME_ASSERT( sizeof(TOffset) == 2 ); + COMPILE_TIME_ASSERT( offsetof(HDeflateHash, iHash) < offsetof(HDeflateHash, iOffset) ); // Compute the size of the class, including rounding it up to a multiple of 4 // bytes. - - unsigned n = sizeof(TInt) * 256 + sizeof(TOffset) * Min(aLinks, KDeflateMaxDistance); - - while (n & 0x1f) - { - n++; - } + unsigned n = sizeof(TInt) * 256 + sizeof(TOffset) * Min(aLinks, KDeflateMaxDistance); + while (n & 0x1f) + { + n++; + } // Allocate the raw memory ... - void* p = ::operator new(n); + void* p = ::operator new(n); // ... And create the object in that memory. - return new(p) HDeflateHash; + return new(p) HDeflateHash; #else return new(new char[_FOFF(HDeflateHash,iOffset[Min(aLinks,KDeflateMaxDistance)])]) HDeflateHash; #endif diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/elffilesupplied.cpp --- a/e32tools/elf2e32/source/elffilesupplied.cpp Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/elffilesupplied.cpp Thu Oct 28 11:39:28 2010 +0800 @@ -235,8 +235,12 @@ while( aResultPos != aAbsentListEnd ) { // intersection set {Absent,ELF_Symbols} is non-empty + if ((strncmp("_ZTI", (*aResultPos)->SymbolName(), len)) && + (strncmp("_ZTV", (*aResultPos)->SymbolName(), len))) + { iSymList.insert(iSymList.end(), *aResultPos); cout << "Elf2e32: Warning: Symbol " << (*aResultPos)->SymbolName() << " absent in the DEF file, but present in the ELF file" << endl; + } aResultPos++; } } diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/filedump.cpp --- a/e32tools/elf2e32/source/filedump.cpp Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/filedump.cpp Thu Oct 28 11:39:28 2010 +0800 @@ -23,7 +23,8 @@ #include "h_utl.h" #include "deffile.h" #include "errorhandler.h" -#include +#include +#include /** Constructor for class FileDump @param aParameterListInterface - Instance of class ParameterListInterface @@ -63,7 +64,7 @@ if(!iParameterListInterface->DefInput()) throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput"); - GenerateAsmFile(iParameterListInterface->E32ImageOutput()); + GenerateAsmFile(); } else { @@ -71,7 +72,7 @@ throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input"); if(iParameterListInterface->DumpOptions() & EDumpAsm ) throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump"); - DumpE32Image(iParameterListInterface->E32Input()); + DumpE32Image(); } return 0; } @@ -83,11 +84,26 @@ @internalComponent @released */ -int FileDump::GenerateAsmFile(const char* afileName)//DumpAsm +int FileDump::GenerateAsmFile() //DumpAsm +{ + EAsmDialect asmDialect = iParameterListInterface->AsmDialect(); + switch(asmDialect) + { + case EGas: + return GenerateGasAsmFile(); + case EArmas: + return GenerateArmasAsmFile(); + default: + assert(false); + } + return 0; +} +int FileDump::GenerateArmasAsmFile() { DefFile *iDefFile = new DefFile(); SymbolList *aSymList; aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); + char const *afileName = iParameterListInterface->E32ImageOutput(); FILE *fptr; @@ -155,14 +171,54 @@ } /** +Function to generate a GNU as ASM File. +@param afileName - ASM File name +@return 0 on success, otherwise throw error +@internalComponent +@released*/ +int FileDump::GenerateGasAsmFile() +{ + DefFile *iDefFile = new DefFile(); + SymbolList *aSymList; + aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); + char const *afileName = iParameterListInterface->E32ImageOutput(); + FILE *fptr; + if((fptr=fopen(afileName,"w"))==NULL) + { + throw FileError(FILEOPENERROR,(char*)afileName); + } + else + { + SymbolList::iterator aItr = aSymList->begin(); + SymbolList::iterator last = aSymList->end(); + Symbol *aSym; + while( aItr != last) + { + aSym = *aItr; + if(aSym->Absent()) + { + aItr++; + continue; + } + fputs("\t.global ",fptr); + fputs(aSym->SymbolName(),fptr); + fputs("\n",fptr); + aItr++; + } + fclose(fptr); + } + return 0; +} +/** Function to Dump E32 Image. @param afileName - E32 Image File name @return 1 on success, otherwise throw error @internalComponent @released */ -int FileDump::DumpE32Image(const char* afileName) +int FileDump::DumpE32Image() { + char const *afileName = iParameterListInterface->E32Input(); E32ImageFile *aE32Imagefile=new E32ImageFile(); TInt result = aE32Imagefile->Open(afileName); diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/filedump.h --- a/e32tools/elf2e32/source/filedump.h Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/filedump.h Thu Oct 28 11:39:28 2010 +0800 @@ -35,8 +35,10 @@ ~FileDump(); int Execute(); private: - int DumpE32Image(const char * fileName); - int GenerateAsmFile(const char* afileName);//DumpAsm + int DumpE32Image(); + int GenerateAsmFile();//DumpAsm + int GenerateArmasAsmFile(); + int GenerateGasAsmFile(); }; #endif diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/parameterlistinterface.h --- a/e32tools/elf2e32/source/parameterlistinterface.h Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/parameterlistinterface.h Thu Oct 28 11:39:28 2010 +0800 @@ -43,6 +43,11 @@ EStdExe }; +enum EAsmDialect // Which dialect of arm assembly to write for the --dump option +{ + EArmas, // RVCT armas + EGas // GNU as +}; typedef unsigned int UINT; using std::vector; @@ -278,6 +283,7 @@ virtual bool SymNamedLookup() = 0; virtual bool IsDebuggable() = 0; virtual bool IsSmpSafe() = 0; + virtual EAsmDialect AsmDialect() = 0; }; diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/parametermanager.cpp --- a/e32tools/elf2e32/source/parametermanager.cpp Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/parametermanager.cpp Thu Oct 28 11:39:28 2010 +0800 @@ -25,7 +25,7 @@ #include "parametermanager.h" #include "errorhandler.h" #include -#include +#include #include "h_utl.h" #include "h_ver.h" @@ -111,7 +111,8 @@ iCustomDllTarget(false), iSymNamedLookup(false), iDebuggable(false), - iSmpSafe(false) + iSmpSafe(false), + iAsmDialect(EArmas) { iArgumentCount = aArgc; ParamList temp(aArgv, aArgv+aArgc); @@ -430,6 +431,12 @@ (void*)ParameterManager::ParseSmpSafe, "SMP Safe", }, + { + "asm", + (void*)ParameterManager::ParseAsmDialect, + "Dialect of arm assembly to write for the --dump option. " + "Either \"gas\" (GNU as) or \"armas\" (RVCT as: default)", + }, { "help", (void *)ParameterManager::ParamHelp, @@ -648,7 +655,7 @@ parser(this, "help", 0, 0); } - parser(this, const_cast(aName.c_str()), optval, aDesc); + parser(this, aName.c_str(), optval, aDesc); } } @@ -1509,6 +1516,20 @@ } /** +This function indicates the asm assembly dialect that will be written for the +--dump option, as determined by the specified or default value of the --asm +option. + +@internalComponent +@released + +@return EArmas if --asm=armas was passed, else EGas +*/ +EAsmDialect ParameterManager::AsmDialect() +{ + return iAsmDialect; +} +/** This function extracts the filename from the absolute path that is given as input. @internalComponent @@ -2256,7 +2277,7 @@ while (*(p+len-1) == ' ' || *(p+len-1) == ' ') len --; symbol = new char[len+1]; - memcpy(symbol, p, len); + memcpy(symbol, &*p, len); symbol[len] = 0; q = nq+1; while (*(p+q) == ' ' || *(p+q) == ' ') @@ -2400,7 +2421,7 @@ if (*e == '-' || *e == '+') break; } if (e != b) - ParseCapability1(b, e, aCapabilities, invert); + ParseCapability1(&*b, &*e, aCapabilities, invert); b = e; @@ -2863,6 +2884,22 @@ aPM->SetSmpSafe(true); } +DEFINE_PARAM_PARSER(ParameterManager::ParseAsmDialect) +{ + INITIALISE_PARAM_PARSER; + if (!strcmp(aValue,"gas")) + { + aPM->SetAsmDialect(EGas); + } + else if (!strcmp(aValue,"armas")) + { + aPM->SetSmpSafe(EArmas); + } + else + { + throw InvalidArgumentError(INVALIDARGUMENTERROR, aValue, "--asm"); + } +} static const ParameterManager::TargetTypeDesc DefaultTargetTypes[] = { { "DLL", EDll }, @@ -3745,3 +3782,16 @@ { iSmpSafe = aVal; } +/** +This function sets iAsmDialect if --asm is passed in. + +@internalComponent +@released + +@param aVal +A member of enum EAsmDialect +*/ +void ParameterManager::SetAsmDialect(EAsmDialect aAsmDialect) +{ + iAsmDialect = aAsmDialect; +} diff -r fb8810d63524 -r ac2dc5c059f3 e32tools/elf2e32/source/parametermanager.h --- a/e32tools/elf2e32/source/parametermanager.h Thu Oct 28 11:34:42 2010 +0800 +++ b/e32tools/elf2e32/source/parametermanager.h Thu Oct 28 11:39:28 2010 +0800 @@ -81,7 +81,7 @@ typedef std::map OptionMap; typedef vector LibSearchPaths; - typedef void (*ParserFn)(ParameterManager *, char *, char *, const OptionDesc *); + typedef void (*ParserFn)(ParameterManager *, char const *, char const *, const OptionDesc *); #define DECLARE_PARAM_PARSER(name) \ @@ -144,6 +144,7 @@ DECLARE_PARAM_PARSER(ParseSymNamedLookup); DECLARE_PARAM_PARSER(ParseDebuggable); DECLARE_PARAM_PARSER(ParseSmpSafe); + DECLARE_PARAM_PARSER(ParseAsmDialect); ParameterManager(int aArgc, char** aArgv); virtual ~ParameterManager(); @@ -195,6 +196,7 @@ void SetSymNamedLookup(bool aVal); void SetDebuggable(bool aVal); void SetSmpSafe(bool aVal); + void SetAsmDialect(EAsmDialect aAsmDialect); int NumOptions(); int NumShortOptions(); @@ -279,6 +281,7 @@ bool SymNamedLookup(); bool IsDebuggable(); bool IsSmpSafe(); + EAsmDialect AsmDialect(); private: /** The number of command line arguments passed into the program */ @@ -445,6 +448,7 @@ bool iSymNamedLookup; bool iDebuggable; bool iSmpSafe; + EAsmDialect iAsmDialect; };