|
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 // Implementation of the Class ElfImports for the elf2e32 tool |
|
15 // @internalComponent |
|
16 // @released |
|
17 // |
|
18 // |
|
19 |
|
20 #include "pl_elfimports.h" |
|
21 #include "pl_elfimportrelocation.h" |
|
22 |
|
23 /** |
|
24 Constructor for class ElfImports |
|
25 @internalComponent |
|
26 @released |
|
27 */ |
|
28 ElfImports::ElfImports(){ |
|
29 |
|
30 } |
|
31 |
|
32 /** |
|
33 Destructor for class ElfImports to release allocated memory |
|
34 @internalComponent |
|
35 @released |
|
36 */ |
|
37 ElfImports::~ElfImports() |
|
38 { |
|
39 |
|
40 if(iImports.size()) |
|
41 { |
|
42 ImportMap::iterator aItr = iImports.begin(); |
|
43 ImportMap::iterator last = iImports.end(); |
|
44 RelocationList *rlistTemp; |
|
45 |
|
46 while( aItr != last) |
|
47 { |
|
48 rlistTemp = &((*aItr).second); |
|
49 RelocationList::iterator aItr1 = rlistTemp->begin(); |
|
50 RelocationList::iterator last1 = rlistTemp->end(); |
|
51 ElfImportRelocation *temp; |
|
52 |
|
53 while( aItr1 != last1) |
|
54 { |
|
55 temp = *aItr1; |
|
56 aItr1++; |
|
57 delete temp; |
|
58 } |
|
59 aItr++; |
|
60 rlistTemp->clear(); |
|
61 } |
|
62 } |
|
63 |
|
64 iImports.clear(); |
|
65 } |
|
66 |
|
67 |
|
68 /** |
|
69 Function to add imports |
|
70 @param aDllName - Dll name |
|
71 @param aReloc - Elf import relocation |
|
72 @internalComponent |
|
73 @released |
|
74 */ |
|
75 void ElfImports::Add(const char* aDllName, ElfImportRelocation *aReloc){ |
|
76 iImports[aDllName].insert(iImports[aDllName].end(), aReloc); |
|
77 } |
|
78 |
|
79 |
|
80 /** |
|
81 Function to get import size |
|
82 @return import size |
|
83 @internalComponent |
|
84 @released |
|
85 */ |
|
86 PLUINT32 ElfImports::GetImportSize(){ |
|
87 |
|
88 PLUINT32 aSize = 0; |
|
89 |
|
90 ImportMap::iterator aItr = iImports.begin(); |
|
91 RelocationList aList; |
|
92 |
|
93 while(aItr != iImports.end()) { |
|
94 aList = ((*aItr).second); |
|
95 aSize += aList.size(); |
|
96 aItr++; |
|
97 } |
|
98 return aSize; |
|
99 } |
|
100 |
|
101 |
|
102 /** |
|
103 Overloaded operator comparing the symbol names. |
|
104 @return True if lhs string is less then rhs, otherwise false |
|
105 @internalComponent |
|
106 @released |
|
107 */ |
|
108 bool ElfImports::StringPtrLess::operator() (const char * lhs, const char * rhs) const |
|
109 { |
|
110 return strcmp(lhs, rhs) < 0; |
|
111 } |
|
112 |
|
113 /** |
|
114 Function to get imports |
|
115 @return imports |
|
116 @internalComponent |
|
117 @released |
|
118 */ |
|
119 ElfImports::ImportMap& ElfImports::GetImports() |
|
120 { |
|
121 return iImports; |
|
122 } |
|
123 |