toolsandutils/e32tools/elf2e32/source/filedump.cpp
author William Roberts <williamr@symbian.org>
Tue, 06 Jul 2010 16:25:46 +0100
branchGCC_SURGE
changeset 60 5a90ee674b42
child 61 b376866b09e6
permissions -rw-r--r--
Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
//
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
//
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
// Contributors:
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
//
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
// Description:
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
// FileDump Operations of elf2e32 tool to dump E32Image and generate ASM File.
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
// @internalComponent
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
// @released
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
// 
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
//
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
#include "pl_common.h"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
#include "filedump.h"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
#include "e32imagefile.h"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
#include "h_utl.h"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    24
#include "deffile.h"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
#include "errorhandler.h"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    26
#include <stdio.h>
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    27
/**
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    28
Constructor for class FileDump
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    29
@param aParameterListInterface - Instance of class ParameterListInterface
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    30
@internalComponent
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    31
@released
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    32
*/
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    33
FileDump::FileDump(ParameterListInterface* aParameterListInterface) : UseCaseBase(aParameterListInterface)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    34
{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
/**
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
Destructor for class FileDump
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
@internalComponent
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
@released
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
*/
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    42
FileDump::~FileDump()
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
/**
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
Execute Function for the File Dump. It dumps E32 image or generate ASM file based on the
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
file dump options
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
@return 0 on success, otherwise throw error 
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
@internalComponent
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    51
@released
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
*/
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
int FileDump::Execute()
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    54
{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    55
	if(iParameterListInterface->FileDumpOption() && iParameterListInterface->E32OutOption() && iParameterListInterface->DefFileInOption()) //DumpAsm
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
	{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    57
		if(!(iParameterListInterface->DumpOptions() & EDumpAsm))
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    58
			throw InvalidArgumentError(INVALIDARGUMENTERROR,(!iParameterListInterface->FileDumpSubOptions()?"":iParameterListInterface->FileDumpSubOptions()) ,"--dump");
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    59
		if(iParameterListInterface->DumpOptions() & 31)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    60
			throw InvalidArgumentError(INVALIDARGUMENTERROR,(!iParameterListInterface->FileDumpSubOptions()?"":iParameterListInterface->FileDumpSubOptions()),"--dump");
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    61
		if(!iParameterListInterface->E32ImageOutput())
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    62
			throw ParameterParserError(NOREQUIREDOPTIONERROR,"--output");
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    63
		if(!iParameterListInterface->DefInput())
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    64
			throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput");
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
		GenerateAsmFile(iParameterListInterface->E32ImageOutput());
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
	}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    68
	else
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    69
	{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    70
		if(!iParameterListInterface->E32Input())
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    71
			throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input");
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    72
		if(iParameterListInterface->DumpOptions() & EDumpAsm )
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    73
			throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump");
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    74
		DumpE32Image(iParameterListInterface->E32Input());
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    75
	}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    76
	return 0;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    77
}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    79
/**
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    80
Function to generate ASM File.
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    81
@param afileName - ASM File name
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    82
@return 0 on success, otherwise throw error 
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    83
@internalComponent
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    84
@released
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
*/
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    86
int FileDump::GenerateAsmFile(const char* afileName)//DumpAsm
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    87
{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    88
	DefFile *iDefFile = new DefFile();
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    89
	SymbolList *aSymList;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    90
	aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput());
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    92
	FILE *fptr;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
	if((fptr=fopen(afileName,"w"))==NULL)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
	{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
		throw FileError(FILEOPENERROR,(char*)afileName);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
	}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
	else
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
	{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
		SymbolList::iterator aItr = aSymList->begin();
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   101
		SymbolList::iterator last = aSymList->end();
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   102
		Symbol *aSym;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   103
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
		while( aItr != last)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
		{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   106
			aSym = *aItr;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
			if(aSym->Absent())
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
			{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
				aItr++;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   111
				continue;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
			}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
			fputs("\tIMPORT ",fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   115
			fputs(aSym->SymbolName(),fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
			//Set the visibility of the symbols as default."DYNAMIC" option is
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
			//added to remove STV_HIDDEN visibility warnings generated by every 
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   118
			//export during kernel build 
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   119
			fputs(" [DYNAMIC]", fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   120
			fputs("\n",fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   121
			aItr++;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   122
		}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   123
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   124
        // Create a directive section that instructs the linker to make all listed
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   125
        // symbols visible.
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   126
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   127
        fputs("\n AREA |.directive|, READONLY, NOALLOC\n\n",fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   128
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   129
        fputs("\tDCB \"#<SYMEDIT>#\\n\"\n", fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   130
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   131
		aItr = aSymList->begin();
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   132
		while (aItr != last)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   133
		{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   134
			aSym = *aItr;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   135
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   136
			if ( aSym->Absent() )
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   137
			{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   138
				aItr++;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   139
				continue;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   140
			}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   141
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   142
            // Example:
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   143
            //  DCB "EXPORT __ARM_ll_mlass\n"
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   144
			fputs("\tDCB \"EXPORT ",fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   145
			fputs(aSym->SymbolName(),fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   146
			fputs("\\n\"\n", fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   147
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   148
			aItr++;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   149
		}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   150
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   151
		fputs("\n END\n",fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   152
		fclose(fptr);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   153
	}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   154
	return 0;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   155
}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   156
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   157
/**
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   158
Function to Dump E32 Image.
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   159
@param afileName - E32 Image File name
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   160
@return 1 on success, otherwise throw error 
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   161
@internalComponent
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   162
@released
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   163
*/
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   164
int FileDump::DumpE32Image(const char* afileName)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   165
{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   166
	E32ImageFile *aE32Imagefile=new E32ImageFile();
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   167
	TInt result = aE32Imagefile->Open(afileName);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   168
	
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   169
	if (result > 0)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   170
		return 1;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   171
	else if (result == KErrCorrupt || result == KErrNotSupported)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   172
	{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   173
		throw InvalidE32ImageError(INVALIDE32IMAGEERROR, (char *)afileName);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   174
	}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   175
	else if (result != 0)
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   176
	{
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   177
		throw FileError(FILEREADERROR, (char *)afileName);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   178
	}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   179
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   180
	int dumpOptions=iParameterListInterface->DumpOptions();
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   181
	
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   182
	aE32Imagefile->Dump((TText*)afileName, dumpOptions);
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   183
	delete aE32Imagefile;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   184
	return KErrNone;
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   185
}
5a90ee674b42 Reinstate elf2e32, so that we can change it more easily in GCC_SURGE builds
William Roberts <williamr@symbian.org>
parents:
diff changeset
   186