|
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 // Ignore the non callable exports |
|
239 if ((strncmp("_ZTI", (*aResultPos)->SymbolName(), len)) && |
|
240 (strncmp("_ZTV", (*aResultPos)->SymbolName(), len))) |
|
241 { |
|
242 iSymList.insert(iSymList.end(), *aResultPos); |
|
243 cout << "Elf2e32: Warning: Symbol " << (*aResultPos)->SymbolName() << " absent in the DEF file, but present in the ELF file" << endl; |
|
244 } |
|
245 aResultPos++; |
|
246 } |
|
247 } |
|
248 } |
|
249 |
|
250 //Do 3 |
|
251 { |
|
252 SymbolList aResult(aElfExports.size()); |
|
253 Iterator aResultPos = aResult.begin(); |
|
254 |
|
255 Iterator aNewListEnd = set_difference(aElfExports.begin(), aElfExports.end(), \ |
|
256 aDefValidExports.begin(), aDefValidExports.end(), aResultPos, ElfExports::PtrELFExportNameCompare()); |
|
257 |
|
258 bool aIgnoreNonCallable = GetIgnoreNonCallable(); |
|
259 bool aIsCustomDll = IsCustomDllTarget(); |
|
260 bool aExcludeUnwantedExports = ExcludeUnwantedExports(); |
|
261 |
|
262 while( aResultPos != aNewListEnd ) |
|
263 { |
|
264 |
|
265 if( !(*aResultPos)->Absent() ) |
|
266 { |
|
267 /* For a custom dll and for option "--excludeunwantedexports", the new exports should be filtered, |
|
268 * so that only the exports from the frozen DEF file are considered. |
|
269 */ |
|
270 if ((aIsCustomDll || aExcludeUnwantedExports) && UnWantedSymbolp((*aResultPos)->SymbolName())) |
|
271 { |
|
272 iElfExecutable->iExports->ExportsFilteredP(true); |
|
273 iElfExecutable->iExports->iFilteredExports.insert(iElfExecutable->iExports->iFilteredExports.end(),(DllSymbol *)(*aResultPos)); |
|
274 aResultPos++; |
|
275 continue; |
|
276 } |
|
277 if (aIgnoreNonCallable) |
|
278 { |
|
279 // Ignore the non callable exports |
|
280 if ((!strncmp("_ZTI", (*aResultPos)->SymbolName(), len)) || |
|
281 (!strncmp("_ZTV", (*aResultPos)->SymbolName(), len))) |
|
282 { |
|
283 iElfExecutable->iExports->ExportsFilteredP(true); |
|
284 iElfExecutable->iExports->iFilteredExports.insert(iElfExecutable->iExports->iFilteredExports.end(),(DllSymbol *)(*aResultPos)); |
|
285 aResultPos++; |
|
286 continue; |
|
287 } |
|
288 } |
|
289 (*aResultPos)->SetOrdinal( ++aMaxOrdinal ); |
|
290 (*aResultPos)->SetSymbolStatus(New); // Set the symbol Status as NEW |
|
291 iSymList.insert(iSymList.end(), *aResultPos); |
|
292 if(WarnForNewExports()) |
|
293 cout << "Elf2e32: Warning: New Symbol " << (*aResultPos)->SymbolName() << " found, export(s) not yet Frozen" << endl; |
|
294 } |
|
295 aResultPos++; |
|
296 } |
|
297 } |
|
298 |
|
299 //Do 4 |
|
300 { |
|
301 if(aDefAbsentExports.size()) |
|
302 { |
|
303 SymbolList aResult(aDefAbsentExports.size()); |
|
304 Iterator aResultPos = aResult.begin(); |
|
305 |
|
306 Iterator aAbsentListEnd = set_difference(aDefAbsentExports.begin(), aDefAbsentExports.end(), \ |
|
307 aElfExports.begin(), aElfExports.end(), aResultPos, ElfExports::PtrELFExportNameCompareUpdateAttributes()); |
|
308 |
|
309 DllSymbol *aSymbol; |
|
310 bool aAbsent = true; |
|
311 while( aResultPos != aAbsentListEnd ) { |
|
312 //aElfExports.insert(aElfExports.end(), *aResultPos); |
|
313 aSymbol = new DllSymbol( *aResultPos, SymbolTypeCode, aAbsent); |
|
314 iElfExecutable->iExports->Add(iElfExecutable->iSOName, aSymbol); |
|
315 //aElfExports.insert(aElfExports.end(), (Symbol*)aSymbol); |
|
316 iSymList.insert(iSymList.end(), (Symbol*)aSymbol); |
|
317 aResultPos++; |
|
318 } |
|
319 aElfExports.sort(ElfExports::PtrELFExportOrdinalCompare()); |
|
320 iSymList.sort(ElfExports::PtrELFExportOrdinalCompare()); |
|
321 } |
|
322 } |
|
323 |
|
324 if(iElfExecutable->iExports && iElfExecutable->iExports->ExportsFilteredP() ) { |
|
325 iElfExecutable->iExports->FilterExports(); |
|
326 } |
|
327 |
|
328 aElfExports.clear(); |
|
329 aDefAbsentExports.clear(); |
|
330 aDefValidExports.clear(); |
|
331 |
|
332 } |
|
333 |
|
334 /** |
|
335 Function to generate output which is E32 Image file, DEF File and DSO file, if |
|
336 exports are available. |
|
337 @internalComponent |
|
338 @released |
|
339 */ |
|
340 void ElfFileSupplied::GenerateOutput() |
|
341 { |
|
342 if (iElfExecutable->iExports) |
|
343 { |
|
344 Elf2E32::ValidateDSOGeneration(iParameterListInterface, ETargetTypeNotSet); |
|
345 WriteDefFile(); |
|
346 WriteDSOFile(); |
|
347 } |
|
348 Elf2E32::ValidateE32ImageGeneration(iParameterListInterface, ETargetTypeNotSet); |
|
349 WriteE32(); |
|
350 } |
|
351 |
|
352 /** |
|
353 Function to write DSO file. |
|
354 @internalComponent |
|
355 @released |
|
356 */ |
|
357 void ElfFileSupplied::WriteDSOFile() |
|
358 { |
|
359 char * aLinkAs = UseCaseBase::LinkAsDLLName(); |
|
360 char * aDSOName = UseCaseBase::DSOOutput(); |
|
361 char * aDSOFileName = UseCaseBase::FileName(aDSOName); |
|
362 |
|
363 iElfIfc->WriteElfFile( aDSOName, aDSOFileName, aLinkAs, iSymList ); |
|
364 } |
|
365 |
|
366 /** |
|
367 Function to write E32 Image file. |
|
368 @internalComponent |
|
369 @released |
|
370 */ |
|
371 void ElfFileSupplied::WriteE32() |
|
372 { |
|
373 |
|
374 const char * aE32FileName = OutputE32FileName(); |
|
375 |
|
376 iE32ImageFile = new E32ImageFile(aE32FileName, iElfExecutable, this); |
|
377 |
|
378 try |
|
379 { |
|
380 iE32ImageFile->GenerateE32Image(); |
|
381 |
|
382 if (iE32ImageFile->WriteImage(aE32FileName)) |
|
383 { |
|
384 //GetELF2E32()->AddFileCleanup(aE32FileName); |
|
385 delete iE32ImageFile; |
|
386 } |
|
387 } |
|
388 catch (...) |
|
389 { |
|
390 delete iE32ImageFile; |
|
391 throw; |
|
392 } |
|
393 } |
|
394 |
|
395 /** |
|
396 Function to check image is Dll or not. |
|
397 @return True if image is Dll, otherwise false. |
|
398 @internalComponent |
|
399 @released |
|
400 */ |
|
401 bool ElfFileSupplied::ImageIsDll() |
|
402 { |
|
403 return (iElfExecutable->LookupStaticSymbol("_E32Dll") != NULL); |
|
404 } |
|
405 |
|
406 /** |
|
407 Function to allocate E32 Image header. |
|
408 @return pointer to E32ImageHeaderV |
|
409 @internalComponent |
|
410 @released |
|
411 */ |
|
412 E32ImageHeaderV * ElfFileSupplied::AllocateE32ImageHeader() |
|
413 { |
|
414 if (iNumAbsentExports == 0) |
|
415 { |
|
416 return new E32ImageHeaderV; |
|
417 } |
|
418 |
|
419 int nexp = GetNumExports(); |
|
420 size_t memsz = (nexp + 7) >> 3; // size of complete bitmap |
|
421 size_t mbs = (memsz + 7) >> 3; // size of meta-bitmap |
|
422 size_t nbytes = 0; |
|
423 PLUINT32 i; |
|
424 for (i=0; i<memsz; ++i) |
|
425 if (iExportBitMap[i] != 0xff) |
|
426 ++nbytes; // number of groups of 8 |
|
427 PLUINT8 edt = KImageHdr_ExpD_FullBitmap; |
|
428 PLUINT32 extra_space = memsz - 1; |
|
429 if (mbs + nbytes < memsz) |
|
430 { |
|
431 edt = KImageHdr_ExpD_SparseBitmap8; |
|
432 extra_space = mbs + nbytes - 1; |
|
433 } |
|
434 extra_space = (extra_space + sizeof(PLUINT32) - 1) &~ (sizeof(PLUINT32) - 1); |
|
435 size_t aExtendedHeaderSize = sizeof(E32ImageHeaderV) + extra_space; |
|
436 iE32ImageFile->SetExtendedE32ImageHeaderSize(aExtendedHeaderSize); |
|
437 E32ImageHeaderV * aHdr = (E32ImageHeaderV *)new PLUINT8[aExtendedHeaderSize]; |
|
438 |
|
439 iExportDescType = edt; |
|
440 if (edt == KImageHdr_ExpD_FullBitmap) |
|
441 { |
|
442 iExportDescSize = (PLUINT16)memsz; |
|
443 memcpy(aHdr->iExportDesc, iExportBitMap, memsz); |
|
444 } |
|
445 else |
|
446 { |
|
447 iExportDescSize = (PLUINT16) (mbs + nbytes); |
|
448 memset(aHdr->iExportDesc, 0, extra_space + 1); |
|
449 PLUINT8* mptr = aHdr->iExportDesc; |
|
450 PLUINT8* gptr = mptr + mbs; |
|
451 for (i=0; i<memsz; ++i) |
|
452 { |
|
453 if (iExportBitMap[i] != 0xff) |
|
454 { |
|
455 mptr[i>>3] |= (1u << (i&7)); |
|
456 *gptr++ = iExportBitMap[i]; |
|
457 } |
|
458 } |
|
459 } |
|
460 return aHdr; |
|
461 } |
|
462 |
|
463 /** |
|
464 Function to create export table |
|
465 @internalComponent |
|
466 @released |
|
467 */ |
|
468 void ElfFileSupplied::CreateExportTable() |
|
469 { |
|
470 ElfExports::ExportList aList; |
|
471 |
|
472 if(iElfExecutable->iExports) |
|
473 aList = iElfExecutable->GetExportsInOrdinalOrder(); |
|
474 |
|
475 iExportTable.CreateExportTable(iElfExecutable, aList); |
|
476 } |
|
477 |
|
478 /** |
|
479 Function to create export bitmap |
|
480 @internalComponent |
|
481 @released |
|
482 */ |
|
483 void ElfFileSupplied::CreateExportBitMap() |
|
484 { |
|
485 int nexp = GetNumExports(); |
|
486 size_t memsz = (nexp + 7) >> 3; |
|
487 iExportBitMap = new PLUINT8[memsz]; |
|
488 memset(iExportBitMap, 0xff, memsz); |
|
489 // skip header |
|
490 PLUINT32 * exports = ((PLUINT32 *)GetExportTable()) + 1; |
|
491 PLUINT32 absentVal = iElfExecutable->EntryPointOffset() + iElfExecutable->GetROBase(); |
|
492 iNumAbsentExports = 0; |
|
493 for (int i=0; i<nexp; ++i) |
|
494 { |
|
495 if (exports[i] == absentVal) |
|
496 { |
|
497 iExportBitMap[i>>3] &= ~(1u << (i & 7)); |
|
498 ++iNumAbsentExports; |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 /** |
|
504 Function to get number of exports |
|
505 @return Number of exports in export table |
|
506 @internalComponent |
|
507 @released |
|
508 */ |
|
509 size_t ElfFileSupplied::GetNumExports() |
|
510 { |
|
511 return iExportTable.GetNumExports(); |
|
512 } |
|
513 |
|
514 /** |
|
515 Function to check export table is required. |
|
516 @return True for E32 image if allocation requires space for export table. |
|
517 @internalComponent |
|
518 @released |
|
519 */ |
|
520 bool ElfFileSupplied::AllocateExportTableP() |
|
521 { |
|
522 return iExportTable.AllocateP(); |
|
523 } |
|
524 |
|
525 /** |
|
526 Function to get export table |
|
527 @return Pointer to export table |
|
528 @internalComponent |
|
529 @released |
|
530 */ |
|
531 char * ElfFileSupplied::GetExportTable() |
|
532 { |
|
533 return (char *)iExportTable.GetExportTable(); |
|
534 } |
|
535 |
|
536 /** |
|
537 Function to get export table size |
|
538 @return size of export table |
|
539 @internalComponent |
|
540 @released |
|
541 */ |
|
542 size_t ElfFileSupplied::GetExportTableSize() |
|
543 { |
|
544 return iExportTable.GetExportTableSize(); |
|
545 } |
|
546 |
|
547 /** |
|
548 Function to get export table Virtual address |
|
549 @return the export table VA |
|
550 @internalComponent |
|
551 @released |
|
552 */ |
|
553 size_t ElfFileSupplied::GetExportTableAddress() |
|
554 { |
|
555 return iExportTable.iExportTableAddress; |
|
556 } |
|
557 |
|
558 /** |
|
559 Function to get export offset |
|
560 @return size of export offset |
|
561 @internalComponent |
|
562 @released |
|
563 */ |
|
564 size_t ElfFileSupplied::GetExportOffset() |
|
565 { |
|
566 return iE32ImageFile->GetExportOffset(); |
|
567 } |
|
568 |
|
569 /** |
|
570 Function to get symbol type based on the encoded names. |
|
571 @return CODE or DATA |
|
572 @internalComponent |
|
573 @released |
|
574 */ |
|
575 SymbolType ElfFileSupplied::SymbolTypeF(char * aName) |
|
576 { |
|
577 size_t prefixLength = strlen("_ZTV"); |
|
578 bool classImpedimenta = false; |
|
579 classImpedimenta = !strncmp(aName, "_ZTV", prefixLength) || |
|
580 !strncmp(aName, "_ZTI", prefixLength) || |
|
581 !strncmp(aName, "_ZTS", prefixLength) ; |
|
582 |
|
583 return classImpedimenta? SymbolTypeData : SymbolTypeCode; |
|
584 } |
|
585 |
|
586 /** |
|
587 Function to get export description size |
|
588 @return export description size |
|
589 @internalComponent |
|
590 @released |
|
591 */ |
|
592 PLUINT16 ElfFileSupplied::GetExportDescSize() |
|
593 { |
|
594 return iExportDescSize; |
|
595 } |
|
596 |
|
597 /** |
|
598 Function to get export description type |
|
599 @return export description type |
|
600 @internalComponent |
|
601 @released |
|
602 */ |
|
603 PLUINT8 ElfFileSupplied::GetExportDescType() |
|
604 { |
|
605 return iExportDescType; |
|
606 } |
|
607 |
|
608 /** |
|
609 Function to indicate if the new exports are to be reported as warnings. |
|
610 @return export description type |
|
611 @internalComponent |
|
612 @released |
|
613 */ |
|
614 bool ElfFileSupplied::WarnForNewExports() |
|
615 { |
|
616 return true; |
|
617 } |
|
618 |
|
619 /** |
|
620 To check if the two strings are equal |
|
621 @internalComponent |
|
622 @released |
|
623 */ |
|
624 struct eqstr |
|
625 { |
|
626 bool operator()(const char* s1, const char* s2) const |
|
627 { |
|
628 return strcmp(s1, s2) == 0; |
|
629 } |
|
630 }; |
|
631 |
|
632 /** |
|
633 Function to provide a predicate which checks whether a symbol name is unwanted: |
|
634 @return 1 if new symbols are present in the static library list else return 0 |
|
635 @param aSymbol symbols to be checked if part of static lib |
|
636 @internalComponent |
|
637 @released |
|
638 */ |
|
639 int ElfFileSupplied::UnWantedSymbolp(const char * aSymbol) |
|
640 { |
|
641 static hash_set<const char*, hash<const char*>, eqstr> aSymbolSet; |
|
642 int symbollistsize=sizeof(Unwantedruntimesymbols)/sizeof(Unwantedruntimesymbols[0]); |
|
643 static bool FLAG=false; |
|
644 while(!FLAG) |
|
645 { |
|
646 for(int i=0;i<symbollistsize;i++) |
|
647 { |
|
648 aSymbolSet.insert(Unwantedruntimesymbols[i]); |
|
649 } |
|
650 FLAG=true; |
|
651 } |
|
652 hash_set<const char*, hash<const char*>, eqstr>::const_iterator it |
|
653 = aSymbolSet.find(aSymbol); |
|
654 if(it != aSymbolSet.end()) |
|
655 return 1; |
|
656 else |
|
657 return 0; |
|
658 } |
|
659 |