|
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 // |
|
15 |
|
16 #include "elffilesupplied.h" |
|
17 #include "pl_elfexecutable.h" |
|
18 #include "errorhandler.h" |
|
19 #include "pl_dso_handler.h" |
|
20 #include "deffile.h" |
|
21 #include "pl_elfexports.h" |
|
22 #include "pl_dllsymbol.h" |
|
23 #include "elf2e32.h" |
|
24 #include "staticlibsymbols.h" |
|
25 |
|
26 #include <algorithm> |
|
27 #include <iostream> |
|
28 #if __GNUC__ < 4 |
|
29 #include <ext/hash_set> |
|
30 #define SET_TYPE __gnu_cxx::hash_set |
|
31 #define HASH_FUN __gnu_cxx::hash |
|
32 #else |
|
33 #include <unordered_set> |
|
34 #define SET_TYPE std::unordered_set |
|
35 #define HASH_FUN std::hash |
|
36 #endif |
|
37 |
|
38 using namespace std; |
|
39 |
|
40 /** |
|
41 Constructor for class ElfFileSupplied to initialize members and create instance of class DSOHandler |
|
42 @param aParameterListInterface - Instance of class ParameterListInterface |
|
43 @internalComponent |
|
44 @released |
|
45 */ |
|
46 ElfFileSupplied::ElfFileSupplied(ParameterListInterface* aParameterListInterface) : UseCaseBase(aParameterListInterface) , |
|
47 iNumAbsentExports(-1),iExportBitMap(NULL),iE32ImageFile(NULL), iElfExecutable(NULL), \ |
|
48 iExportDescSize(0), iExportDescType(0) |
|
49 { |
|
50 iElfIfc = new DSOHandler(aParameterListInterface); |
|
51 } |
|
52 |
|
53 /** |
|
54 Destructor for class ElfFileSupplied to release allocated memory |
|
55 @internalComponent |
|
56 @released |
|
57 */ |
|
58 ElfFileSupplied::~ElfFileSupplied() |
|
59 { |
|
60 iSymList.clear(); |
|
61 delete iElfIfc; |
|
62 delete [] iExportBitMap; |
|
63 } |
|
64 |
|
65 /** |
|
66 Execute Function for the Elf File Supplied use case |
|
67 @return 0 on success |
|
68 @internalComponent |
|
69 @released |
|
70 */ |
|
71 int ElfFileSupplied::Execute() |
|
72 { |
|
73 ReadElfFile(); |
|
74 iElfIfc->ProcessElfFile(); |
|
75 try |
|
76 { |
|
77 ProcessExports(); |
|
78 } |
|
79 catch(SymbolMissingFromElfError& aSme) |
|
80 { |
|
81 /* Only DEF file would be generated if symbols found in |
|
82 * DEF file are missing from the ELF file. |
|
83 */ |
|
84 WriteDefFile(); |
|
85 throw aSme; |
|
86 } |
|
87 GenerateOutput(); |
|
88 return 0; |
|
89 } |
|
90 |
|
91 /** |
|
92 Function to read ELF File |
|
93 @internalComponent |
|
94 @released |
|
95 */ |
|
96 void ElfFileSupplied::ReadElfFile() |
|
97 { |
|
98 char * aElfFileName = UseCaseBase::InputElfFileName(); |
|
99 |
|
100 iElfIfc->ReadElfFile(aElfFileName); |
|
101 iElfExecutable = iElfIfc->ElfExecutableP(); |
|
102 } |
|
103 |
|
104 /** |
|
105 Function to process exports |
|
106 @internalComponent |
|
107 @released |
|
108 */ |
|
109 void ElfFileSupplied::ProcessExports() |
|
110 { |
|
111 ValidateExports(NULL); |
|
112 CreateExports(); |
|
113 } |
|
114 |
|
115 /** |
|
116 Function to write DEF File |
|
117 @internalComponent |
|
118 @released |
|
119 */ |
|
120 void ElfFileSupplied::WriteDefFile() |
|
121 { |
|
122 char * aDEFFileName = UseCaseBase::DefOutput(); |
|
123 DefFile deffile; |
|
124 |
|
125 deffile.WriteDefFile(aDEFFileName, &iSymList); |
|
126 } |
|
127 |
|
128 /** |
|
129 Function to create exports |
|
130 @internalComponent |
|
131 @released |
|
132 */ |
|
133 void ElfFileSupplied::CreateExports() |
|
134 { |
|
135 if (iElfExecutable->iExports || GetNamedSymLookup()) |
|
136 { |
|
137 CreateExportTable(); |
|
138 CreateExportBitMap(); |
|
139 } |
|
140 } |
|
141 |
|
142 /** |
|
143 Function to validate exports |
|
144 @param aDefExports - List of export symbols from Def file and/or sysdef. |
|
145 @internalComponent |
|
146 @released |
|
147 */ |
|
148 void ElfFileSupplied::ValidateExports(SymbolList *aDefExports) |
|
149 { |
|
150 /** |
|
151 * Symbols from DEF file (DEF_Symbols) => Valid_DEF + Absent |
|
152 * Symbols from ELF file (ELF_Symbols) => Existing + NEW |
|
153 * 1. if the set {Valid_DEF - ELF_Symbols} is non-empty then, symbols are missing |
|
154 * from Elf and it is an error if the mode is UNFROZEN |
|
155 * 2. if the intersection set {Absent,ELF_Symbols} is non-empty, absent symbols |
|
156 * are exported from Elf..warn for this |
|
157 * 3. if the set {ELF_Symbols - Valid_DEF} is non-empty, these are the NEW symbols |
|
158 * 4. if there are symbols marked absent in DEF file but exported in ELF, |
|
159 * add them into the new list retaining the ordinal number as of the |
|
160 * absent symbol(using PtrELFExportNameCompareUpdateOrdinal). |
|
161 **/ |
|
162 |
|
163 PLUINT32 aMaxOrdinal = 0; |
|
164 int len = strlen("_ZTI"); |
|
165 |
|
166 typedef SymbolList::iterator Iterator; |
|
167 |
|
168 Iterator aPos, aEnd; |
|
169 |
|
170 //SymbolList *aDefExports, aDefValidExports, aDefAbsentExports, aElfExports; |
|
171 SymbolList aDefValidExports, aDefAbsentExports, aElfExports; |
|
172 |
|
173 //aDefExports = iDefIfc->GetSymbolEntryList(); |
|
174 if (aDefExports) |
|
175 { |
|
176 aPos = aDefExports->begin(); |
|
177 aEnd = aDefExports->end(); |
|
178 |
|
179 while(aPos != aEnd) |
|
180 { |
|
181 if( (*aPos)->Absent() ){ |
|
182 aDefAbsentExports.insert(aDefAbsentExports.end(), *aPos); |
|
183 } |
|
184 else { |
|
185 aDefValidExports.insert(aDefValidExports.end(), *aPos); |
|
186 } |
|
187 |
|
188 if( aMaxOrdinal < (*aPos)->OrdNum() ){ |
|
189 aMaxOrdinal = (*aPos)->OrdNum(); |
|
190 } |
|
191 aPos++; |
|
192 } |
|
193 } |
|
194 |
|
195 iSymList = aDefValidExports; |
|
196 |
|
197 if (iElfIfc->ElfExecutableP()->iExports) |
|
198 iElfIfc->GetElfExportSymbolList( aElfExports ); |
|
199 else if (!aDefExports) |
|
200 return; |
|
201 |
|
202 // REVISIT - return back if elfexports and defexports is NULL |
|
203 |
|
204 aDefValidExports.sort(ElfExports::PtrELFExportNameCompare()); |
|
205 aElfExports.sort(ElfExports::PtrELFExportNameCompare()); |
|
206 |
|
207 aDefAbsentExports.sort(ElfExports::PtrELFExportNameCompare()); |
|
208 |
|
209 //Check for Case 1... {Valid_DEF - ELF_Symbols} |
|
210 { |
|
211 SymbolList aResult(aDefValidExports.size()); |
|
212 Iterator aResultPos = aResult.begin(); |
|
213 |
|
214 Iterator aMissingListEnd = set_difference(aDefValidExports.begin(), aDefValidExports.end(), \ |
|
215 aElfExports.begin(), aElfExports.end(), aResultPos, ElfExports::PtrELFExportNameCompareUpdateAttributes()); |
|
216 |
|
217 std::list<String> aMissingSymNameList; |
|
218 while (aResultPos != aMissingListEnd) { |
|
219 // {Valid_DEF - ELF_Symbols} is non empty |
|
220 (*aResultPos)->SetSymbolStatus(Missing); // Set the symbol Status as Missing |
|
221 aMissingSymNameList.push_back((*aResultPos)->SymbolName()); |
|
222 aResultPos++; |
|
223 //throw error |
|
224 } |
|
225 if( aMissingSymNameList.size() ) { |
|
226 if (!Unfrozen()) |
|
227 throw SymbolMissingFromElfError(SYMBOLMISSINGFROMELFERROR, aMissingSymNameList, UseCaseBase::InputElfFileName()); |
|
228 else |
|
229 cout << "Elf2e32: Warning: " << aMissingSymNameList.size() << " Frozen Export(s) missing from the ELF file" << endl; |
|
230 } |
|
231 } |
|
232 |
|
233 //Check for Case 2... intersection set {Absent,ELF_Symbols} |
|
234 { |
|
235 if(aDefAbsentExports.size()) |
|
236 { |
|
237 SymbolList aResult(aDefAbsentExports.size()); |
|
238 Iterator aResultPos = aResult.begin(); |
|
239 |
|
240 Iterator aAbsentListEnd = set_intersection(aDefAbsentExports.begin(), aDefAbsentExports.end(), \ |
|
241 aElfExports.begin(), aElfExports.end(), aResultPos, ElfExports::PtrELFExportNameCompareUpdateAttributes()); |
|
242 |
|
243 while( aResultPos != aAbsentListEnd ) |
|
244 { |
|
245 // intersection set {Absent,ELF_Symbols} is non-empty |
|
246 // Ignore the non callable exports |
|
247 if ((strncmp("_ZTI", (*aResultPos)->SymbolName(), len)) && |
|
248 (strncmp("_ZTV", (*aResultPos)->SymbolName(), len))) |
|
249 { |
|
250 iSymList.insert(iSymList.end(), *aResultPos); |
|
251 cout << "Elf2e32: Warning: Symbol " << (*aResultPos)->SymbolName() << " absent in the DEF file, but present in the ELF file" << endl; |
|
252 } |
|
253 aResultPos++; |
|
254 } |
|
255 } |
|
256 } |
|
257 |
|
258 //Do 3 |
|
259 { |
|
260 SymbolList aResult(aElfExports.size()); |
|
261 Iterator aResultPos = aResult.begin(); |
|
262 |
|
263 Iterator aNewListEnd = set_difference(aElfExports.begin(), aElfExports.end(), \ |
|
264 aDefValidExports.begin(), aDefValidExports.end(), aResultPos, ElfExports::PtrELFExportNameCompare()); |
|
265 |
|
266 bool aIgnoreNonCallable = GetIgnoreNonCallable(); |
|
267 bool aIsCustomDll = IsCustomDllTarget(); |
|
268 bool aExcludeUnwantedExports = ExcludeUnwantedExports(); |
|
269 |
|
270 while( aResultPos != aNewListEnd ) |
|
271 { |
|
272 |
|
273 if( !(*aResultPos)->Absent() ) |
|
274 { |
|
275 /* For a custom dll and for option "--excludeunwantedexports", the new exports should be filtered, |
|
276 * so that only the exports from the frozen DEF file are considered. |
|
277 */ |
|
278 if ((aIsCustomDll || aExcludeUnwantedExports) && UnWantedSymbolp((*aResultPos)->SymbolName())) |
|
279 { |
|
280 iElfExecutable->iExports->ExportsFilteredP(true); |
|
281 iElfExecutable->iExports->iFilteredExports.insert(iElfExecutable->iExports->iFilteredExports.end(),(DllSymbol *)(*aResultPos)); |
|
282 aResultPos++; |
|
283 continue; |
|
284 } |
|
285 if (aIgnoreNonCallable) |
|
286 { |
|
287 // Ignore the non callable exports |
|
288 if ((!strncmp("_ZTI", (*aResultPos)->SymbolName(), len)) || |
|
289 (!strncmp("_ZTV", (*aResultPos)->SymbolName(), len))) |
|
290 { |
|
291 iElfExecutable->iExports->ExportsFilteredP(true); |
|
292 iElfExecutable->iExports->iFilteredExports.insert(iElfExecutable->iExports->iFilteredExports.end(),(DllSymbol *)(*aResultPos)); |
|
293 aResultPos++; |
|
294 continue; |
|
295 } |
|
296 } |
|
297 (*aResultPos)->SetOrdinal( ++aMaxOrdinal ); |
|
298 (*aResultPos)->SetSymbolStatus(New); // Set the symbol Status as NEW |
|
299 iSymList.insert(iSymList.end(), *aResultPos); |
|
300 if(WarnForNewExports()) |
|
301 cout << "Elf2e32: Warning: New Symbol " << (*aResultPos)->SymbolName() << " found, export(s) not yet Frozen" << endl; |
|
302 } |
|
303 aResultPos++; |
|
304 } |
|
305 } |
|
306 |
|
307 //Do 4 |
|
308 { |
|
309 if(aDefAbsentExports.size()) |
|
310 { |
|
311 SymbolList aResult(aDefAbsentExports.size()); |
|
312 Iterator aResultPos = aResult.begin(); |
|
313 |
|
314 Iterator aAbsentListEnd = set_difference(aDefAbsentExports.begin(), aDefAbsentExports.end(), \ |
|
315 aElfExports.begin(), aElfExports.end(), aResultPos, ElfExports::PtrELFExportNameCompareUpdateAttributes()); |
|
316 |
|
317 DllSymbol *aSymbol; |
|
318 bool aAbsent = true; |
|
319 while( aResultPos != aAbsentListEnd ) { |
|
320 //aElfExports.insert(aElfExports.end(), *aResultPos); |
|
321 aSymbol = new DllSymbol( *aResultPos, SymbolTypeCode, aAbsent); |
|
322 iElfExecutable->iExports->Add(iElfExecutable->iSOName, aSymbol); |
|
323 //aElfExports.insert(aElfExports.end(), (Symbol*)aSymbol); |
|
324 iSymList.insert(iSymList.end(), (Symbol*)aSymbol); |
|
325 aResultPos++; |
|
326 } |
|
327 aElfExports.sort(ElfExports::PtrELFExportOrdinalCompare()); |
|
328 iSymList.sort(ElfExports::PtrELFExportOrdinalCompare()); |
|
329 } |
|
330 } |
|
331 |
|
332 if(iElfExecutable->iExports && iElfExecutable->iExports->ExportsFilteredP() ) { |
|
333 iElfExecutable->iExports->FilterExports(); |
|
334 } |
|
335 |
|
336 aElfExports.clear(); |
|
337 aDefAbsentExports.clear(); |
|
338 aDefValidExports.clear(); |
|
339 |
|
340 } |
|
341 |
|
342 /** |
|
343 Function to generate output which is E32 Image file, DEF File and DSO file, if |
|
344 exports are available. |
|
345 @internalComponent |
|
346 @released |
|
347 */ |
|
348 void ElfFileSupplied::GenerateOutput() |
|
349 { |
|
350 if (iElfExecutable->iExports) |
|
351 { |
|
352 Elf2E32::ValidateDSOGeneration(iParameterListInterface, ETargetTypeNotSet); |
|
353 WriteDefFile(); |
|
354 WriteDSOFile(); |
|
355 } |
|
356 Elf2E32::ValidateE32ImageGeneration(iParameterListInterface, ETargetTypeNotSet); |
|
357 WriteE32(); |
|
358 } |
|
359 |
|
360 /** |
|
361 Function to write DSO file. |
|
362 @internalComponent |
|
363 @released |
|
364 */ |
|
365 void ElfFileSupplied::WriteDSOFile() |
|
366 { |
|
367 char * aLinkAs = UseCaseBase::LinkAsDLLName(); |
|
368 char * aDSOName = UseCaseBase::DSOOutput(); |
|
369 char * aDSOFileName = UseCaseBase::FileName(aDSOName); |
|
370 |
|
371 iElfIfc->WriteElfFile( aDSOName, aDSOFileName, aLinkAs, iSymList ); |
|
372 } |
|
373 |
|
374 /** |
|
375 Function to write E32 Image file. |
|
376 @internalComponent |
|
377 @released |
|
378 */ |
|
379 void ElfFileSupplied::WriteE32() |
|
380 { |
|
381 |
|
382 const char * aE32FileName = OutputE32FileName(); |
|
383 |
|
384 iE32ImageFile = new E32ImageFile(aE32FileName, iElfExecutable, this); |
|
385 |
|
386 try |
|
387 { |
|
388 iE32ImageFile->GenerateE32Image(); |
|
389 |
|
390 if (iE32ImageFile->WriteImage(aE32FileName)) |
|
391 { |
|
392 //GetELF2E32()->AddFileCleanup(aE32FileName); |
|
393 delete iE32ImageFile; |
|
394 } |
|
395 } |
|
396 catch (...) |
|
397 { |
|
398 delete iE32ImageFile; |
|
399 throw; |
|
400 } |
|
401 } |
|
402 |
|
403 /** |
|
404 Function to check image is Dll or not. |
|
405 @return True if image is Dll, otherwise false. |
|
406 @internalComponent |
|
407 @released |
|
408 */ |
|
409 bool ElfFileSupplied::ImageIsDll() |
|
410 { |
|
411 return (iElfExecutable->LookupStaticSymbol("_E32Dll") != NULL); |
|
412 } |
|
413 |
|
414 /** |
|
415 Function to allocate E32 Image header. |
|
416 @return pointer to E32ImageHeaderV |
|
417 @internalComponent |
|
418 @released |
|
419 */ |
|
420 E32ImageHeaderV * ElfFileSupplied::AllocateE32ImageHeader() |
|
421 { |
|
422 if (iNumAbsentExports == 0) |
|
423 { |
|
424 return new E32ImageHeaderV; |
|
425 } |
|
426 |
|
427 int nexp = GetNumExports(); |
|
428 size_t memsz = (nexp + 7) >> 3; // size of complete bitmap |
|
429 size_t mbs = (memsz + 7) >> 3; // size of meta-bitmap |
|
430 size_t nbytes = 0; |
|
431 PLUINT32 i; |
|
432 for (i=0; i<memsz; ++i) |
|
433 if (iExportBitMap[i] != 0xff) |
|
434 ++nbytes; // number of groups of 8 |
|
435 PLUINT8 edt = KImageHdr_ExpD_FullBitmap; |
|
436 PLUINT32 extra_space = memsz - 1; |
|
437 if (mbs + nbytes < memsz) |
|
438 { |
|
439 edt = KImageHdr_ExpD_SparseBitmap8; |
|
440 extra_space = mbs + nbytes - 1; |
|
441 } |
|
442 extra_space = (extra_space + sizeof(PLUINT32) - 1) &~ (sizeof(PLUINT32) - 1); |
|
443 size_t aExtendedHeaderSize = sizeof(E32ImageHeaderV) + extra_space; |
|
444 iE32ImageFile->SetExtendedE32ImageHeaderSize(aExtendedHeaderSize); |
|
445 E32ImageHeaderV * aHdr = (E32ImageHeaderV *)new PLUINT8[aExtendedHeaderSize]; |
|
446 |
|
447 iExportDescType = edt; |
|
448 if (edt == KImageHdr_ExpD_FullBitmap) |
|
449 { |
|
450 iExportDescSize = (PLUINT16)memsz; |
|
451 memcpy(aHdr->iExportDesc, iExportBitMap, memsz); |
|
452 } |
|
453 else |
|
454 { |
|
455 iExportDescSize = (PLUINT16) (mbs + nbytes); |
|
456 memset(aHdr->iExportDesc, 0, extra_space + 1); |
|
457 PLUINT8* mptr = aHdr->iExportDesc; |
|
458 PLUINT8* gptr = mptr + mbs; |
|
459 for (i=0; i<memsz; ++i) |
|
460 { |
|
461 if (iExportBitMap[i] != 0xff) |
|
462 { |
|
463 mptr[i>>3] |= (1u << (i&7)); |
|
464 *gptr++ = iExportBitMap[i]; |
|
465 } |
|
466 } |
|
467 } |
|
468 return aHdr; |
|
469 } |
|
470 |
|
471 /** |
|
472 Function to create export table |
|
473 @internalComponent |
|
474 @released |
|
475 */ |
|
476 void ElfFileSupplied::CreateExportTable() |
|
477 { |
|
478 ElfExports::ExportList aList; |
|
479 |
|
480 if(iElfExecutable->iExports) |
|
481 aList = iElfExecutable->GetExportsInOrdinalOrder(); |
|
482 |
|
483 iExportTable.CreateExportTable(iElfExecutable, aList); |
|
484 } |
|
485 |
|
486 /** |
|
487 Function to create export bitmap |
|
488 @internalComponent |
|
489 @released |
|
490 */ |
|
491 void ElfFileSupplied::CreateExportBitMap() |
|
492 { |
|
493 int nexp = GetNumExports(); |
|
494 size_t memsz = (nexp + 7) >> 3; |
|
495 iExportBitMap = new PLUINT8[memsz]; |
|
496 memset(iExportBitMap, 0xff, memsz); |
|
497 // skip header |
|
498 PLUINT32 * exports = ((PLUINT32 *)GetExportTable()) + 1; |
|
499 PLUINT32 absentVal = iElfExecutable->EntryPointOffset() + iElfExecutable->GetROBase(); |
|
500 iNumAbsentExports = 0; |
|
501 for (int i=0; i<nexp; ++i) |
|
502 { |
|
503 if (exports[i] == absentVal) |
|
504 { |
|
505 iExportBitMap[i>>3] &= ~(1u << (i & 7)); |
|
506 ++iNumAbsentExports; |
|
507 } |
|
508 } |
|
509 } |
|
510 |
|
511 /** |
|
512 Function to get number of exports |
|
513 @return Number of exports in export table |
|
514 @internalComponent |
|
515 @released |
|
516 */ |
|
517 size_t ElfFileSupplied::GetNumExports() |
|
518 { |
|
519 return iExportTable.GetNumExports(); |
|
520 } |
|
521 |
|
522 /** |
|
523 Function to check export table is required. |
|
524 @return True for E32 image if allocation requires space for export table. |
|
525 @internalComponent |
|
526 @released |
|
527 */ |
|
528 bool ElfFileSupplied::AllocateExportTableP() |
|
529 { |
|
530 return iExportTable.AllocateP(); |
|
531 } |
|
532 |
|
533 /** |
|
534 Function to get export table |
|
535 @return Pointer to export table |
|
536 @internalComponent |
|
537 @released |
|
538 */ |
|
539 char * ElfFileSupplied::GetExportTable() |
|
540 { |
|
541 return (char *)iExportTable.GetExportTable(); |
|
542 } |
|
543 |
|
544 /** |
|
545 Function to get export table size |
|
546 @return size of export table |
|
547 @internalComponent |
|
548 @released |
|
549 */ |
|
550 size_t ElfFileSupplied::GetExportTableSize() |
|
551 { |
|
552 return iExportTable.GetExportTableSize(); |
|
553 } |
|
554 |
|
555 /** |
|
556 Function to get export table Virtual address |
|
557 @return the export table VA |
|
558 @internalComponent |
|
559 @released |
|
560 */ |
|
561 size_t ElfFileSupplied::GetExportTableAddress() |
|
562 { |
|
563 return iExportTable.iExportTableAddress; |
|
564 } |
|
565 |
|
566 /** |
|
567 Function to get export offset |
|
568 @return size of export offset |
|
569 @internalComponent |
|
570 @released |
|
571 */ |
|
572 size_t ElfFileSupplied::GetExportOffset() |
|
573 { |
|
574 return iE32ImageFile->GetExportOffset(); |
|
575 } |
|
576 |
|
577 /** |
|
578 Function to get symbol type based on the encoded names. |
|
579 @return CODE or DATA |
|
580 @internalComponent |
|
581 @released |
|
582 */ |
|
583 SymbolType ElfFileSupplied::SymbolTypeF(char * aName) |
|
584 { |
|
585 size_t prefixLength = strlen("_ZTV"); |
|
586 bool classImpedimenta = false; |
|
587 classImpedimenta = !strncmp(aName, "_ZTV", prefixLength) || |
|
588 !strncmp(aName, "_ZTI", prefixLength) || |
|
589 !strncmp(aName, "_ZTS", prefixLength) ; |
|
590 |
|
591 return classImpedimenta? SymbolTypeData : SymbolTypeCode; |
|
592 } |
|
593 |
|
594 /** |
|
595 Function to get export description size |
|
596 @return export description size |
|
597 @internalComponent |
|
598 @released |
|
599 */ |
|
600 PLUINT16 ElfFileSupplied::GetExportDescSize() |
|
601 { |
|
602 return iExportDescSize; |
|
603 } |
|
604 |
|
605 /** |
|
606 Function to get export description type |
|
607 @return export description type |
|
608 @internalComponent |
|
609 @released |
|
610 */ |
|
611 PLUINT8 ElfFileSupplied::GetExportDescType() |
|
612 { |
|
613 return iExportDescType; |
|
614 } |
|
615 |
|
616 /** |
|
617 Function to indicate if the new exports are to be reported as warnings. |
|
618 @return export description type |
|
619 @internalComponent |
|
620 @released |
|
621 */ |
|
622 bool ElfFileSupplied::WarnForNewExports() |
|
623 { |
|
624 return true; |
|
625 } |
|
626 |
|
627 /** |
|
628 To check if the two strings are equal |
|
629 @internalComponent |
|
630 @released |
|
631 */ |
|
632 struct eqstr |
|
633 { |
|
634 bool operator()(const char* s1, const char* s2) const |
|
635 { |
|
636 return strcmp(s1, s2) == 0; |
|
637 } |
|
638 }; |
|
639 |
|
640 /** |
|
641 Function to provide a predicate which checks whether a symbol name is unwanted: |
|
642 @return 1 if new symbols are present in the static library list else return 0 |
|
643 @param aSymbol symbols to be checked if part of static lib |
|
644 @internalComponent |
|
645 @released |
|
646 */ |
|
647 int ElfFileSupplied::UnWantedSymbolp(const char * aSymbol) |
|
648 { |
|
649 static SET_TYPE<const char*, HASH_FUN<const char*>, eqstr> aSymbolSet; |
|
650 int symbollistsize=sizeof(Unwantedruntimesymbols)/sizeof(Unwantedruntimesymbols[0]); |
|
651 static bool FLAG=false; |
|
652 while(!FLAG) |
|
653 { |
|
654 for(int i=0;i<symbollistsize;i++) |
|
655 { |
|
656 aSymbolSet.insert(Unwantedruntimesymbols[i]); |
|
657 } |
|
658 FLAG=true; |
|
659 } |
|
660 SET_TYPE<const char*, HASH_FUN<const char*>, eqstr>::const_iterator it |
|
661 = aSymbolSet.find(aSymbol); |
|
662 if(it != aSymbolSet.end()) |
|
663 return 1; |
|
664 else |
|
665 return 0; |
|
666 } |
|
667 |