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