pkgutil.pas 23 KB

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