pkgutil.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. {
  2. Copyright (c) 2013-2014 by Free Pascal Development Team
  3. This unit implements basic parts of the package system
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit pkgutil;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. fmodule,fpkg;
  22. procedure createimportlibfromexternals(pkg:tpackage);
  23. Function RewritePPU(const PPUFn,PPLFn:String):Boolean;
  24. procedure export_unit(u:tmodule);
  25. procedure load_packages;
  26. implementation
  27. uses
  28. sysutils,
  29. globtype,systems,
  30. cutils,cclasses,
  31. globals,verbose,
  32. aasmbase,aasmdata,aasmtai,
  33. symtype,symconst,symsym,symdef,symbase,symtable,
  34. ppu,entfile,fpcp,
  35. ncgutil,
  36. export;
  37. procedure procexport(const s : string);
  38. var
  39. hp : texported_item;
  40. begin
  41. hp:=texported_item.create;
  42. hp.name:=stringdup(s);
  43. hp.options:=hp.options+[eo_name];
  44. exportlib.exportprocedure(hp);
  45. end;
  46. procedure varexport(const s : string);
  47. var
  48. hp : texported_item;
  49. begin
  50. hp:=texported_item.create;
  51. hp.name:=stringdup(s);
  52. hp.options:=hp.options+[eo_name];
  53. exportlib.exportvar(hp);
  54. end;
  55. procedure exportprocsym(sym:tprocsym;symtable:tsymtable);
  56. var
  57. i : longint;
  58. item : TCmdStrListItem;
  59. begin
  60. for i:=0 to tprocsym(sym).ProcdefList.Count-1 do
  61. begin
  62. if not(tprocdef(tprocsym(sym).ProcdefList[i]).proccalloption in [pocall_internproc]) and
  63. ((tprocdef(tprocsym(sym).ProcdefList[i]).procoptions*[po_external])=[]) and
  64. ((symtable.symtabletype in [globalsymtable,recordsymtable,objectsymtable]) or
  65. ((symtable.symtabletype=staticsymtable) and (po_public in tprocdef(tprocsym(sym).ProcdefList[i]).procoptions))
  66. ) then
  67. begin
  68. exportallprocdefnames(tprocsym(sym),tprocdef(tprocsym(sym).ProcdefList[i]),[]);
  69. end;
  70. end;
  71. end;
  72. procedure exportabstractrecordsymproc(sym:tobject;arg:pointer);
  73. var
  74. def : tabstractrecorddef;
  75. begin
  76. case tsym(sym).typ of
  77. typesym:
  78. begin
  79. case ttypesym(sym).typedef.typ of
  80. objectdef,
  81. recorddef:
  82. begin
  83. def:=tabstractrecorddef(ttypesym(sym).typedef);
  84. def.symtable.symlist.foreachcall(@exportabstractrecordsymproc,def.symtable);
  85. end;
  86. end;
  87. end;
  88. procsym:
  89. begin
  90. { don't export methods of interfaces }
  91. if is_interface(tdef(tabstractrecordsymtable(arg).defowner)) then
  92. exit;
  93. exportprocsym(tprocsym(sym),tsymtable(arg));
  94. end;
  95. staticvarsym:
  96. begin
  97. varexport(tsym(sym).mangledname);
  98. end;
  99. end;
  100. end;
  101. procedure insert_export(sym : TObject;arg:pointer);
  102. var
  103. i : longint;
  104. item : TCmdStrListItem;
  105. def : tabstractrecorddef;
  106. hp : texported_item;
  107. publiconly : boolean;
  108. begin
  109. publiconly:=tsymtable(arg).symtabletype=staticsymtable;
  110. case TSym(sym).typ of
  111. { ignore: }
  112. unitsym,
  113. syssym,
  114. constsym,
  115. namespacesym,
  116. propertysym,
  117. enumsym:
  118. ;
  119. typesym:
  120. begin
  121. case ttypesym(sym).typedef.typ of
  122. recorddef,
  123. objectdef:
  124. begin
  125. def:=tabstractrecorddef(ttypesym(sym).typedef);
  126. def.symtable.SymList.ForEachCall(@exportabstractrecordsymproc,def.symtable);
  127. if (def.typ=objectdef) and (oo_has_vmt in tobjectdef(def).objectoptions) then
  128. begin
  129. hp:=texported_item.create;
  130. hp.name:=stringdup(tobjectdef(def).vmt_mangledname);
  131. hp.options:=hp.options+[eo_name];
  132. exportlib.exportvar(hp);
  133. end;
  134. end;
  135. end;
  136. end;
  137. procsym:
  138. begin
  139. exportprocsym(tprocsym(sym),tsymtable(arg));
  140. end;
  141. staticvarsym:
  142. begin
  143. if publiconly and not (vo_is_public in tstaticvarsym(sym).varoptions) then
  144. exit;
  145. varexport(tsym(sym).mangledname);
  146. end;
  147. else
  148. begin
  149. writeln('unknown: ',ord(TSym(sym).typ));
  150. end;
  151. end;
  152. end;
  153. procedure export_unit(u: tmodule);
  154. begin
  155. u.globalsymtable.symlist.ForEachCall(@insert_export,u.globalsymtable);
  156. { check localsymtable for exports too to get public symbols }
  157. u.localsymtable.symlist.ForEachCall(@insert_export,u.localsymtable);
  158. { export assembler symbols }
  159. for i:=0 to u.globalasmsyms.count-1 do
  160. with tasmsymbol(u.globalasmsyms[i]) do
  161. if bind in [AB_GLOBAL] then
  162. case typ of
  163. AT_FUNCTION:
  164. procexport(name);
  165. AT_DATA:
  166. varexport(name);
  167. else
  168. Writeln('Ignoring asm symbol ',typ);
  169. end;
  170. end;
  171. Function RewritePPU(const PPUFn,PPLFn:String):Boolean;
  172. Var
  173. MakeStatic : Boolean;
  174. Var
  175. buffer : array[0..$1fff] of byte;
  176. inppu,
  177. outppu : tppufile;
  178. b,
  179. untilb : byte;
  180. l,m : longint;
  181. f : file;
  182. ext,
  183. s : string;
  184. ppuversion : dword;
  185. begin
  186. Result:=false;
  187. MakeStatic:=False;
  188. inppu:=tppufile.create(PPUFn);
  189. if not inppu.openfile then
  190. begin
  191. inppu.free;
  192. Comment(V_Error,'Could not open : '+PPUFn);
  193. Exit;
  194. end;
  195. { Check the ppufile }
  196. if not inppu.CheckPPUId then
  197. begin
  198. inppu.free;
  199. Comment(V_Error,'Not a PPU File : '+PPUFn);
  200. Exit;
  201. end;
  202. ppuversion:=inppu.getversion;
  203. if ppuversion<CurrentPPUVersion then
  204. begin
  205. inppu.free;
  206. Comment(V_Error,'Wrong PPU Version '+tostr(ppuversion)+' in '+PPUFn);
  207. Exit;
  208. end;
  209. { No .o file generated for this ppu, just skip }
  210. if (inppu.header.common.flags and uf_no_link)<>0 then
  211. begin
  212. inppu.free;
  213. Result:=true;
  214. Exit;
  215. end;
  216. { Already a lib? }
  217. if (inppu.header.common.flags and uf_in_library)<>0 then
  218. begin
  219. inppu.free;
  220. Comment(V_Error,'PPU is already in a library : '+PPUFn);
  221. Exit;
  222. end;
  223. { We need a static linked unit }
  224. if (inppu.header.common.flags and uf_static_linked)=0 then
  225. begin
  226. inppu.free;
  227. Comment(V_Error,'PPU is not static linked : '+PPUFn);
  228. Exit;
  229. end;
  230. { Check if shared is allowed }
  231. if tsystem(inppu.header.common.target) in [system_i386_go32v2] then
  232. begin
  233. Comment(V_Error,'Shared library not supported for ppu target, switching to static library');
  234. MakeStatic:=true;
  235. end;
  236. { Create the new ppu }
  237. if PPUFn=PPLFn then
  238. outppu:=tppufile.create('ppumove.$$$')
  239. else
  240. outppu:=tppufile.create(PPLFn);
  241. outppu.createfile;
  242. { Create new header, with the new flags }
  243. outppu.header:=inppu.header;
  244. outppu.header.common.flags:=outppu.header.common.flags or uf_in_library;
  245. if MakeStatic then
  246. outppu.header.common.flags:=outppu.header.common.flags or uf_static_linked
  247. else
  248. outppu.header.common.flags:=outppu.header.common.flags or uf_shared_linked;
  249. { read until the object files are found }
  250. untilb:=iblinkunitofiles;
  251. repeat
  252. b:=inppu.readentry;
  253. if b in [ibendinterface,ibend] then
  254. begin
  255. inppu.free;
  256. outppu.free;
  257. Comment(V_Error,'No files to be linked found : '+PPUFn);
  258. Exit;
  259. end;
  260. if b<>untilb then
  261. begin
  262. repeat
  263. inppu.getdatabuf(buffer,sizeof(buffer),l);
  264. outppu.putdata(buffer,l);
  265. until l<sizeof(buffer);
  266. outppu.writeentry(b);
  267. end;
  268. until (b=untilb);
  269. { we have now reached the section for the files which need to be added,
  270. now add them to the list }
  271. case b of
  272. iblinkunitofiles :
  273. begin
  274. { add all o files, and save the entry when not creating a static
  275. library to keep staticlinking possible }
  276. while not inppu.endofentry do
  277. begin
  278. s:=inppu.getstring;
  279. m:=inppu.getlongint;
  280. if not MakeStatic then
  281. begin
  282. outppu.putstring(s);
  283. outppu.putlongint(m);
  284. end;
  285. current_module.linkotherofiles.add(s,link_always);;
  286. end;
  287. if not MakeStatic then
  288. outppu.writeentry(b);
  289. end;
  290. { iblinkunitstaticlibs :
  291. begin
  292. AddToLinkFiles(ExtractLib(inppu.getstring));
  293. if not inppu.endofentry then
  294. begin
  295. repeat
  296. inppu.getdatabuf(buffer^,bufsize,l);
  297. outppu.putdata(buffer^,l);
  298. until l<bufsize;
  299. outppu.writeentry(b);
  300. end;
  301. end; }
  302. end;
  303. { just add a new entry with the new lib }
  304. if MakeStatic then
  305. begin
  306. outppu.putstring('imp'+current_module.realmodulename^);
  307. outppu.putlongint(link_static);
  308. outppu.writeentry(iblinkunitstaticlibs)
  309. end
  310. else
  311. begin
  312. outppu.putstring('imp'+current_module.realmodulename^);
  313. outppu.putlongint(link_shared);
  314. outppu.writeentry(iblinkunitsharedlibs);
  315. end;
  316. { read all entries until the end and write them also to the new ppu }
  317. repeat
  318. b:=inppu.readentry;
  319. { don't write ibend, that's written automatically }
  320. if b<>ibend then
  321. begin
  322. if b=iblinkothersharedlibs then
  323. begin
  324. while not inppu.endofentry do
  325. begin
  326. s:=inppu.getstring;
  327. m:=inppu.getlongint;
  328. outppu.putstring(s);
  329. outppu.putlongint(m);
  330. { strip lib prefix }
  331. if copy(s,1,3)='lib' then
  332. delete(s,1,3);
  333. ext:=ExtractFileExt(s);
  334. if ext<>'' then
  335. delete(s,length(s)-length(ext)+1,length(ext));
  336. current_module.linkOtherSharedLibs.add(s,link_always);
  337. end;
  338. end
  339. else
  340. repeat
  341. inppu.getdatabuf(buffer,sizeof(buffer),l);
  342. outppu.putdata(buffer,l);
  343. until l<sizeof(buffer);
  344. outppu.writeentry(b);
  345. end;
  346. until b=ibend;
  347. { write the last stuff and close }
  348. outppu.flush;
  349. outppu.writeheader;
  350. outppu.free;
  351. inppu.free;
  352. { rename }
  353. if PPUFn=PPLFn then
  354. begin
  355. {$push}{$I-}
  356. assign(f,PPUFn);
  357. erase(f);
  358. assign(f,'ppumove.$$$');
  359. rename(f,PPUFn);
  360. {$pop}
  361. if ioresult<>0 then;
  362. end;
  363. Result:=True;
  364. end;
  365. procedure load_packages;
  366. var
  367. i : longint;
  368. pcp: tpcppackage;
  369. entry : ppackageentry;
  370. begin
  371. if not (tf_supports_packages in target_info.flags) then
  372. exit;
  373. for i:=0 to packagelist.count-1 do
  374. begin
  375. entry:=ppackageentry(packagelist[i]);
  376. if assigned(entry^.package) then
  377. internalerror(2013053104);
  378. Comment(V_Info,'Loading package: '+entry^.realpkgname);
  379. pcp:=tpcppackage.create(entry^.realpkgname);
  380. pcp.loadpcp;
  381. entry^.package:=pcp;
  382. end;
  383. end;
  384. procedure createimportlibfromexternals(pkg:tpackage);
  385. type
  386. tcacheentry=record
  387. pkg:tpackage;
  388. sym:tasmsymbol;
  389. end;
  390. pcacheentry=^tcacheentry;
  391. var
  392. cache : tfphashlist;
  393. alreadyloaded : tfpobjectlist;
  394. function findpackagewithsym(sym:tasmsymbol):tcacheentry;
  395. var
  396. i,j : longint;
  397. pkgentry : ppackageentry;
  398. unitentry : pcontainedunit;
  399. begin
  400. for i:=0 to packagelist.count-1 do
  401. begin
  402. pkgentry:=ppackageentry(packagelist[i]);
  403. for j:=0 to pkgentry^.package.containedmodules.count-1 do
  404. begin
  405. unitentry:=pcontainedunit(pkgentry^.package.containedmodules[j]);
  406. if not assigned(unitentry^.module) then
  407. { the unit is not loaded }
  408. continue;
  409. result.sym:=tasmsymbol(tmodule(unitentry^.module).globalasmsyms.find(sym.name));
  410. if assigned(result.sym) then
  411. begin
  412. { only accept global symbols of the used unit }
  413. if result.sym.bind<>ab_global then
  414. begin
  415. result.sym:=nil;
  416. result.pkg:=nil;
  417. end
  418. else
  419. result.pkg:=pkgentry^.package;
  420. exit;
  421. end;
  422. end;
  423. end;
  424. result.sym:=nil;
  425. result.pkg:=nil;
  426. end;
  427. procedure processasmsyms(symlist:tfphashobjectlist);
  428. var
  429. i,j,k : longint;
  430. sym : tasmsymbol;
  431. cacheentry : pcacheentry;
  432. list : TAsmList;
  433. labind : tasmsymbol;
  434. psym : tsymentry;
  435. pd : tprocdef;
  436. found : boolean;
  437. begin
  438. for i:=0 to symlist.count-1 do
  439. begin
  440. sym:=tasmsymbol(symlist[i]);
  441. if sym.bind<>ab_external then
  442. continue;
  443. { did we already import the symbol? }
  444. cacheentry:=pcacheentry(cache.find(sym.name));
  445. if assigned(cacheentry) then
  446. continue;
  447. { was the symbol already imported in the previous pass? }
  448. found:=false;
  449. for j:=0 to alreadyloaded.count-1 do
  450. begin
  451. psym:=tsymentry(alreadyloaded[j]);
  452. case psym.typ of
  453. procsym:
  454. for k:=0 to tprocsym(psym).procdeflist.count-1 do
  455. begin
  456. pd:=tprocdef(tprocsym(psym).procdeflist[k]);
  457. if has_alias_name(pd,sym.name) then
  458. begin
  459. found:=true;
  460. break;
  461. end;
  462. end;
  463. staticvarsym:
  464. if tstaticvarsym(psym).mangledname=sym.name then
  465. found:=true;
  466. else
  467. internalerror(2014101005);
  468. end;
  469. if found then
  470. break;
  471. end;
  472. if found then begin
  473. writeln('asm symbol ', sym.name, ' is already imported');
  474. { add a dummy entry }
  475. new(cacheentry);
  476. cacheentry^.pkg:=nil;
  477. cacheentry^.sym:=sym;
  478. cache.add(sym.name,cacheentry);
  479. continue;
  480. end;
  481. new(cacheentry);
  482. cacheentry^:=findpackagewithsym(sym);
  483. cache.add(sym.name,cacheentry);
  484. { use cacheentry^.sym instead of sym, because for the later typ
  485. is always at_none in case of an external symbol }
  486. if assigned(cacheentry^.pkg) then
  487. begin
  488. current_module.addexternalimport(cacheentry^.pkg.pplfilename,sym.name,sym.name,0,cacheentry^.sym.typ=at_data,false);
  489. { also add an $indirect symbol if it is a variable }
  490. if cacheentry^.sym.typ=AT_DATA then
  491. begin
  492. list:=current_asmdata.AsmLists[al_globals];
  493. new_section(list,sec_rodata,lower(sym.name),const_align(4));
  494. labind:=current_asmdata.DefineAsmSymbol(sym.name+indirect_suffix,AB_PRIVATE_EXTERN,AT_DATA);
  495. list.concat(Tai_symbol.Create_Global(labind,0));
  496. list.concat(Tai_const.Createname(sym.name,AT_DATA,0));
  497. list.concat(tai_symbol_end.Create(labind));
  498. end;
  499. end;
  500. end;
  501. end;
  502. procedure import_proc_symbol(pd:tprocdef;pkg:tpackage);
  503. var
  504. item : TCmdStrListItem;
  505. begin
  506. item := TCmdStrListItem(pd.aliasnames.first);
  507. while assigned(item) do
  508. begin
  509. current_module.addexternalimport(pkg.pplfilename,item.str,item.str,0,false,false);
  510. item := TCmdStrListItem(item.next);
  511. end;
  512. end;
  513. procedure processimportedsyms(syms:tfpobjectlist);
  514. var
  515. i,j,k,l : longint;
  516. pkgentry : ppackageentry;
  517. sym : TSymEntry;
  518. srsymtable : tsymtable;
  519. module : tmodule;
  520. unitentry : pcontainedunit;
  521. name : tsymstr;
  522. labind : tasmsymbol;
  523. pd : tprocdef;
  524. list : tasmlist;
  525. begin
  526. writeln('unit has ', syms.count, ' imported symbols');
  527. for i:=0 to syms.count-1 do
  528. begin
  529. sym:=tsymentry(syms[i]);
  530. if not (sym.typ in [staticvarsym,procsym]) then
  531. continue;
  532. if alreadyloaded.indexof(sym)>=0 then
  533. begin
  534. writeln('symbol ', sym.name, ' already imported');
  535. continue;
  536. end;
  537. { determine the unit of the symbol }
  538. srsymtable:=sym.owner;
  539. while not (srsymtable.symtabletype in [staticsymtable,globalsymtable]) do
  540. srsymtable:=srsymtable.defowner.owner;
  541. module:=tmodule(loaded_units.first);
  542. while assigned(module) do
  543. begin
  544. if (module.globalsymtable=srsymtable) or (module.localsymtable=srsymtable) then
  545. break;
  546. module:=tmodule(module.next);
  547. end;
  548. if not assigned(module) then
  549. internalerror(2014101001);
  550. if (uf_in_library and module.flags)=0 then
  551. { unit is not part of a package, so no need to handle it }
  552. continue;
  553. writeln('found symbol ', sym.name, ' in package unit ', module.modulename^);
  554. { loaded by a package? }
  555. for j:=0 to packagelist.count-1 do
  556. begin
  557. pkgentry:=ppackageentry(packagelist[j]);
  558. for k:=0 to pkgentry^.package.containedmodules.count-1 do
  559. begin
  560. unitentry:=pcontainedunit(pkgentry^.package.containedmodules[k]);
  561. if unitentry^.module=module then
  562. begin
  563. writeln('symbol ', sym.name, ' is part of package ', pkgentry^.package.packagename^);
  564. case sym.typ of
  565. staticvarsym:
  566. begin
  567. name:=tstaticvarsym(sym).mangledname;
  568. current_module.addexternalimport(pkgentry^.package.pplfilename,name,name+indirect_suffix,0,true,false);
  569. end;
  570. procsym:
  571. begin
  572. for l:=0 to tprocsym(sym).procdeflist.count-1 do
  573. begin
  574. pd:=tprocdef(tprocsym(sym).procdeflist[l]);
  575. import_proc_symbol(pd,pkgentry^.package);
  576. end;
  577. end;
  578. else
  579. internalerror(2014101001);
  580. end;
  581. alreadyloaded.add(sym);
  582. end;
  583. end;
  584. end;
  585. end;
  586. end;
  587. var
  588. unitentry : pcontainedunit;
  589. i : longint;
  590. sym : tasmsymbol;
  591. module : tmodule;
  592. begin
  593. cache:=tfphashlist.create;
  594. { check each external asm symbol of each unit of the package whether it is
  595. contained in the unit of a loaded package (and thus an import entry
  596. is needed) }
  597. if assigned(pkg) then
  598. begin
  599. { ToDo }
  600. { we were called from a package file }
  601. (*for i:=0 to pkg.containedmodules.count-1 do
  602. begin
  603. unitentry:=pcontainedunit(pkg.containedmodules[i]);
  604. processasmsyms(tmodule(unitentry^.module).globalasmsyms);
  605. end;
  606. { also process the package's module }
  607. processasmsyms(tasmdata(current_module.asmdata).asmsymboldict);*)
  608. end
  609. else
  610. begin
  611. alreadyloaded:=tfpobjectlist.create(false);
  612. { we were called from a program/library }
  613. { first pass to find all symbols that were not loaded by asm name }
  614. module:=tmodule(loaded_units.first);
  615. while assigned(module) do
  616. begin
  617. writeln('processing imported symbols of unit ', module.modulename^);
  618. //if not assigned(module.package) then
  619. if (uf_in_library and module.flags)=0 then
  620. begin
  621. processimportedsyms(module.unitimportsyms);
  622. { this unit is not part of a package }
  623. (*if module=current_module then
  624. { this is the main file, which does not fill globalasmsyms }
  625. processasmsyms(tasmdata(module.asmdata).asmsymboldict)
  626. else
  627. { this is an ordinary unit }
  628. processasmsyms(module.globalasmsyms);*)
  629. end
  630. else
  631. writeln(module.modulename^, ' is a package unit; ignoring');
  632. module:=tmodule(module.next);
  633. end;
  634. { second pass to find all symbols that were loaded by asm name }
  635. module:=tmodule(loaded_units.first);
  636. while assigned(module) do
  637. begin
  638. if (uf_in_library and module.flags)=0 then
  639. begin
  640. writeln('processing assembler symbols of unit ', module.modulename^);
  641. if module=current_module then
  642. { this is the main file, which does not fill globalasmsyms }
  643. processasmsyms(tasmdata(module.asmdata).asmsymboldict)
  644. else
  645. { this is an ordinary unit }
  646. processasmsyms(module.globalasmsyms);
  647. end;
  648. module:=tmodule(module.next);
  649. end;
  650. alreadyloaded.free;
  651. end;
  652. for i:=0 to cache.count-1 do
  653. dispose(pcacheentry(cache[i]));
  654. end;
  655. end.