61 if(!iParameterListInterface->E32ImageOutput()) |
64 if(!iParameterListInterface->E32ImageOutput()) |
62 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--output"); |
65 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--output"); |
63 if(!iParameterListInterface->DefInput()) |
66 if(!iParameterListInterface->DefInput()) |
64 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput"); |
67 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--definput"); |
65 |
68 |
66 GenerateAsmFile(iParameterListInterface->E32ImageOutput()); |
69 GenerateAsmFile(); |
67 } |
70 } |
68 else |
71 else |
69 { |
72 { |
70 if(!iParameterListInterface->E32Input()) |
73 if(!iParameterListInterface->E32Input()) |
71 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input"); |
74 throw ParameterParserError(NOREQUIREDOPTIONERROR,"--e32input"); |
72 if(iParameterListInterface->DumpOptions() & EDumpAsm ) |
75 if(iParameterListInterface->DumpOptions() & EDumpAsm ) |
73 throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump"); |
76 throw InvalidArgumentError(INVALIDARGUMENTERROR,iParameterListInterface->FileDumpSubOptions() ,"--dump"); |
74 DumpE32Image(iParameterListInterface->E32Input()); |
77 DumpE32Image(); |
75 } |
78 } |
76 return 0; |
79 return 0; |
77 } |
80 } |
78 |
81 |
79 /** |
82 /** |
81 @param afileName - ASM File name |
84 @param afileName - ASM File name |
82 @return 0 on success, otherwise throw error |
85 @return 0 on success, otherwise throw error |
83 @internalComponent |
86 @internalComponent |
84 @released |
87 @released |
85 */ |
88 */ |
86 int FileDump::GenerateAsmFile(const char* afileName)//DumpAsm |
89 int FileDump::GenerateAsmFile() //DumpAsm |
|
90 { |
|
91 EAsmDialect asmDialect = iParameterListInterface->AsmDialect(); |
|
92 switch(asmDialect) |
|
93 { |
|
94 case EGas: |
|
95 return GenerateGasAsmFile(); |
|
96 case EArmas: |
|
97 return GenerateArmasAsmFile(); |
|
98 default: |
|
99 assert(false); |
|
100 } |
|
101 return 0; |
|
102 } |
|
103 |
|
104 /** |
|
105 Function to generate an RVCT armas ASM File. |
|
106 @param afileName - ASM File name |
|
107 @return 0 on success, otherwise throw error |
|
108 @internalComponent |
|
109 @released |
|
110 */ |
|
111 int FileDump::GenerateArmasAsmFile() |
87 { |
112 { |
88 DefFile *iDefFile = new DefFile(); |
113 DefFile *iDefFile = new DefFile(); |
89 SymbolList *aSymList; |
114 SymbolList *aSymList; |
90 aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); |
115 aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); |
|
116 char const *afileName = iParameterListInterface->E32ImageOutput(); |
91 |
117 |
92 FILE *fptr; |
118 FILE *fptr; |
93 |
119 |
94 if((fptr=fopen(afileName,"w"))==NULL) |
120 if((fptr=fopen(afileName,"w"))==NULL) |
95 { |
121 { |
153 } |
179 } |
154 return 0; |
180 return 0; |
155 } |
181 } |
156 |
182 |
157 /** |
183 /** |
|
184 Function to generate a GNU as ASM File. |
|
185 @param afileName - ASM File name |
|
186 @return 0 on success, otherwise throw error |
|
187 @internalComponent |
|
188 @released |
|
189 */ |
|
190 int FileDump::GenerateGasAsmFile() |
|
191 { |
|
192 DefFile *iDefFile = new DefFile(); |
|
193 SymbolList *aSymList; |
|
194 aSymList = iDefFile->ReadDefFile(iParameterListInterface->DefInput()); |
|
195 char const *afileName = iParameterListInterface->E32ImageOutput(); |
|
196 |
|
197 FILE *fptr; |
|
198 |
|
199 if((fptr=fopen(afileName,"w"))==NULL) |
|
200 { |
|
201 throw FileError(FILEOPENERROR,(char*)afileName); |
|
202 } |
|
203 else |
|
204 { |
|
205 SymbolList::iterator aItr = aSymList->begin(); |
|
206 SymbolList::iterator last = aSymList->end(); |
|
207 Symbol *aSym; |
|
208 |
|
209 while( aItr != last) |
|
210 { |
|
211 aSym = *aItr; |
|
212 |
|
213 if(aSym->Absent()) |
|
214 { |
|
215 aItr++; |
|
216 continue; |
|
217 } |
|
218 |
|
219 fputs("\t.extern ",fptr); |
|
220 fputs(aSym->SymbolName(),fptr); |
|
221 fputs("\n",fptr); |
|
222 aItr++; |
|
223 } |
|
224 |
|
225 // Create a directive section that instructs the linker to make all listed |
|
226 // symbols visible. |
|
227 |
|
228 fputs("\t.text\n\n",fptr); |
|
229 |
|
230 fputs("\t.ascii \"#<SYMEDIT>#\\n\"\n", fptr); |
|
231 |
|
232 aItr = aSymList->begin(); |
|
233 while (aItr != last) |
|
234 { |
|
235 aSym = *aItr; |
|
236 |
|
237 if ( aSym->Absent() ) |
|
238 { |
|
239 aItr++; |
|
240 continue; |
|
241 } |
|
242 |
|
243 // Example: |
|
244 // DCB "EXPORT __ARM_ll_mlass\n" |
|
245 fputs("\t.ascii \"EXPORT ",fptr); |
|
246 fputs(aSym->SymbolName(),fptr); |
|
247 fputs("\\n\"\n", fptr); |
|
248 |
|
249 aItr++; |
|
250 } |
|
251 fclose(fptr); |
|
252 } |
|
253 return 0; |
|
254 } |
|
255 |
|
256 |
|
257 /** |
158 Function to Dump E32 Image. |
258 Function to Dump E32 Image. |
159 @param afileName - E32 Image File name |
259 @param afileName - E32 Image File name |
160 @return 1 on success, otherwise throw error |
260 @return 1 on success, otherwise throw error |
161 @internalComponent |
261 @internalComponent |
162 @released |
262 @released |
163 */ |
263 */ |
164 int FileDump::DumpE32Image(const char* afileName) |
264 int FileDump::DumpE32Image() |
165 { |
265 { |
|
266 char const *afileName = iParameterListInterface->E32Input(); |
166 E32ImageFile *aE32Imagefile=new E32ImageFile(); |
267 E32ImageFile *aE32Imagefile=new E32ImageFile(); |
167 TInt result = aE32Imagefile->Open(afileName); |
268 TInt result = aE32Imagefile->Open(afileName); |
168 |
269 |
169 if (result > 0) |
270 if (result > 0) |
170 return 1; |
271 return 1; |