First public contribution.
1 // Copyright (c) 2006-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\dll\t_oeexport.cpp
16 // Tests it is possible to retrieve the 0th ordinal from exes and dlls
17 // that are marked as having named symbol export data. This is loaded
18 // as non-XIP so loader fixups of 0th ordinal imports can be tested
22 // - Test reading 0th ordinal from a dll which has a E32EpocExpSymInfoHdr
23 // struct at the 0th ordinal and verify the contents of the header
24 // - Test attempts to get the 0th ordinal from a dll without the named symbol
26 // - Test reading the named symbol data from an exe that contains a
27 // E32EpocExpSymInfoHdr struct at the 0th ordinal and verify the contents
28 // - Test import fixups has correctly fixed up the 0th ordinal of the static
29 // dependencies to this stdexe
30 // - Test NULL is returned when attempting to read the 0th ordinal of
31 // an exe that doesn't contain a E32EpocExpSymInfoHdr
32 // Platforms/Drives/Compatibility:
34 // Assumptions/Requirement/Pre-requisites:
35 // Failures and causes:
36 // Base Port information:
45 RTest test(_L("T_OEEXPORT"));
47 // This is defined as LOCAL_D(static) to ensure that tools allow static symbol in stdexe/dlls
48 // as this was not always the case.
49 LOCAL_D void VerifyHdr(E32EpocExpSymInfoHdr& aExpectedHdr, E32EpocExpSymInfoHdr &aReadHdr)
51 test(aExpectedHdr.iSize == aReadHdr.iSize);
52 test(aExpectedHdr.iFlags == aReadHdr.iFlags);
53 test(aExpectedHdr.iSymCount == aReadHdr.iSymCount);
54 test(aExpectedHdr.iSymbolTblOffset == aReadHdr.iSymbolTblOffset);
55 test(aExpectedHdr.iStringTableSz == aReadHdr.iStringTableSz);
56 test(aExpectedHdr.iStringTableOffset == aReadHdr.iStringTableOffset);
57 test(aExpectedHdr.iDllCount == aReadHdr.iDllCount);
58 test(aExpectedHdr.iDepDllZeroOrdTableOffset == aReadHdr.iDepDllZeroOrdTableOffset);
65 test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));
67 E32EpocExpSymInfoHdr tmpHdr;
68 E32EpocExpSymInfoHdr *readHdr;
71 // The values for the header of the dll with a 0th ordinal
74 tmpHdr.iSymCount = 0xc;
75 tmpHdr.iSymbolTblOffset = 0x1c;
76 tmpHdr.iStringTableSz = 0x134;
77 tmpHdr.iStringTableOffset = 0x64;
78 tmpHdr.iDllCount = 0x3;
79 tmpHdr.iDepDllZeroOrdTableOffset = 0x198;
80 test(library.Load(_L("t_oedll.dll")) == KErrNone);
81 test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));
82 readHdr = (E32EpocExpSymInfoHdr*)library.Lookup(0);
84 test.Next(_L("Verify export data of t_oedll.dll at the 0th ordinal is that expected"));
85 VerifyHdr(tmpHdr, *readHdr);
88 test.Next(_L("Verify lookup on dll without oe export data returns NULL"));
89 test(library.Load(_L("t_dll1.dll")) == KErrNone);
90 readHdr = (E32EpocExpSymInfoHdr*)library.Lookup(0);
91 test(readHdr == NULL);
94 // The values for the header of the exe of the current process with a 0th ordinal
97 tmpHdr.iSymCount = 0x2;
98 tmpHdr.iSymbolTblOffset = 0x1c;
99 tmpHdr.iStringTableSz = 0x14;
100 tmpHdr.iStringTableOffset = 0x28;
101 tmpHdr.iDllCount = 0x3;
102 tmpHdr.iDepDllZeroOrdTableOffset = 0x3c;
103 test.Next(_L("Attempt to retrieve named symbol data from current process"));
104 readHdr = (E32EpocExpSymInfoHdr*)(RProcess::ExeExportData());
106 test.Next(_L("Verify export data at th 0th ordinal of this exe is that expected"));
108 //#define PRINT_ZEROTH
110 test.Printf(_L("iSize=%08x;iFlags=%08x;iSymCount=%08x;iSymbolTblOffset=%08x\n"),readHdr->iSize,readHdr->iFlags,readHdr->iSymCount,readHdr->iSymbolTblOffset);
111 test.Printf(_L("iStringTableSz=%08x,iStringTableOffset=%08x,iDllCount=%08x,iDepDllZeroOrdTableOffset=%08x\n"), readHdr->iStringTableSz, readHdr->iStringTableOffset,readHdr->iDllCount,readHdr->iDepDllZeroOrdTableOffset);
113 VerifyHdr(tmpHdr, *readHdr);
115 test.Next(_L("Verify static dependency t_oedll1 has been fixed up correctly"));
116 test(myfoo()==0x1234);
118 // Get the 0th ordinal data from the dependency t_oedll1 and verify it
119 readHdr=(E32EpocExpSymInfoHdr *)((TUint32)readHdr+readHdr->iDepDllZeroOrdTableOffset);
120 TUint32 readHdrEnd = (TUint32)readHdr + 12;
121 // This stdexe only links one stddll so the only non-NULL entry in iDepDllZeroOrdTable
122 // should point to 0th ordinal of t_oedll1
123 while (*(TUint32*)readHdr == NULL && (TUint32)readHdr < readHdrEnd)
125 readHdr=(E32EpocExpSymInfoHdr *)(((TUint32*)readHdr)+1);
129 test.Printf(_L("iSize=%08x;iFlags=%08x;iSymCount=%08x;iSymbolTblOffset=%08x\n"),(*(E32EpocExpSymInfoHdr**)readHdr)->iSize,(*(E32EpocExpSymInfoHdr**)readHdr)->iFlags,(*(E32EpocExpSymInfoHdr**)readHdr)->iSymCount,(*(E32EpocExpSymInfoHdr**)readHdr)->iSymbolTblOffset);
130 test.Printf(_L("iStringTableSz=%08x,iStringTableOffset=%08x,iDllCount=%08x,iDepDllZeroOrdTableOffset=%08x\n"), (*(E32EpocExpSymInfoHdr**)readHdr)->iStringTableSz, (*(E32EpocExpSymInfoHdr**)readHdr)->iStringTableOffset,(*(E32EpocExpSymInfoHdr**)readHdr)->iDllCount,(*(E32EpocExpSymInfoHdr**)readHdr)->iDepDllZeroOrdTableOffset);
133 tmpHdr.iSize = 0x1a4;
135 tmpHdr.iSymCount = 0xc;
136 tmpHdr.iSymbolTblOffset = 0x1c;
137 tmpHdr.iStringTableSz = 0x134;
138 tmpHdr.iStringTableOffset = 0x64;
139 tmpHdr.iDllCount = 0x3;
140 tmpHdr.iDepDllZeroOrdTableOffset = 0x198;
141 VerifyHdr(tmpHdr,**(E32EpocExpSymInfoHdr**)readHdr);