e32tools/elf2e32/source/pl_elfrelocation.cpp
author Mike Kinghan <mikek@symbian.org>
Thu, 25 Nov 2010 13:59:07 +0000
changeset 40 68f68128601f
parent 2 39c28ec933dd
permissions -rwxr-xr-x
1) Add the sbsv1 components from sftools/dev/build to make the linux_build package independent of the obsolete buildtools package. 2) Enhance romnibus.pl so that it generate the symbol file for the built rom when invoked by Raptor 3) Make the maksym.pl tool portable for Linux as well as Windows. 4) Remove the of armasm2as.pl from the e32tools component in favour of the copy now exported from sbsv1/e32util.

// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// Implementation of the Class ElfRelocation for the elf2e32 tool
// @internalComponent
// @released
// 
//

#include "pl_elfrelocation.h"
#include "pl_elfimportrelocation.h"
#include "pl_elflocalrelocation.h"
#include "pl_dllsymbol.h"

/**
Constructor for class ElfRelocation
@param aElfExec - Instance of class ELfExecutable
@param aAddr
@param aAddend
@param aIndex
@param aRelType - Relocation type
@param aRel
@internalComponent
@released
*/
ElfRelocation::ElfRelocation(ElfExecutable *aElfExec, PLMemAddr32 aAddr, \
			PLUINT32 aAddend, PLUINT32 aIndex, PLUCHAR aRelType, \
			Elf32_Rel* aRel) : iAddr(aAddr), iAddend(aAddend), \
			iSymNdx(aIndex), iRelType(aRelType), iRel(aRel),  iElfExec(aElfExec)
{
}



/**
Destructor for class ElfRelocation
@internalComponent
@released
*/
ElfRelocation::~ElfRelocation(){

}


/**
Function to create new relocation entry
@param aElfExec - Instance of class ElfExecutable
@param aAddr    - location where the relocation refers to.
@param aAddend  - addend for the relocation entry
@param aIndex   - symbol index
@param aRelType - Relocation type
@param aRel     - Elf relocation entry
@param aImportRel - Import relocation
@internalComponent
@released
*/
ElfRelocation* ElfRelocation::NewRelocEntry(ElfExecutable *aElfExec, PLMemAddr32 aAddr, \
				PLUINT32 aAddend, PLUINT32 aIndex, PLUCHAR aRelType, \
				void* aRel, bool aImportRel)
{
	ElfRelocation	*aReloc = NULL;
	if(aImportRel)
		aReloc = new ElfImportRelocation(aElfExec, aAddr, aAddend, aIndex, aRelType, (Elf32_Rel*)aRel);
	else
		aReloc = new ElfLocalRelocation(aElfExec, aAddr, aAddend, aIndex, aRelType, (Elf32_Rel*)aRel);

	return aReloc;
}


/**
This function verifies if the relocation entry is required to be
handled by the postlinker.
@param aType - type of relocation
@return - True if valid relocation type, otherwise false
@internalComponent
@released
*/
bool ElfRelocation::ValidRelocEntry(PLUCHAR aType) {
	
	switch(aType)
	{
	case R_ARM_ABS32:
	case R_ARM_GLOB_DAT:
	case R_ARM_JUMP_SLOT:
	case R_ARM_RELATIVE:
	case R_ARM_GOT_BREL:
		return true;
	case R_ARM_NONE:
		return false;
	default:
		return false;
	}
}