101 print "\t--bldpath=<direcotry> : build path for dll\n"; |
114 print "\t--bldpath=<direcotry> : build path for dll\n"; |
102 print "\t--import=<file> : import from file name\n"; |
115 print "\t--import=<file> : import from file name\n"; |
103 print "\t--linkas=<file> : linkas to file name specified\n"; |
116 print "\t--linkas=<file> : linkas to file name specified\n"; |
104 print "\t--inter : enables interworking on ARM and THUMB\n"; |
117 print "\t--inter : enables interworking on ARM and THUMB\n"; |
105 print "\t--export=<file> : export to filename\n"; |
118 print "\t--export=<file> : export to filename\n"; |
106 print "\t--sym_name_lkup : symbol name ordinal number lookupç\n"; |
119 print "\t--sym_name_lkup : symbol name ordinal number lookup\n"; |
107 print "\n"; |
120 print "\n"; |
108 exit 1; |
121 exit 1; |
109 } |
122 } |
110 |
123 |
111 my %symbols = (); |
124 my %symbols = (); |
146 { |
159 { |
147 my ($path, $bldpath, $expFile) = @_; |
160 my ($path, $bldpath, $expFile) = @_; |
148 my $numkeys = keys %symbolIndexMap; |
161 my $numkeys = keys %symbolIndexMap; |
149 my $failed = 0; |
162 my $failed = 0; |
150 |
163 |
151 open EXPFILE, ">$path\\$expFile.s" or |
164 open EXPFILE, ">$path$gDelim$expFile.s" or |
152 die "Error: can't create $path\\$expFile.s\n"; |
165 die "Error: can't create $path$gDelim$expFile.s\n"; |
153 |
166 |
154 print EXPFILE "\tEXPORT __DLL_Export_Table__\n\n"; |
167 print EXPFILE "\tEXPORT __DLL_Export_Table__\n\n"; |
155 print EXPFILE "\tEXPORT |DLL\#\#ExportTable|\n\n"; |
168 print EXPFILE "\tEXPORT |DLL\#\#ExportTable|\n\n"; |
156 print EXPFILE "\tEXPORT |DLL\#\#ExportTableSize|\n\n"; |
169 print EXPFILE "\tEXPORT |DLL\#\#ExportTableSize|\n\n"; |
157 print EXPFILE "\tAREA ExportTable, CODE\n"; |
170 print EXPFILE "\tAREA ExportTable, CODE\n"; |
202 print EXPFILE "\tDCB \"EXPORT DLL##ExportTableSize\\n\"\n"; |
215 print EXPFILE "\tDCB \"EXPORT DLL##ExportTableSize\\n\"\n"; |
203 |
216 |
204 print EXPFILE "\tEND"; |
217 print EXPFILE "\tEND"; |
205 close EXPFILE; |
218 close EXPFILE; |
206 |
219 |
207 $failed = system "armasm $floatingpointmodel $interworking -o $path\\$expFile.exp $path\\$expFile.s"; |
220 $failed = system "armasm $floatingpointmodel $interworking -o $path$gDelim$expFile.exp $path$gDelim$expFile.s"; |
208 unlink ("$path\\$expFile.s") unless $failed; |
221 unlink ("$path$gDelim$expFile.s") unless $failed; |
209 die "Error: cant create $path\\$expFile.exp\n" if $failed; |
222 die "Error: cant create $path$gDelim$expFile.exp\n" if $failed; |
210 } |
223 } |
211 |
224 |
212 my %DataSymbols = (); |
225 my %DataSymbols = (); |
213 |
226 |
214 sub genVtblExportFile($$) |
227 sub genVtblExportFile($$) |
215 { |
228 { |
216 my ($bldpath, $dllName) = @_; |
229 my ($bldpath, $dllName) = @_; |
217 my $FileName = "VtblExports"; |
230 my $FileName = "VtblExports"; |
218 |
231 |
219 open VTBLFILE, ">$bldpath\\$FileName.s" or |
232 open VTBLFILE, ">$bldpath$gDelim$FileName.s" or |
220 die "Error: can't create $bldpath\\$FileName.s\n"; |
233 die "Error: can't create $bldpath$gDelim$FileName.s\n"; |
221 |
234 |
222 print VTBLFILE "\tAREA |.directive|, NOALLOC, READONLY, ALIGN=2\n"; |
235 print VTBLFILE "\tAREA |.directive|, NOALLOC, READONLY, ALIGN=2\n"; |
223 printf VTBLFILE "\tDCB \"\#\<SYMEDIT\>\#\\n\"\n"; |
236 printf VTBLFILE "\tDCB \"\#\<SYMEDIT\>\#\\n\"\n"; |
224 |
237 |
225 my $symbol; |
238 my $symbol; |
231 } |
244 } |
232 # printf VTBLFILE "\tDCB \"\#\<\\\\VTBLSYMS\>\#\\n\"\n"; |
245 # printf VTBLFILE "\tDCB \"\#\<\\\\VTBLSYMS\>\#\\n\"\n"; |
233 print VTBLFILE "\tEND"; |
246 print VTBLFILE "\tEND"; |
234 close VTBLFILE; |
247 close VTBLFILE; |
235 |
248 |
236 my $failed = system "armasm $floatingpointmodel $interworking -o $bldpath\\$FileName.o $bldpath\\$FileName.s"; |
249 my $failed = system "armasm $floatingpointmodel $interworking -o $bldpath$gDelim$FileName.o $bldpath$gDelim$FileName.s"; |
237 unlink ("$bldpath\\$FileName.s"); |
250 unlink ("$bldpath$gDelim$FileName.s"); |
238 die "Error: cant create $bldpath\\$FileName.o\n" if $failed; |
251 die "Error: cant create $bldpath$gDelim$FileName.o\n" if $failed; |
239 push @objectFiles, "$bldpath\\$FileName.o"; |
252 push @objectFiles, "$bldpath$gDelim$FileName.o"; |
240 } |
253 } |
241 |
254 |
242 sub genLibFile ($$$$) |
255 sub genLibFile ($$$$) |
243 { |
256 { |
244 my ($path, $bldpath, $libFile, $dllName) = @_; |
257 my ($path, $bldpath, $libFile, $dllName) = @_; |
245 my $tempFileName = "$bldpath\\$compName"; |
258 my $tempFileName = "$bldpath$gDelim$compName"; |
246 my $viaFileName = sprintf("$bldpath\\_t%x_via_.txt", time); |
259 my $viaFileName = sprintf("$bldpath${gDelim}_t%x_via_.txt", time); |
247 my $keyz = keys %symbolIndexMap; |
260 my $keyz = keys %symbolIndexMap; |
248 my $failed = 0; |
261 my $failed = 0; |
249 my $key; |
262 my $key; |
250 |
263 |
251 if ($keyz > 0) { |
264 if ($keyz > 0) { |
252 open STUBGEN, "|$ENV{'EPOCROOT'}/epoc32/tools/genstubs" if $exports; |
265 open STUBGEN, "|genstubs" if $exports; |
253 foreach $key (sort keys %symbolIndexMap) { |
266 foreach $key (sort keys %symbolIndexMap) { |
254 my $symbol = $symbolIndexMap{$key}; |
267 my $symbol = $symbolIndexMap{$key}; |
255 my $stubFileName = "$tempFileName-$key"; |
268 my $stubFileName = "$tempFileName-$key"; |
256 if ( $symbols{$symbol} eq 'DATA') { |
269 if ( $symbols{$symbol} eq 'DATA') { |
257 $DataSymbols{$symbol} = $key; |
270 $DataSymbols{$symbol} = $key; |
261 } |
274 } |
262 } |
275 } |
263 genVtblExportFile($bldpath, $dllName); |
276 genVtblExportFile($bldpath, $dllName); |
264 } else { |
277 } else { |
265 # create dummy stub so armar creates a .lib for us |
278 # create dummy stub so armar creates a .lib for us |
266 open STUBGEN, "|$ENV{'EPOCROOT'}/epoc32/tools/genstubs"; |
279 open STUBGEN, "|genstubs"; |
267 print STUBGEN "$tempFileName-stub.o $tempFileName##stub $dllName##dummy\n"; |
280 print STUBGEN "$tempFileName-stub.o $tempFileName##stub $dllName##dummy\n"; |
268 push @objectFiles, "$tempFileName-stub.o"; |
281 push @objectFiles, "$tempFileName-stub.o"; |
269 } |
282 } |
270 close STUBGEN; |
283 close STUBGEN; |
271 |
284 |
272 open VIAFILE, ">$viaFileName" or |
285 open VIAFILE, ">$viaFileName" or |
273 die "Error: can't create VIA fie $viaFileName\n"; |
286 die "Error: can't create VIA fie $viaFileName\n"; |
274 |
287 |
275 print VIAFILE "${oP}create \"$path\\$libFile\"\n"; |
288 print VIAFILE "${oP}create \"$path$gDelim$libFile\"\n"; |
276 my $objectFile; |
289 my $objectFile; |
277 foreach $objectFile (@objectFiles) { |
290 foreach $objectFile (@objectFiles) { |
278 print VIAFILE "\"$objectFile\"\n"; |
291 print VIAFILE "\"$objectFile\"\n"; |
279 } |
292 } |
280 close VIAFILE; |
293 close VIAFILE; |
281 |
294 |
282 $failed = system( "armar ${oP}via $viaFileName"); |
295 $failed = system( "armar ${oP}via $viaFileName"); |
283 push @objectFiles, $viaFileName; |
296 push @objectFiles, $viaFileName; |
284 unlink @objectFiles; |
297 unlink @objectFiles; |
285 die "Error: can't create $path\\$libFile\n" if $failed; |
298 die "Error: can't create $path$gDelim$libFile\n" if $failed; |
286 } |
299 } |
287 |
300 |
288 __END__ |
301 __END__ |
289 |
302 |