toolsandutils/e32tools/rombuild/r_rom.h
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 // Copyright (c) 1995-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 //
       
    15 
       
    16 #ifndef __R_ROM_H__
       
    17 #define __R_ROM_H__
       
    18 
       
    19 #include "e32image.h"
       
    20 #include <e32rom.h>
       
    21 
       
    22 #if defined(__MSVCDOTNET__) || defined(__TOOLS2__)
       
    23 #include <fstream>
       
    24 #else //!__MSVCDOTNET__
       
    25 #include <fstream.h>
       
    26 #endif //__MSVCDOTNET__
       
    27 
       
    28 #include "h_utl.h"
       
    29 #include "r_mromimage.h"
       
    30 #include <malloc.h>
       
    31 
       
    32 
       
    33 //
       
    34 const TUint KRomWrapperSize = 0x100;
       
    35 const TUint KRomNameSize = 16;
       
    36 //
       
    37 const TUint KOverrideStack = 0x01;
       
    38 const TUint KOverrideHeapMin = 0x02;
       
    39 const TUint KOverrideHeapMax = 0x04;
       
    40 const TUint KOverrideAddress = 0x08;
       
    41 const TUint KOverrideUid1 = 0x10;
       
    42 const TUint KOverrideUid2 = 0x20;
       
    43 const TUint KOverrideUid3 = 0x40;
       
    44 const TUint KOverrideCallEntryPoint = 0x80;
       
    45 const TUint KOverrideNoCallEntryPoint = 0x100;
       
    46 const TUint KOverridePriority = 0x200;
       
    47 const TUint KOverrideStackReserve = 0x400;
       
    48 const TUint KOverrideKeepIAT = 0x800;
       
    49 const TUint KOverrideCapability = 0x1000;
       
    50 const TUint KOverrideCodeUnpaged = 0x2000;
       
    51 const TUint KOverrideCodePaged = 0x4000;
       
    52 const TUint KOverrideDataUnpaged = 0x8000;
       
    53 const TUint KOverrideDataPaged = 0x10000;
       
    54 const TUint KOverrideHCRData = 0x20000 ;
       
    55 
       
    56 enum TKernelModel {ESingleKernel, EMultipleKernels};
       
    57 enum TMemModel {E_MM_Moving, E_MM_Direct, E_MM_Multiple, E_MM_Flexible};
       
    58 
       
    59 const TUint KVariantIndependent = 0x01000000;
       
    60 
       
    61 extern TInt CompareCapabilities(const TUint32* aSubCaps, const TUint32* aSuperCaps, const char* aSubName, const char* aSuperName);
       
    62 
       
    63 class THardwareVariant
       
    64 	{
       
    65 public:
       
    66 	enum THardwareVariantOrder
       
    67 		{
       
    68 		EUnordered=0,
       
    69 		ELess=1,
       
    70 		EEqual=2,
       
    71 		EGreater=4,
       
    72 		};
       
    73 public:
       
    74 	THardwareVariant() {iVariant=KVariantIndependent;}
       
    75 	THardwareVariant(TUint aVariant) {iVariant=aVariant;}
       
    76 	operator TUint() const {return iVariant;}
       
    77 	TBool MutuallyExclusive(THardwareVariant aHardwareVariant) const;
       
    78 	TInt Compare(THardwareVariant aHardwareVariant) const;
       
    79 	TBool operator<(THardwareVariant a) const { return ((Compare(a)&ELess)!=0); }
       
    80 	TBool operator==(THardwareVariant a) const { return ((Compare(a)&EEqual)!=0); }
       
    81 	TBool operator>(THardwareVariant a) const { return ((Compare(a)&EGreater)!=0); }
       
    82 	TBool operator<=(THardwareVariant a) const { return ((Compare(a)&(ELess|EEqual))!=0); }
       
    83 	TBool operator>=(THardwareVariant a) const { return ((Compare(a)&(EGreater|EEqual))!=0); }
       
    84 	TBool IsIndependent() const {return Layer()<=3;}
       
    85 	TBool IsCpu() const {return Parent()==3; }
       
    86 	TBool IsVariant() const;
       
    87 	TUint32 ReturnVariant() const {return iVariant;} 
       
    88 	TUint Layer() const {return iVariant>>24;}
       
    89 	TUint Parent() const {return (iVariant>>16)&0xff;}
       
    90 	TUint VMask() const {return iVariant&0xffff;}
       
    91 private:
       
    92 	TUint32 iVariant;
       
    93 	};
       
    94 
       
    95 class TRomLoad
       
    96 	{
       
    97 public:
       
    98 	TText name[KRomNameSize];
       
    99 	TText versionStr[4];
       
   100 	TText buildNumStr[4];
       
   101 	TUint romSize;
       
   102 	TUint wrapSize;
       
   103 	};
       
   104 //
       
   105 
       
   106 // representation of a relocation record for areas.
       
   107 class TReloc
       
   108 	{
       
   109 public:
       
   110 	TInt iLength;
       
   111 	TUint iSrc;
       
   112 	TUint iDest;
       
   113 	};
       
   114 
       
   115 // thing for tracking the various addresses at which to find something
       
   116 
       
   117 class TAddressRange
       
   118 	{
       
   119 public:
       
   120 	TAddressRange();
       
   121 
       
   122 	void Append(TAddressRange& aRange);
       
   123 	void Extend(TInt aOffset);
       
   124 	void Move(TInt aOffset);
       
   125 
       
   126 public:
       
   127 	TAny*	iImagePtr;			// data in the ROM image buffer
       
   128 	TUint32	iImageAddr;			// address in the ROM image 
       
   129 	TUint32 iRunAddr;			// runtime address, usually the same as the iImageAddr
       
   130 	TUint   iSize;				// size of this section
       
   131 	};
       
   132 
       
   133 
       
   134 class TImageSection : public TAddressRange
       
   135 	{
       
   136 public:
       
   137 	TImageSection() : TAddressRange(), iFilePtr(0) {}
       
   138 
       
   139 	TAny* iFilePtr;		// original data in the E32Image file
       
   140 
       
   141 	void Load() const;	// copy the file data into the image, if needed
       
   142 	};
       
   143 
       
   144 //
       
   145 const TUint KFillSize = KRomWrapperSize-sizeof(TRomLoad);
       
   146 class CObeyFile;
       
   147 class TRomLoaderHeader
       
   148 	{
       
   149 public:
       
   150 	void SetUp(CObeyFile *aObey);
       
   151 private:
       
   152 	TRomLoad r;
       
   153 	TUint8 filler[KFillSize];
       
   154 	};
       
   155 //
       
   156 class TRomBuilderEntry;
       
   157 class TRomNode;
       
   158 class TRomFile;
       
   159 class TDllFindInfo
       
   160 	{
       
   161 public:
       
   162 	TDllFindInfo(const char* aImportName, const TRomBuilderEntry* aEntry);
       
   163 	~TDllFindInfo();
       
   164 public:
       
   165 	const char* iBareName;		// filename+extension to find, not including path UID or version
       
   166 	TUint32 iUid3;				// requested UID3 - 0 if don't care
       
   167 	TUint32 iModuleVersion;		// requested version
       
   168 	TUint32 iHwVariant;			// requested hardware variant
       
   169 	};
       
   170 
       
   171 class TAutoFree
       
   172 	{
       
   173 public:
       
   174 	TAutoFree(void* aPtr) {iPtr=aPtr;}
       
   175 	~TAutoFree() {free(iPtr);}
       
   176 private:
       
   177 	void* iPtr;
       
   178 	};
       
   179 
       
   180 #define AUTO_FREE(p)	TAutoFree _auto_free_##p(p)
       
   181 
       
   182 class TModuleName
       
   183 	{
       
   184 public:
       
   185 	TModuleName(const TRomBuilderEntry* aEntry);
       
   186 	TModuleName(const TDllFindInfo& aInfo);
       
   187 	TModuleName(const TRomNode& aNode);
       
   188 	TModuleName(const TRomFile& aFile, const TRomNode* aRootDir);
       
   189 	~TModuleName();
       
   190 	operator const char* () {return iName;}
       
   191 private:
       
   192 	char* iName;
       
   193 	};
       
   194 
       
   195 // class representing a file (or directory) in the ROM
       
   196 class TRomFile
       
   197 	{
       
   198 public:
       
   199 	TRomFile();
       
   200 	~TRomFile();
       
   201 	TInt AddressFromOrdinal(TLinAddr& aEDataAddr,TLinAddr& aExport, TUint aOrdinal);
       
   202 	void Finalise(TInt aSize);
       
   203 
       
   204 	void Close() { if (--iRefCount<=0) delete this; };
       
   205 	void Open() {iRefCount++; };
       
   206 
       
   207 	TInt MarkDeps();
       
   208 	TInt FindRouteTo(TRomFile* aDest, TRomFile** aStack, TInt aIndex);
       
   209 	TRomEntry* RomEntry() const {return iRomEntry;}
       
   210 	void SetRomEntry(TRomEntry* aEntry);
       
   211 
       
   212 	TAddressRange iAddresses;
       
   213 
       
   214 	inline TRomImageHeader* RomImgHdr() const
       
   215 		{return (TRomImageHeader*)iAddresses.iImagePtr;}
       
   216 
       
   217 	TAddressRange iExportDir;
       
   218 	TRomBuilderEntry* iRbEntry;	// only until Layout stage
       
   219 	TBool iDir;
       
   220 	TBool iFinal;
       
   221 	THardwareVariant iHwvd;
       
   222 	TRomEntry* iRomEntry;		// in ROM image buffer
       
   223 	friend class FileEntry;
       
   224 
       
   225 	TInt iDataBssOffsetInExe;	// for allocating DLL data in process data section
       
   226 
       
   227 	// dependence graph
       
   228 	TInt iNumDeps;
       
   229 	TRomFile** iDeps;
       
   230 	TInt iNumPDeps;
       
   231 	TRomFile** iPDeps;
       
   232 	TInt iMark;
       
   233 	TRomFile* iAttachProcess;
       
   234 	TInt iTotalDataBss;
       
   235 
       
   236 	// Data used when computing SMP properties.
       
   237 	struct TSmpInfo
       
   238 		{
       
   239 		TSmpInfo() : isInit(0), isActive(0), isSafe(0) {}
       
   240 		bool isInit;
       
   241 		bool isActive;
       
   242 		bool isSafe;
       
   243 		} iSmpInfo;
       
   244 
       
   245 	bool ComputeSmpSafe(const TRomBuilderEntry*);
       
   246 public:
       
   247 	TUint32 Uid3() const;
       
   248 	TUint32 ModuleVersion() const;
       
   249 	THardwareVariant HardwareVariant() const;
       
   250 	TUint32 ABI() const;
       
   251 	TInt ExportDirCount() const;
       
   252 	TUint32 RomImageFlags() const;
       
   253 	TLinAddr DataBssLinearBase() const;
       
   254 	const SSecurityInfo& SecurityInfo() const;
       
   255 private:
       
   256 	TInt iRefCount;
       
   257 	};
       
   258 //
       
   259 class TRomBuilderEntry;
       
   260 class RomFileStructure;
       
   261 
       
   262 // class representing a directory entry in the ROM file system
       
   263 class TRomNode
       
   264 	{
       
   265 public:
       
   266 	TRomNode(const TText* aName, TRomBuilderEntry* aEntry=0);
       
   267 	TRomNode(const TText* aName, TRomNode* aNode);
       
   268 private:
       
   269 	TRomNode(const TRomNode& aNode);
       
   270 public:
       
   271 	~TRomNode();
       
   272 	void Destroy();
       
   273 
       
   274 	TInt SetAtt(TText *anAttWord);
       
   275 	TInt NameCpy(char* aDest); // returns the length of aDest (in UTF-16 characters for Unicode, not bytes)
       
   276 	TInt SetBareName();
       
   277 
       
   278 	TRomNode* NewSubDir(const TText* aName);
       
   279 	void AddFile(TRomNode *aChild);
       
   280 	TInt Rename(TRomNode *aOldParent, TRomNode* aNewParent, TText* aNewName);
       
   281 	TRomNode* FindInDirectory(const TText* aName);
       
   282 	TRomNode* FindInDirectory(const TText* aName, THardwareVariant aVariant , TBool aPatchDataFlag=FALSE);
       
   283 
       
   284 	TRomEntry* RomEntry() const {return iRomFile->RomEntry();}
       
   285 	void Finalise(TInt aSize);
       
   286 
       
   287 	void CountDirectory(TInt& aFileCount, TInt& aDirCount);
       
   288 	TInt ProcessDirectory(RomFileStructure* aRFS);
       
   289 
       
   290 	static void AddExecutableFile(TRomNode*& aLast, TRomNode* aNode);
       
   291 	TRomNode* FindImageFileByName(const TDllFindInfo& aInfo, TBool aPrintDiag, TBool& aFallBack);
       
   292 	TInt CheckForVersionConflicts(const TRomBuilderEntry* a);
       
   293 
       
   294 	TRomNode* CopyDirectory(TRomNode*& aLastExecutable, TRomNode* aParent);
       
   295 	TInt Alias(TRomNode* aNode, TRomNode*& aLastExecutable);
       
   296 public:
       
   297 	char* BareName() const;
       
   298 	TUint32 Uid3() const;
       
   299 	TUint32 ModuleVersion() const;
       
   300 	THardwareVariant HardwareVariant() const;
       
   301 	TUint32 ABI() const;
       
   302 	TInt FullNameLength(TBool aIgnoreHiddenAttrib = EFalse) const;
       
   303 	TInt GetFullName(char* aBuf, TBool aIgnoreHiddenAttrib = EFalse) const;
       
   304 
       
   305 	void Add(TRomNode* aChild);
       
   306 	void Remove(TRomNode* aChild);
       
   307 
       
   308 	static TInt Count;			// seed for unique identifiers
       
   309 
       
   310 	TRomNode* iSibling;
       
   311 	TRomNode* iChild;
       
   312 	TRomNode* iParent;
       
   313 	TRomNode* iNextExecutable;
       
   314 
       
   315 protected:
       
   316 	TInt iIdentifier;
       
   317 	friend class FileEntry;
       
   318 
       
   319 public:
       
   320 	TRomFile* iRomFile;
       
   321 	TText* iName;
       
   322 	char* iBareName;		// name including extension but without UID or version
       
   323 	TUint8 iAtt;
       
   324 	TBool iHidden;
       
   325 	};
       
   326 
       
   327 class E32Rom;
       
   328 class Area;
       
   329 class TRomBuilderEntry : public E32ImageFile
       
   330 	{
       
   331 public:
       
   332 	TRomBuilderEntry(const char *aFileName, TText *aName);
       
   333 	~TRomBuilderEntry();
       
   334 	TInt SetCodeAlignment(TText *aStr);
       
   335 	TInt SetDataAlignment(TText *aStr);
       
   336 	TInt SetRelocationAddress(TText *aStr);
       
   337 	TInt SetStackReserve(TText *aStr);
       
   338 	TInt SetStackSize(TText *aStr);
       
   339 	TInt SetHeapSizeMin(TText *aStr);
       
   340 	TInt SetHeapSizeMax(TText *aStr);
       
   341 	TInt SetCapability(TText *aStr);
       
   342 	TInt SetUid1(TText *aStr);
       
   343 	TInt SetUid2(TText *aStr);
       
   344 	TInt SetUid3(TText *aStr);
       
   345 	TInt SetCallEntryPoint(TBool aState);
       
   346 	TInt SetPriority(TText *aStr);
       
   347 	TInt SetAttachProcess(TText *aStr);
       
   348 	TInt OpenImageFile();
       
   349 	TInt SizeInRom();
       
   350 	void SizeInSections(TInt& aSize1, TInt& aSize2);
       
   351 	void LoadToRom();
       
   352 	TInt FixupImports(E32Rom& aRom);
       
   353 	TInt ResolveDllRefTable(E32Rom& aRom);
       
   354 	TInt BuildDependenceGraph(E32Rom& aRom);
       
   355 	TInt FindAttachProcess(E32Rom& aRom);
       
   356 	const char* GetDefaultAttachProcess();
       
   357 	void SetRomNode(TRomNode* aNode);
       
   358 	void FixupRomEntries(TInt aSize);
       
   359 	TRomEntry* RomEntry() const {return iRomNode->RomEntry(); };
       
   360 	void DisplaySize(TPrintType aWhere);
       
   361 public:
       
   362 	inline TBool Primary() const
       
   363 		{return iRomImageFlags & KRomImageFlagPrimary;}
       
   364 	inline TBool Variant() const
       
   365 		{return iRomImageFlags & KRomImageFlagVariant;}
       
   366 	inline TBool Extension() const
       
   367 		{return iRomImageFlags & KRomImageFlagExtension;}
       
   368 	inline TBool Device() const
       
   369 		{return iRomImageFlags & KRomImageFlagDevice;}
       
   370 	inline TBool Secondary() const
       
   371 		{return iRomImageFlags & KRomImageFlagSecondary;}
       
   372 	inline TBool HCRDataFile() const 
       
   373 		{ return iOverrideFlags & KOverrideHCRData ;}
       
   374 private:
       
   375 	TRomBuilderEntry();
       
   376 	TRomBuilderEntry(const TRomBuilderEntry&);
       
   377 	const TRomBuilderEntry& operator=(const TRomBuilderEntry &);
       
   378 	void Relocate();
       
   379 public:
       
   380 	TText *iName;
       
   381 	TBool iResource;
       
   382 	TBool iNonXIP;
       
   383 	TBool iPreferred;
       
   384 	TUint iCompression;
       
   385 	TBool iPatched;
       
   386 	Area* iArea;
       
   387 	TInt  iRomSectionNumber;
       
   388 	TUint iOverrideFlags;
       
   389 	TUint32 iRelocationAddress;
       
   390 	TInt iAlignment;
       
   391 	TInt iCodeAlignment;
       
   392 	TInt iDataAlignment;
       
   393 	TInt iStackSize;
       
   394 	TInt iHeapSizeMin;
       
   395 	TInt iHeapSizeMax;
       
   396 	TProcessPriority iPriority;
       
   397 	TUint iUid1;
       
   398 	TUint iUid2;
       
   399 	TUint iUid3;
       
   400 	TLinAddr iDataBssLinearBase;
       
   401 	SSecurityInfo iS;
       
   402 	char* iBareName;			// EPOC name+extension but without path or version
       
   403 	TUint32 iVersionInName;
       
   404 	TUint32 iVersionPresentInName;
       
   405 
       
   406 	THardwareVariant iHardwareVariant;
       
   407 	TUint iDataBssOffset;
       
   408 	TInt iStackReserve;
       
   409 
       
   410 	TRomImageHeader* iRomImageHeader;
       
   411 
       
   412 	TAddressRange iHeaderRange;
       
   413 	TImageSection iCodeSection;
       
   414 	TImageSection iImportAddressTableSection;
       
   415 	TImageSection iExportDirSection;
       
   416 	TImageSection iDataSection;
       
   417 	TAddressRange iDllRefTableRange;
       
   418 
       
   419 	TLinAddr**  iIATRefs;	// image addresses of pointers to IAT
       
   420 
       
   421 	TRomBuilderEntry* iNext;
       
   422 	TRomBuilderEntry* iNextInArea;
       
   423 
       
   424 	TUint32 iRomImageFlags;
       
   425 	TText* iProcessName;
       
   426 
       
   427 	// Used by the collapse routines
       
   428 	TInt iImportCount;
       
   429 	TUint32 iImportBlockStartAddress;
       
   430 	TUint32 iImportBlockEndAddress;
       
   431 	TRomNode *iRomNode;
       
   432 	};
       
   433 //
       
   434 class ImpTRomHeader	: public TRomHeader
       
   435 	{
       
   436 public:
       
   437 	void Display();
       
   438 	void SetUp(CObeyFile *aObey);
       
   439 	void CheckSum(TUint32 aTargetValue);
       
   440 	};
       
   441 //
       
   442 class COrderedFileList
       
   443 	{
       
   444 public:
       
   445 	static COrderedFileList* New(TInt aMaxFiles);
       
   446 	~COrderedFileList();
       
   447 	void Add(TRomBuilderEntry* anEntry);
       
   448 	TInt Count() {return iCount;}
       
   449 	TRomBuilderEntry* operator[](TInt anIndex) {return iOrderedFiles[anIndex];}
       
   450 private:
       
   451 	COrderedFileList(TInt aMaxFiles);
       
   452 private:
       
   453 	TInt iCount;
       
   454 	TInt iMaxFiles;
       
   455 	TRomBuilderEntry **iOrderedFiles;
       
   456 	};
       
   457 //
       
   458 class CObeyFile;
       
   459 class Area;
       
   460 class Memmap;
       
   461 class E32Rom : public MRomImage
       
   462 	{
       
   463 public:
       
   464 	E32Rom(CObeyFile *aObey);
       
   465 	~E32Rom();
       
   466 	TInt Create();
       
   467 	TInt CreateExtension(MRomImage* aKernelRom);
       
   468 	TInt Align(TInt aVal);
       
   469 	void DisplaySizes(TPrintType aWhere);
       
   470 	TInt WriteImages(TInt aHeaderType);
       
   471 	TInt Compare(char* anImage, TInt aHeaderType);
       
   472 	//
       
   473 	//
       
   474 	char *RomToActualAddress(TUint aPtr);
       
   475 	TUint ActualToRomAddress(TAny *aPtr);
       
   476 	void Display(TRomImageHeader *aHdr);
       
   477 	TRomNode* FindImageFileByName(const TDllFindInfo& aInfo, TBool aPrintDiag, TBool& aFallBack);
       
   478 	TInt CheckForVersionConflicts(const TRomBuilderEntry* a);
       
   479 	TRomNode* CopyDirectory(TRomNode*& aLastExecutable);
       
   480 
       
   481 	TRomNode* RootDirectory();
       
   482 	TText* RomFileName();
       
   483 	TUint32 RomBase();
       
   484 	TUint32 RomSize();
       
   485 	TVersion Version();
       
   486 	TInt64 Time();
       
   487 	TUint32 CheckSum();
       
   488 	TUint32 DataRunAddress();
       
   489 	TUint32 RomAlign();
       
   490 
       
   491 private:
       
   492 	void CalculateDataAddresses();
       
   493 	void CalculateDataAddress(TRomBuilderEntry *aFile);
       
   494 	char *LayoutRom(char *anAddr);
       
   495 	char *ReserveRomExceptionSearchTable(char *anAddr, TRomExceptionSearchTable*& exceptionSearchTable);
       
   496 	void ConstructRomExceptionSearchTable(TRomExceptionSearchTable* exceptionSearchTable);
       
   497 	void LayoutFile(TRomBuilderEntry*, TAddressRange& aMain, TAddressRange* aSecond, CBytePair* aBPE);
       
   498 	void NextRom(TAddressRange* aFirst, TAddressRange* aSecond);
       
   499 	TInt TranslateFiles();
       
   500 	void EnumerateVariants();
       
   501 	TUint32 AlignToChunk(TUint32 anAddr);
       
   502 	TUint32 AlignToPage(TUint32 anAddr);
       
   503 	TUint32 AllocVirtual(TUint32 aAddr,TUint aSize);
       
   504 	TInt LoadDataToRom(TRomBuilderEntry *aFile, TAddressRange& aAddress, CBytePair* aBPE);
       
   505 	void LoadFileToRom(TRomBuilderEntry *aFile);
       
   506 
       
   507 	void Write(ofstream &of, TInt aHeaderType);		// main ROM image
       
   508 	void WriteOdd(ofstream &of);					// odd halfwords
       
   509 	void WriteEven(ofstream &of);					// even halfwords
       
   510 	void WriteSRecord(ofstream &of);				// SREC or S19 format
       
   511 
       
   512 	TInt LoadContents(char*& anAddr, TRomHeader* aHeader);
       
   513 	TInt BuildDependenceGraph();
       
   514 	TInt ResolveDllRefTables();
       
   515 	TInt ResolveImports();
       
   516 	TInt CreateExportDirectory();
       
   517 	char *WriteDirectory(char *aAddr, TRomHeader* aHeader);
       
   518 	TInt WriteHeadersToRom(char *anAddr);
       
   519 	TInt RequiredSize();
       
   520 	void SetCompressionInfo(TUint aCompressionType, TUint aCompressedSize, TUint aUncompressedSize);
       
   521 	void FinaliseSectionHeader();
       
   522 	void FinaliseExtensionHeader(MRomImage* aKernelRom);
       
   523 	void DisplayExtensionHeader();
       
   524 	void SetImageAddr(TAddressRange& aSet, TAny* aPtr, TUint32 aRunOffset=0);
       
   525 	void SetImageAddr(TAddressRange& aSet, TUint aAddr, TUint32 aRunOffset=0);
       
   526 	TInt CollapseImportThunks();
       
   527 	TInt CollapseImportThunks(TRomBuilderEntry* aFile);
       
   528 	TInt CollapseBranches();
       
   529 	TInt CollapseBranches(TRomBuilderEntry* aFile);
       
   530 	TUint32 FindFinalJumpDestination(TUint32 ja);
       
   531 
       
   532 	char* AllocateRelocationTable(char* aAddr, TReloc*& aRelocTable);
       
   533 	void FillInRelocationTable(TReloc* aRelocTable);
       
   534 
       
   535 	void LinkKernelExtensions(TRomBuilderEntry* aExtArray[], TInt aExtCount);
       
   536 	void FillInCrcs();
       
   537 	void ProcessDllData();
       
   538 
       
   539 	void CreatePageIndex(char*& aAddr);
       
   540 	TInt CompressPages();
       
   541 	TInt CompressPage(SRomPageInfo& aPageInfo, TInt aOutOffset, CBytePair * aBPE);
       
   542 
       
   543 	// dependence graph
       
   544 	void UnmarkGraph(TInt aMark=0xffffffff);
       
   545 	void FindMarked(TInt aMarkMask, TInt aMark, TRomFile**& aList);
       
   546 	TInt ProcessDependencies();
       
   547 	void ListRouteTo(TRomFile* aStart, TRomFile* aDest, TInt aNDeps);
       
   548 
       
   549 	void SetSmpFlags();
       
   550 	
       
   551 	// Check if the unpaged memory size overflows. For page enabled ROM only.
       
   552 	TInt CheckUnpagedMemSize();
       
   553 	
       
   554 	// Initialize the page info prior to compression
       
   555 	TInt SetupPages();
       
   556 
       
   557 	Memmap *iImageMap;
       
   558 public:
       
   559 	char* iData;
       
   560 	TInt iSize;
       
   561 	TRomLoaderHeader *iLoaderHeader;
       
   562 	TRomHeader *iHeader;
       
   563 	TExtensionRomHeader *iExtensionRomHeader;		// NULL if not extension ROM
       
   564 	//
       
   565 	CObeyFile *iObey;
       
   566 
       
   567 	char *iSectionPtr;
       
   568 	
       
   569 	//
       
   570 	TInt iSizeUsed;
       
   571 	TInt iUncompressedSize;
       
   572 	TInt iOverhead;
       
   573 	TInt iDirectorySize;
       
   574 	TInt iImportsFixedUp;
       
   575 	TInt iBranchesFixedUp;
       
   576 	TInt iVtableEntriesFixedUp;
       
   577 	//
       
   578 	TUint32 iNextDataChunkBase;
       
   579 	TUint32 iTotalSvDataSize;
       
   580 	TUint32 iNextDllDataAddr;
       
   581 	char* iPrevPrimaryAddress;
       
   582 	char* iPrevVariantAddress;
       
   583 	COrderedFileList** iVariantFileLists;
       
   584 	TRomBuilderEntry** iPeFiles;
       
   585 	};
       
   586 
       
   587 
       
   588 #endif