e32tools/elf2e32/source/filedump.cpp
author William Roberts <williamr@symbian.org>
Thu, 24 Jun 2010 14:23:13 +0100
changeset 598 0a541d1f13c3
parent 589 851206cea67b
permissions -rw-r--r--
Clean up licenses and remove .bak files (cf changes 56dd7656a965 and 238f4cb8391f)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     7
//
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    10
//
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    11
// Contributors:
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    12
// Mike Kinghan, mikek@symbian.org, for Symbian Foundation, 2010 
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    13
//
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    14
// Description:
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    15
// FileDump Operations of elf2e32 tool to dump E32Image and generate ASM File.
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    16
// @internalComponent
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    17
// @released
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    18
// 
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    19
//
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    20
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    21
#include "pl_common.h"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    22
#include "filedump.h"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    23
#include "e32imagefile.h"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    24
#include "h_utl.h"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    25
#include "deffile.h"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    26
#include "errorhandler.h"
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    27
#include <cstdio>
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    28
#include <cassert>
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    29
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    30
/**
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    31
Constructor for class FileDump
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    32
@param aParameterListInterface - Instance of class ParameterListInterface
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    33
@internalComponent
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    34
@released
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    35
*/
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    36
FileDump::FileDump(ParameterListInterface* aParameterListInterface) : UseCaseBase(aParameterListInterface)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    37
{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    38
}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    39
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    40
/**
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    41
Destructor for class FileDump
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    42
@internalComponent
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    43
@released
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    44
*/
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    45
FileDump::~FileDump()
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    46
{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    47
}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    48
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    49
/**
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    50
Execute Function for the File Dump. It dumps E32 image or generate ASM file based on the
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    51
file dump options
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    52
@return 0 on success, otherwise throw error 
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    53
@internalComponent
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    54
@released
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    55
*/
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    56
int FileDump::Execute()
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    57
{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    58
	if(iParameterListInterface->FileDumpOption() && iParameterListInterface->E32OutOption() && iParameterListInterface->DefFileInOption()) //DumpAsm
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    59
	{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    60
		if(!(iParameterListInterface->DumpOptions() & EDumpAsm))
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    61
			throw InvalidArgumentError(INVALIDARGUMENTERROR,(!iParameterListInterface->FileDumpSubOptions()?"":iParameterListInterface->FileDumpSubOptions()) ,"--dump");
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    62
		if(iParameterListInterface->DumpOptions() & 31)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    63
			throw InvalidArgumentError(INVALIDARGUMENTERROR,(!iParameterListInterface->FileDumpSubOptions()?"":iParameterListInterface->FileDumpSubOptions()),"--dump");
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    64
		if(!iParameterListInterface->E32ImageOutput())
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    65
			throw ParameterParserError(NOREQUIREDOPTIONERROR,"--output");
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    66
		if(!iParameterListInterface->DefInput())
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    67
			throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput");
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    68
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    69
		GenerateAsmFile();
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    70
	}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    71
	else
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    72
	{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    73
		if(!iParameterListInterface->E32Input())
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    74
			throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input");
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    75
		if(iParameterListInterface->DumpOptions() & EDumpAsm )
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    76
			throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump");
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    77
		DumpE32Image();
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    78
	}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    79
	return 0;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    80
}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    81
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    82
/**
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    83
Function to generate ASM File.
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    84
@param afileName - ASM File name
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    85
@return 0 on success, otherwise throw error 
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    86
@internalComponent
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    87
@released
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
    88
*/
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    89
int FileDump::GenerateAsmFile() //DumpAsm
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    90
{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    91
	EAsmDialect asmDialect = iParameterListInterface->AsmDialect();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    92
	switch(asmDialect)
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    93
	{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    94
	case EGas:
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    95
		return GenerateGasAsmFile();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    96
	case EArmas:
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    97
		return GenerateArmasAsmFile();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    98
	default:
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
    99
		assert(false);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   100
	}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   101
	return 0;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   102
}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   103
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   104
/**
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   105
Function to generate an RVCT armas ASM File.
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   106
@param afileName - ASM File name
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   107
@return 0 on success, otherwise throw error 
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   108
@internalComponent
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   109
@released
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   110
*/
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   111
int FileDump::GenerateArmasAsmFile()
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   112
{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   113
	DefFile *iDefFile = new DefFile();
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   114
	SymbolList *aSymList;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   115
	aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput());
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   116
	char const *afileName = iParameterListInterface->E32ImageOutput(); 
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   117
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   118
	FILE *fptr;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   119
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   120
	if((fptr=fopen(afileName,"w"))==NULL)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   121
	{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   122
		throw FileError(FILEOPENERROR,(char*)afileName);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   123
	}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   124
	else
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   125
	{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   126
		SymbolList::iterator aItr = aSymList->begin();
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   127
		SymbolList::iterator last = aSymList->end();
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   128
		Symbol *aSym;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   129
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   130
		while( aItr != last)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   131
		{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   132
			aSym = *aItr;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   133
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   134
			if(aSym->Absent())
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   135
			{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   136
				aItr++;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   137
				continue;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   138
			}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   139
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   140
			fputs("\tIMPORT ",fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   141
			fputs(aSym->SymbolName(),fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   142
			//Set the visibility of the symbols as default."DYNAMIC" option is
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   143
			//added to remove STV_HIDDEN visibility warnings generated by every 
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   144
			//export during kernel build 
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   145
			fputs(" [DYNAMIC]", fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   146
			fputs("\n",fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   147
			aItr++;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   148
		}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   149
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   150
        // Create a directive section that instructs the linker to make all listed
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   151
        // symbols visible.
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   152
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   153
        fputs("\n AREA |.directive|, READONLY, NOALLOC\n\n",fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   154
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   155
        fputs("\tDCB \"#<SYMEDIT>#\\n\"\n", fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   156
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   157
		aItr = aSymList->begin();
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   158
		while (aItr != last)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   159
		{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   160
			aSym = *aItr;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   161
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   162
			if ( aSym->Absent() )
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   163
			{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   164
				aItr++;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   165
				continue;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   166
			}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   167
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   168
            // Example:
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   169
            //  DCB "EXPORT __ARM_ll_mlass\n"
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   170
			fputs("\tDCB \"EXPORT ",fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   171
			fputs(aSym->SymbolName(),fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   172
			fputs("\\n\"\n", fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   173
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   174
			aItr++;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   175
		}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   176
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   177
		fputs("\n END\n",fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   178
		fclose(fptr);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   179
	}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   180
	return 0;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   181
}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   182
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   183
/**
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   184
Function to generate a GNU as ASM File.
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   185
@param afileName - ASM File name
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   186
@return 0 on success, otherwise throw error 
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   187
@internalComponent
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   188
@released
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   189
*/
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   190
int FileDump::GenerateGasAsmFile()
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   191
{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   192
	DefFile *iDefFile = new DefFile();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   193
	SymbolList *aSymList;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   194
	aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput());
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   195
	char const *afileName = iParameterListInterface->E32ImageOutput(); 
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   196
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   197
	FILE *fptr;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   198
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   199
	if((fptr=fopen(afileName,"w"))==NULL)
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   200
	{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   201
		throw FileError(FILEOPENERROR,(char*)afileName);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   202
	}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   203
	else
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   204
	{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   205
		SymbolList::iterator aItr = aSymList->begin();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   206
		SymbolList::iterator last = aSymList->end();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   207
		Symbol *aSym;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   208
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   209
		while( aItr != last)
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   210
		{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   211
			aSym = *aItr;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   212
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   213
			if(aSym->Absent())
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   214
			{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   215
				aItr++;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   216
				continue;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   217
			}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   218
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   219
			fputs("\t.extern ",fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   220
			fputs(aSym->SymbolName(),fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   221
			fputs("\n",fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   222
			aItr++;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   223
		}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   224
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   225
        // Create a directive section that instructs the linker to make all listed
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   226
        // symbols visible.
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   227
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   228
        fputs("\t.text\n\n",fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   229
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   230
        fputs("\t.ascii \"#<SYMEDIT>#\\n\"\n", fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   231
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   232
		aItr = aSymList->begin();
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   233
		while (aItr != last)
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   234
		{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   235
			aSym = *aItr;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   236
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   237
			if ( aSym->Absent() )
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   238
			{
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   239
				aItr++;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   240
				continue;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   241
			}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   242
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   243
            // Example:
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   244
            //  DCB "EXPORT __ARM_ll_mlass\n"
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   245
			fputs("\t.ascii \"EXPORT ",fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   246
			fputs(aSym->SymbolName(),fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   247
			fputs("\\n\"\n", fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   248
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   249
			aItr++;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   250
		}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   251
		fclose(fptr);
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   252
	}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   253
	return 0;
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   254
}
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   255
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   256
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   257
/**
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   258
Function to Dump E32 Image.
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   259
@param afileName - E32 Image File name
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   260
@return 1 on success, otherwise throw error 
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   261
@internalComponent
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   262
@released
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   263
*/
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   264
int FileDump::DumpE32Image()
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   265
{
589
851206cea67b Add --asm option to elf2e32, so that GCCE builds can use --asm=gas with --dump=a and get a usable .s file (Bug 1405)
Mike Kinghan <mikek@symbian.org>
parents: 0
diff changeset
   266
	char const *afileName = iParameterListInterface->E32Input(); 
0
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   267
	E32ImageFile *aE32Imagefile=new E32ImageFile();
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   268
	TInt result = aE32Imagefile->Open(afileName);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   269
	
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   270
	if (result > 0)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   271
		return 1;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   272
	else if (result == KErrCorrupt || result == KErrNotSupported)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   273
	{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   274
		throw InvalidE32ImageError(INVALIDE32IMAGEERROR, (char *)afileName);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   275
	}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   276
	else if (result != 0)
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   277
	{
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   278
		throw FileError(FILEREADERROR, (char *)afileName);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   279
	}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   280
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   281
	int dumpOptions=iParameterListInterface->DumpOptions();
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   282
	
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   283
	aE32Imagefile->Dump((TText*)afileName, dumpOptions);
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   284
	delete aE32Imagefile;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   285
	return KErrNone;
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   286
}
044383f39525 Convert Build package from SFL to EPL
Alex Gilkes <alex.gilkes@nokia.com>
parents:
diff changeset
   287