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