e32tools/elf2e32/source/pl_elfproducer.h
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implementation of the Class ElfProducer for the elf2e32 tool
       
    15 // @internalComponent
       
    16 // @released
       
    17 // 
       
    18 //
       
    19 
       
    20 #if !defined(_PL_ELFPRODUCER_H_)
       
    21 #define _PL_ELFPRODUCER_H_
       
    22 
       
    23 #include "pl_elfexecutable.h"
       
    24 #include <string>
       
    25 
       
    26 //enum for section index
       
    27 typedef enum _SECTION_INDEX_ {
       
    28 	DUMMY_SECTION=0,
       
    29 	CODE_SECTION,
       
    30 	DYNAMIC_SECTION,
       
    31 	HASH_TBL_SECTION,
       
    32 	VER_DEF_SECTION,
       
    33 	VERSION_SECTION,
       
    34 	STRING_SECTION,
       
    35 	SYMBOL_SECTION,
       
    36 	SH_STR_SECTION,
       
    37 	MAX_SECTIONS=SH_STR_SECTION
       
    38 }SECTION_INDEX;
       
    39 
       
    40 //enum for DYN entries
       
    41 typedef enum _DYN_ENTRIES_ {
       
    42 	DSO_DT_DSONAME=0,
       
    43 	DSO_DT_SYMTAB,
       
    44 	DSO_DT_SYMENT,
       
    45 	DSO_DT_STRTAB,
       
    46 	DSO_DT_STRSZ,
       
    47 	DSO_DT_VERSYM,
       
    48 	DSO_DT_VERDEF,
       
    49 	DSO_DT_VERDEFNUM,
       
    50 	DSO_DT_HASH,
       
    51 	DSO_DT_NULL,
       
    52 	MAX_DYN_ENTS=DSO_DT_NULL,
       
    53 }DYN_ENTRIES;
       
    54 
       
    55 #define DEFAULT_VERSION	2
       
    56 /**
       
    57 This class provides elf contents for the dso file creation. It generates the
       
    58 elf header, sections, dynamic array and the relocatrion entries.
       
    59 @internalComponent
       
    60 @released
       
    61 */
       
    62 class ElfProducer : public ElfExecutable
       
    63 {
       
    64 
       
    65 	typedef std::list<Symbol*> SymbolList;
       
    66 public:
       
    67 	ElfProducer(ParameterListInterface *aParameterListInterface);
       
    68 	~ElfProducer();
       
    69 	
       
    70 	void SetSymbolList(SymbolList& aSymbolList);
       
    71 	void WriteElfFile(char* aDsoFullName,char* aDsoFileName, char* aLinkAs);
       
    72 
       
    73 private:
       
    74 	/**
       
    75 	 * This list is passed from the UseCaseHandler via the DSOHandler to this class.
       
    76 	 * This is used to create the export info when only a def file is available and
       
    77 	 * the DSO needs to be generated for that.
       
    78 	 */
       
    79 	typedef std::string	String;
       
    80 	/** The proxy DSO file name*/
       
    81 	String			iDSOName;
       
    82 
       
    83 	/** The offset of the file name within the string table of the ELF file*/
       
    84 	PLUINT32		iDSONameOffset;
       
    85 
       
    86 	/** The DLL name that defines the export Symbols*/
       
    87 	String			iLinkAs;
       
    88 
       
    89 	/** The offset of the DLL name within the string table within the ELF file*/
       
    90 	PLUINT32		iLinkAsOffset;
       
    91 
       
    92 	/** The export Symbol list*/
       
    93 	SymbolList		*iSymbolsList;
       
    94 
       
    95 	/** The number of export Symbols*/
       
    96 	PLUINT32		iNSymbols;
       
    97 
       
    98 	/** The proxy DSO full file name*/
       
    99 	String			iDsoFullName;
       
   100 
       
   101 	/*DSO content Fields*/
       
   102 
       
   103 	/** The Elf version definition auxiliary section*/
       
   104 	Elf32_Verdaux	*iDSODaux;
       
   105 
       
   106 	/** The Buckets for the hash table*/
       
   107 	Elf32_Sword		*iDSOBuckets;
       
   108 
       
   109 	/** The chains pointed to by the buckets belonging to the hash table*/
       
   110 	Elf32_Sword		*iDSOChains;
       
   111 
       
   112 	/** The Elf Dynamic section table*/
       
   113 	Elf32_Dyn		iDSODynTbl[MAX_DYN_ENTS+1];
       
   114 
       
   115 	/** The code section*/
       
   116 	PLUINT32		*iCodeSectionData;
       
   117 
       
   118 	/** The Elf file offset maintained for writing the different sections of the Elf file*/
       
   119 	PLUINT32		iElfFileOffset;
       
   120 
       
   121 	/** The Elf String table*/
       
   122 	String			iDSOSymNameStrTbl;
       
   123 
       
   124 	/** The Elf Section-header String table*/
       
   125 	String			iDSOSectionNames;
       
   126 
       
   127 
       
   128 	void InitElfContents();
       
   129 	void Cleanup();
       
   130 	void SetSymolFields(Symbol *aSym, Elf32_Sym* aElfSym, PLUINT32 aIndex);
       
   131 	void AddToHashTable(const char* aSymName, PLUINT32 aIndex);
       
   132 	void CreateVersionTable();
       
   133 	void CreateElfHeader();
       
   134 	void CreateSections();
       
   135 	void SetSectionFields(PLUINT32 aSectionIndex, char* aSectionName, PLUINT32 aType, \
       
   136 								   PLUINT32 aEntSz, PLUINT32 aSectionSize, PLUINT32 aLink, \
       
   137 								   PLUINT32 aInfo, PLUINT32 aAddrAlign, PLUINT32 aFlags, \
       
   138 								   PLUINT32 aAddr);
       
   139 	void CreateDynamicEntries();
       
   140 	void CreateProgHeader();
       
   141 
       
   142 	void WriteElfContents();
       
   143 	void AlignString(String& aStr);
       
   144 
       
   145 };
       
   146 
       
   147 
       
   148 
       
   149 
       
   150 #endif // !defined(_PL_ELFPRODUCER_H_)