--- a/toolsandutils/e32tools/elf2e32/group/elf2e32.mmp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/group/elf2e32.mmp Tue Jul 06 16:56:48 2010 +0100
@@ -27,9 +27,9 @@
source pl_elfrelocation.cpp pl_elfrelocations.cpp pl_symbol.cpp polydll_fb_target.cpp polydll_rebuild_target.cpp usecasebase.cpp
source byte_pair.cpp pagedcompress.cpp checksum.cpp stdexe_target.cpp
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
-userinclude ../source
-userinclude ../include
+OS_LAYER_SYSTEMINCLUDE
+systeminclude /epoc32/include /epoc32/include/tools
+userinclude ../source ../include
option GCC -w
--- a/toolsandutils/e32tools/elf2e32/include/h_ver.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/include/h_ver.h Tue Jul 06 16:56:48 2010 +0100
@@ -18,7 +18,7 @@
const TInt MajorVersion=2;
const TInt MinorVersion=1;
-const TInt Build=15;
+const TInt Build=16;
#endif
--- a/toolsandutils/e32tools/elf2e32/source/deflatecompress.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/deflatecompress.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -29,14 +29,6 @@
const TUint KDeflateHashMultiplier=0xAC4B9B19u;
const TInt KDeflateHashShift=24;
-#define COMPILE_TIME_ASSERT(e) \
- switch (0) \
- { \
- case 0: \
- case e: \
- ; \
- }
-
/**
Class HDeflateHash
@internalComponent
@@ -133,30 +125,8 @@
*/
inline HDeflateHash* HDeflateHash::NewLC(TInt aLinks)
{
-#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) );
-
- // 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++;
- }
-
- // Allocate the raw memory ...
- void* p = ::operator new(n);
-
- // ... And create the object in that memory.
- return new(p) HDeflateHash;
-#else
+ //return new(HMem::Alloc(0,_FOFF(HDeflateHash,iOffset[Min(aLinks,KDeflateMaxDistance)]))) HDeflateHash;
return new(new char[_FOFF(HDeflateHash,iOffset[Min(aLinks,KDeflateMaxDistance)])]) HDeflateHash;
-#endif
}
/**
--- a/toolsandutils/e32tools/elf2e32/source/e32exporttable.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/e32exporttable.h Tue Jul 06 16:56:48 2010 +0100
@@ -20,7 +20,7 @@
#ifndef __E32EXPORTTABLE__
#define __E32EXPORTTABLE__
-#include <tools/elfdefs.h>
+#include "elfdefs.h"
#include "pl_elfexports.h"
--- a/toolsandutils/e32tools/elf2e32/source/e32imagefile.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/e32imagefile.h Tue Jul 06 16:56:48 2010 +0100
@@ -23,7 +23,7 @@
#include "pl_elfrelocation.h"
#include "pl_elfrelocations.h"
#include "e32imagedefs.h"
-#include <tools/elfdefs.h>
+#include "elfdefs.h"
#include <fstream>
#include <vector>
--- a/toolsandutils/e32tools/elf2e32/source/elffilesupplied.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/elffilesupplied.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -235,9 +235,13 @@
while( aResultPos != aAbsentListEnd )
{
// intersection set {Absent,ELF_Symbols} is non-empty
-
- iSymList.insert(iSymList.end(), *aResultPos);
- cout << "Elf2e32: Warning: Symbol " << (*aResultPos)->SymbolName() << " absent in the DEF file, but present in the ELF file" << endl;
+ // Ignore the non callable exports
+ 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++;
}
}
--- a/toolsandutils/e32tools/elf2e32/source/filedump.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/filedump.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -9,6 +9,7 @@
// Nokia Corporation - initial contribution.
//
// Contributors:
+// Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010
//
// Description:
// FileDump Operations of elf2e32 tool to dump E32Image and generate ASM File.
@@ -23,7 +24,9 @@
#include "h_utl.h"
#include "deffile.h"
#include "errorhandler.h"
-#include <stdio.h>
+#include <cstdio>
+#include <cassert>
+
/**
Constructor for class FileDump
@param aParameterListInterface - Instance of class ParameterListInterface
@@ -63,7 +66,7 @@
if(!iParameterListInterface->DefInput())
throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput");
- GenerateAsmFile(iParameterListInterface->E32ImageOutput());
+ GenerateAsmFile();
}
else
{
@@ -71,7 +74,7 @@
throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input");
if(iParameterListInterface->DumpOptions() & EDumpAsm )
throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump");
- DumpE32Image(iParameterListInterface->E32Input());
+ DumpE32Image();
}
return 0;
}
@@ -83,11 +86,34 @@
@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;
+}
+
+/**
+Function to generate an RVCT armas ASM File.
+@param afileName - ASM File name
+@return 0 on success, otherwise throw error
+@internalComponent
+@released
+*/
+int FileDump::GenerateArmasAsmFile()
{
DefFile *iDefFile = new DefFile();
SymbolList *aSymList;
aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput());
+ char const *afileName = iParameterListInterface->E32ImageOutput();
FILE *fptr;
@@ -155,14 +181,62 @@
}
/**
+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.common ",fptr);
+ fputs(aSym->SymbolName(),fptr);
+ fputs(" 4\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);
--- a/toolsandutils/e32tools/elf2e32/source/filedump.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/filedump.h Tue Jul 06 16:56:48 2010 +0100
@@ -9,6 +9,7 @@
// Nokia Corporation - initial contribution.
//
// Contributors:
+// Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010
//
// Description:
// FileDump Class for elf2e32 tool
@@ -35,8 +36,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
--- a/toolsandutils/e32tools/elf2e32/source/pagedcompress.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pagedcompress.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -270,26 +270,32 @@
}
-void CompressPages(TUint8* bytes, TInt size, std::ofstream& os)
+void CompressPages(TUint8 * bytes, TInt size, std::ofstream& os)
{
// Build a list of compressed pages
- TUint16 numOfPages = (TUint16) ((size + PAGE_SIZE - 1) / PAGE_SIZE);
+ TUint16 numOfPages = (TUint16) (size / PAGE_SIZE);
+ if ( size % PAGE_SIZE > 0)
+ ++numOfPages;
- CBytePairCompressedImage* comprImage = CBytePairCompressedImage::NewLC(numOfPages, size);
- if (!comprImage)
+ CBytePairCompressedImage *comprImage = CBytePairCompressedImage::NewLC(numOfPages, size);
+ if( NULL == comprImage)
{
//Print(EError," NULL == comprImage\n");
return;
}
- TUint pageNum;
- TUint remain = (TUint)size;
- for (pageNum=0; pageNum<numOfPages; ++pageNum)
+ TUint8* iPageStart;
+ TUint16 iPageLen;
+ TUint16 iPage = 0;
+
+ while(iPage * PAGE_SIZE <= size )
{
- TUint8* pageStart = bytes + pageNum * PAGE_SIZE;
- TUint pageLen = remain>PAGE_SIZE ? PAGE_SIZE : remain;
- comprImage->AddPage((TUint16)pageNum, pageStart, (TUint16)pageLen);
- remain -= pageLen;
+ iPageStart = &bytes[iPage * PAGE_SIZE];
+ iPageLen = (TUint16)( (iPage + 1) * PAGE_SIZE < size ? PAGE_SIZE : size - iPage * PAGE_SIZE);
+
+ comprImage->AddPage(iPage, iPageStart, iPageLen);
+
+ ++iPage;
}
// Write out index table and compressed pages
@@ -301,7 +307,6 @@
}
-
int DecompressPages(TUint8 * bytes, std::ifstream& is)
{
TUint decompressedSize = 0;
--- a/toolsandutils/e32tools/elf2e32/source/parameterlistinterface.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/parameterlistinterface.h Tue Jul 06 16:56:48 2010 +0100
@@ -9,6 +9,7 @@
// Nokia Corporation - initial contribution.
//
// Contributors:
+// Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010
//
// Description:
// Implementation of the Header file for the ParameterListInterface of the elf2e32 tool
@@ -43,6 +44,12 @@
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 +285,7 @@
virtual bool SymNamedLookup() = 0;
virtual bool IsDebuggable() = 0;
virtual bool IsSmpSafe() = 0;
+ virtual EAsmDialect AsmDialect() = 0;
};
--- a/toolsandutils/e32tools/elf2e32/source/parametermanager.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/parametermanager.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -9,6 +9,7 @@
// Nokia Corporation - initial contribution.
//
// Contributors:
+// Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010
//
// Description:
// Implementation of the Class ParameterManager for the elf2e32 tool
@@ -25,6 +26,7 @@
#include "parametermanager.h"
#include "errorhandler.h"
#include <iostream>
+#include <cstdlib>
#include "h_utl.h"
#include "h_ver.h"
@@ -110,7 +112,8 @@
iCustomDllTarget(false),
iSymNamedLookup(false),
iDebuggable(false),
- iSmpSafe(false)
+ iSmpSafe(false),
+ iAsmDialect(EArmas)
{
iArgumentCount = aArgc;
ParamList temp(aArgv, aArgv+aArgc);
@@ -429,6 +432,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,
@@ -647,7 +656,7 @@
parser(this, "help", 0, 0);
}
- parser(this, const_cast<char*>(aName.c_str()), optval, aDesc);
+ parser(this, aName.c_str(), optval, aDesc);
}
}
@@ -1508,6 +1517,21 @@
}
/**
+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
@@ -2247,7 +2271,7 @@
{
int len = nq;
symbol = new char[len+1];
- memcpy(symbol, p, len);
+ memcpy(symbol, &*p, len);
symbol[len] = 0;
q = nq+1;
@@ -2387,7 +2411,7 @@
if (*e == '-' || *e == '+') break;
}
if (e != b)
- ParseCapability1(b, e, aCapabilities, invert);
+ ParseCapability1(&*b, &*e, aCapabilities, invert);
b = e;
@@ -2846,6 +2870,23 @@
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 },
@@ -3728,3 +3769,18 @@
{
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;
+}
+
--- a/toolsandutils/e32tools/elf2e32/source/parametermanager.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/parametermanager.h Tue Jul 06 16:56:48 2010 +0100
@@ -9,6 +9,7 @@
// Nokia Corporation - initial contribution.
//
// Contributors:
+// Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010
//
// Description:
// Implementation of the Header file for Class ParameterManager of the elf2e32 tool
@@ -81,7 +82,7 @@
typedef std::map<string, const OptionDesc *, OptionCompare> OptionMap;
typedef vector<char *> 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 +145,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 +197,7 @@
void SetSymNamedLookup(bool aVal);
void SetDebuggable(bool aVal);
void SetSmpSafe(bool aVal);
+ void SetAsmDialect(EAsmDialect aAsmDialect);
int NumOptions();
int NumShortOptions();
@@ -279,6 +282,7 @@
bool SymNamedLookup();
bool IsDebuggable();
bool IsSmpSafe();
+ EAsmDialect AsmDialect();
private:
/** The number of command line arguments passed into the program */
@@ -445,6 +449,7 @@
bool iSymNamedLookup;
bool iDebuggable;
bool iSmpSafe;
+ EAsmDialect iAsmDialect;
};
--- a/toolsandutils/e32tools/elf2e32/source/pl_common.cpp Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pl_common.cpp Tue Jul 06 16:56:48 2010 +0100
@@ -17,7 +17,7 @@
//
//
-#include <tools/elfdefs.h>
+#include "elfdefs.h"
#include "pl_common.h"
--- a/toolsandutils/e32tools/elf2e32/source/pl_common.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pl_common.h Tue Jul 06 16:56:48 2010 +0100
@@ -27,7 +27,7 @@
#pragma warning(disable: 4710) // function not inlined
#endif
-#include <tools/elfdefs.h>
+#include "elfdefs.h"
typedef unsigned long PLULONG;
typedef unsigned int PLUINT32;
--- a/toolsandutils/e32tools/elf2e32/source/pl_dllsymbol.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pl_dllsymbol.h Tue Jul 06 16:56:48 2010 +0100
@@ -20,7 +20,7 @@
#if !defined(_PL_DLLSYMBOL_H_)
#define _PL_DLLSYMBOL_H_
-#include <tools/elfdefs.h>
+#include "elfdefs.h"
#include "pl_symbol.h"
/**
--- a/toolsandutils/e32tools/elf2e32/source/pl_elfconsumer.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pl_elfconsumer.h Tue Jul 06 16:56:48 2010 +0100
@@ -26,7 +26,7 @@
using std::list;
-enum{ KMaxWindowsIOSize = 31 * 1024 * 1024 };
+enum{ KMaxWindowsIOSize = 32 * 1024 * 1024 };
/**
This class is for reading the ELF file generated by the static linker and based on whether it is
--- a/toolsandutils/e32tools/elf2e32/source/pl_sym_type.h Tue Jul 06 16:25:46 2010 +0100
+++ b/toolsandutils/e32tools/elf2e32/source/pl_sym_type.h Tue Jul 06 16:56:48 2010 +0100
@@ -20,7 +20,7 @@
#if !defined(EA_37C067EA_9B6B_4d95_84A3_ABBE88E7AD8F__INCLUDED_)
#define EA_37C067EA_9B6B_4d95_84A3_ABBE88E7AD8F__INCLUDED_
-#include <tools/elfdefs.h>
+#include "elfdefs.h"
enum SymbolType
{