|
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 Symbol for the elf2e32 tool |
|
15 // @internalComponent |
|
16 // @released |
|
17 // |
|
18 // |
|
19 |
|
20 #include "pl_symbol.h" |
|
21 |
|
22 |
|
23 /** |
|
24 This constructor sets the symbol members. |
|
25 @internalComponent |
|
26 @released |
|
27 */ |
|
28 Symbol::Symbol(char* aName, SymbolType aCodeDataType, char* aExportName, PLUINT32 aOrd, \ |
|
29 char* aComment , bool aR3Unused, bool aAbsent, PLUINT32 aSz) :\ |
|
30 iSymbolName(aName), iExportName(aExportName),iSymbolType(aCodeDataType),\ |
|
31 iOrdinalNumber(aOrd),iComment(aComment),iAbsent(aAbsent), iR3Unused(aR3Unused), \ |
|
32 iSize (aSz) |
|
33 { |
|
34 |
|
35 } |
|
36 |
|
37 /** |
|
38 This constructor sets the symbol members. |
|
39 @internalComponent |
|
40 @released |
|
41 */ |
|
42 Symbol::Symbol(Symbol& aSymbol, SymbolType aCodeDataType, bool aAbsent) |
|
43 : iExportName(NULL), \ |
|
44 iSymbolType(aCodeDataType),iComment(NULL), iR3Unused(false), iAbsent(aAbsent) |
|
45 { |
|
46 iSymbolName = new char[strlen(aSymbol.SymbolName()) + 1]; |
|
47 strcpy(iSymbolName, aSymbol.SymbolName()); |
|
48 iOrdinalNumber = aSymbol.OrdNum(); |
|
49 } |
|
50 |
|
51 /** |
|
52 This copy constructor copies the symbol members from the input symbol. |
|
53 @param aSymbol - The symbol from which the members are to be copied. |
|
54 @internalComponent |
|
55 @released |
|
56 */ |
|
57 Symbol::Symbol(Symbol& aSymbol) |
|
58 { |
|
59 memcpy(this, &aSymbol, sizeof(aSymbol)); |
|
60 |
|
61 iSymbolName = new char[strlen(aSymbol.SymbolName()) + 1]; |
|
62 strcpy(iSymbolName, aSymbol.SymbolName()); |
|
63 |
|
64 if(aSymbol.Comment()) |
|
65 { |
|
66 iComment = new char[strlen(aSymbol.Comment()) + 1]; |
|
67 strcpy(iComment, aSymbol.Comment()); |
|
68 } |
|
69 |
|
70 if(aSymbol.ExportName()) |
|
71 { |
|
72 iExportName = new char[strlen(aSymbol.ExportName()) + 1]; |
|
73 strcpy(iExportName, aSymbol.ExportName()); |
|
74 } |
|
75 } |
|
76 |
|
77 /** |
|
78 This constructor sets the symbol members. |
|
79 @internalComponent |
|
80 @released |
|
81 */ |
|
82 Symbol::Symbol(int symbolStatus,char *name,char *exportName,int ordinalNo,bool r3unused,bool absent,int symbolType,char *comment, PLUINT32 aSz)\ |
|
83 :iSize (aSz) |
|
84 { |
|
85 if(symbolStatus==0) |
|
86 { |
|
87 iSymbolStatus=Matching; |
|
88 } |
|
89 else if(symbolStatus==1) |
|
90 { |
|
91 iSymbolStatus=Missing; |
|
92 } |
|
93 else |
|
94 { |
|
95 iSymbolStatus=New; |
|
96 } |
|
97 iSymbolName=name; |
|
98 iExportName=exportName; |
|
99 iOrdinalNumber=ordinalNo; |
|
100 iR3Unused=r3unused; |
|
101 iAbsent=absent; |
|
102 if(symbolType==0) |
|
103 { |
|
104 iSymbolType=SymbolTypeCode; |
|
105 } |
|
106 else if(symbolType==1) |
|
107 { |
|
108 iSymbolType=SymbolTypeData; |
|
109 } |
|
110 else |
|
111 { |
|
112 iSymbolType=SymbolTypeNotDefined; |
|
113 } |
|
114 iComment=comment; |
|
115 } |
|
116 |
|
117 /** |
|
118 This destructor frees the symbol members. |
|
119 @internalComponent |
|
120 @released |
|
121 */ |
|
122 Symbol::~Symbol() |
|
123 { |
|
124 delete [] iSymbolName; |
|
125 delete [] iExportName; |
|
126 delete [] iComment; |
|
127 } |
|
128 |
|
129 /** |
|
130 This function sets the symbol name. |
|
131 @param aSymbolName - The symbol name |
|
132 @internalComponent |
|
133 @released |
|
134 */ |
|
135 void Symbol::SetSymbolName(char *aSymbolName) |
|
136 { |
|
137 iSymbolName = new char[strlen(aSymbolName)+1]; |
|
138 strcpy(iSymbolName, aSymbolName); |
|
139 } |
|
140 |
|
141 /** |
|
142 This function compares the symbol for equality. |
|
143 @param aSym - The symbol that is compared with this symbol |
|
144 Return - It returns true if the 2 symbols are equal. |
|
145 @internalComponent |
|
146 @released |
|
147 */ |
|
148 bool Symbol::operator==(const Symbol* aSym) const { |
|
149 if(strcmp(iSymbolName, aSym->iSymbolName)) |
|
150 return false; |
|
151 if( iSymbolType != aSym->iSymbolType ) |
|
152 return false; |
|
153 |
|
154 return true; |
|
155 } |
|
156 |
|
157 /** |
|
158 This function returns the symbol name. |
|
159 @internalComponent |
|
160 @released |
|
161 */ |
|
162 const char* Symbol::SymbolName() const { |
|
163 return iSymbolName; |
|
164 } |
|
165 |
|
166 /** |
|
167 This function returns the aliased symbol name. |
|
168 @internalComponent |
|
169 @released |
|
170 */ |
|
171 const char* Symbol::ExportName() { |
|
172 return iExportName; |
|
173 } |
|
174 |
|
175 /** |
|
176 This function returns the ordinal number of the symbol. |
|
177 @internalComponent |
|
178 @released |
|
179 */ |
|
180 PLUINT32 Symbol::OrdNum() const { |
|
181 return iOrdinalNumber; |
|
182 } |
|
183 |
|
184 /** |
|
185 This function returns if the symbol is code or a data symbol. |
|
186 @internalComponent |
|
187 @released |
|
188 */ |
|
189 SymbolType Symbol::CodeDataType() { |
|
190 return iSymbolType; |
|
191 } |
|
192 |
|
193 /** |
|
194 This function returns if r3unused is true. |
|
195 @internalComponent |
|
196 @released |
|
197 */ |
|
198 bool Symbol::R3unused() { |
|
199 return iR3Unused; |
|
200 } |
|
201 |
|
202 /** |
|
203 This function returns if the symbol is marked absent in the def file. |
|
204 @internalComponent |
|
205 @released |
|
206 */ |
|
207 bool Symbol::Absent() { |
|
208 return iAbsent; |
|
209 } |
|
210 |
|
211 /** |
|
212 This function sets the symbol to be absent. |
|
213 @param aAbsent - bool value |
|
214 @internalComponent |
|
215 @released |
|
216 */ |
|
217 void Symbol::SetAbsent(bool aAbsent) { |
|
218 iAbsent = aAbsent; |
|
219 } |
|
220 |
|
221 /** |
|
222 This function returns the comment against this def file. |
|
223 @internalComponent |
|
224 @released |
|
225 */ |
|
226 char* Symbol::Comment() { |
|
227 return iComment; |
|
228 } |
|
229 |
|
230 /** |
|
231 This function returns the symbol is a matching/missing/new symbol in the def file. |
|
232 @internalComponent |
|
233 @released |
|
234 */ |
|
235 int Symbol::GetSymbolStatus() { |
|
236 return iSymbolStatus; |
|
237 } |
|
238 |
|
239 /** |
|
240 This function sets the ordinal number for this symbol. |
|
241 @internalComponent |
|
242 @released |
|
243 */ |
|
244 void Symbol::SetOrdinal(PLUINT32 aOrdinalNum) { |
|
245 iOrdinalNumber=aOrdinalNum; |
|
246 } |
|
247 |
|
248 /** |
|
249 This function sets the status of the symbol i.e., whether it is |
|
250 a matching/missing/new symbol. |
|
251 @internalComponent |
|
252 @released |
|
253 */ |
|
254 void Symbol::SetSymbolStatus(SymbolStatus aSymbolStatus) { |
|
255 iSymbolStatus = aSymbolStatus; |
|
256 } |
|
257 |
|
258 /** |
|
259 This function sets the symbol name. |
|
260 @param aSymbolName - Symbol Name |
|
261 @internalComponent |
|
262 @released |
|
263 */ |
|
264 void Symbol::SymbolName(char *aSymbolName) |
|
265 { |
|
266 iSymbolName = aSymbolName; |
|
267 } |
|
268 /** |
|
269 This function sets the export name of the symbol. |
|
270 @param aComment - aExportName |
|
271 @internalComponent |
|
272 @released |
|
273 */ |
|
274 void Symbol::ExportName(char *aExportName) |
|
275 { |
|
276 iExportName = aExportName; |
|
277 } |
|
278 |
|
279 /** |
|
280 This function sets the comment against the symbol. |
|
281 @param aComment - aComment |
|
282 @internalComponent |
|
283 @released |
|
284 */ |
|
285 void Symbol::Comment(char *aComment) |
|
286 { |
|
287 iComment = aComment; |
|
288 } |
|
289 |
|
290 /** |
|
291 This function sets the symbol type if it is Code or Data symbol. |
|
292 @param aType - Symbol Type |
|
293 @internalComponent |
|
294 @released |
|
295 */ |
|
296 void Symbol::CodeDataType(SymbolType aType) |
|
297 { |
|
298 iSymbolType = aType; |
|
299 } |
|
300 |
|
301 /** |
|
302 This function sets if R3Unused is true for this symbol. |
|
303 @param aR3Unused - bool value |
|
304 @internalComponent |
|
305 @released |
|
306 */ |
|
307 void Symbol::R3Unused(bool aR3Unused) |
|
308 { |
|
309 iR3Unused = aR3Unused; |
|
310 } |
|
311 |
|
312 /** |
|
313 This function sets if R3Unused is true for this symbol. |
|
314 @param aSize - size of the symbol |
|
315 @internalComponent |
|
316 @released |
|
317 */ |
|
318 void Symbol::SetSymbolSize(PLUINT32 aSize){ |
|
319 iSize = aSize; |
|
320 } |
|
321 |
|
322 /** |
|
323 This function gets the size of this symbol. |
|
324 @internalComponent |
|
325 @released |
|
326 */ |
|
327 PLUINT32 Symbol::SymbolSize(){ |
|
328 return iSize; |
|
329 } |