diff options
author | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2015-12-11 15:52:15 +0000 |
---|---|---|
committer | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2015-12-11 15:52:15 +0000 |
commit | c8153bca74c5c88346e8ecdf65efecb3ba0de02a (patch) | |
tree | e52ca13806995e6faec6a374c8e648acadfed84d | |
parent | c80d37cb13ad6c0fef24bcaccfd6be67d07412d8 (diff) | |
download | fpc-svenbarth.tar.gz |
Correctly handle external functions that are used from other units.svenbarth
pkgutil.pas, createimportlibfromexternals:
* processasmsyms: also check the import name when checking for duplicates (just for safety, the cache check should have caught these already)
* processimportedsyms: if we have a routine imported from a library of whihc the symbol resides in a unit loaded from a package we need to import the routine ourselves instead of trying to import it from the package; also add an entry in the cache to speed up finding it again in processasmsyms()
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/svenbarth@32639 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | packages/compiler/pkgutil.pas | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/packages/compiler/pkgutil.pas b/packages/compiler/pkgutil.pas index aacd490582..8a9f2bad8d 100644 --- a/packages/compiler/pkgutil.pas +++ b/packages/compiler/pkgutil.pas @@ -48,7 +48,9 @@ implementation aasmbase,aasmdata,aasmtai, symtype,symconst,symsym,symdef,symbase,symtable, ppu,entfile,fpcp, + psub,pdecsub, ncgutil, + ogbase, export; procedure procexport(const s : string); @@ -646,7 +648,11 @@ implementation for k:=0 to tprocsym(psym).procdeflist.count-1 do begin pd:=tprocdef(tprocsym(psym).procdeflist[k]); - if has_alias_name(pd,symname) then + if has_alias_name(pd,symname) or + ( + ([po_external,po_has_importdll]*pd.procoptions=[po_external,po_has_importdll]) and + (symname=proc_get_importname(pd)) + ) then begin found:=true; break; @@ -717,6 +723,7 @@ implementation labind : tasmsymbol; pd : tprocdef; list : tasmlist; + centry : pcacheentry; begin for i:=0 to syms.count-1 do begin @@ -766,7 +773,18 @@ implementation for l:=0 to tprocsym(sym).procdeflist.count-1 do begin pd:=tprocdef(tprocsym(sym).procdeflist[l]); - import_proc_symbol(pd,pkgentry^.package); + if [po_external,po_has_importdll]*pd.procoptions=[po_external,po_has_importdll] then + begin + { if we use an external procedure of another unit we + need to import it ourselves from the correct library } + import_external_proc(pd); + New(centry); + centry^.sym:=nil; + centry^.pkg:=pkgentry^.package; + cache.add(proc_get_importname(pd),centry); + end + else + import_proc_symbol(pd,pkgentry^.package); end; end; else |