mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-09 04:18:30 +02:00
* win imports are only by importname not anymore per procdef
git-svn-id: trunk@3622 -
This commit is contained in:
parent
4790838455
commit
392ef22a7f
@ -1206,7 +1206,11 @@ implementation
|
|||||||
ObjSectionList.Add(objsec);
|
ObjSectionList.Add(objsec);
|
||||||
if (SecOptions<>[]) then
|
if (SecOptions<>[]) then
|
||||||
begin
|
begin
|
||||||
if (oso_Data in SecOptions)<>(oso_Data in objsec.SecOptions) then
|
{ Only if the section contains (un)initialized data the
|
||||||
|
data flag must match. This check is not needed if the
|
||||||
|
section is empty for a symbol allocation }
|
||||||
|
if (objsec.size>0) and
|
||||||
|
((oso_Data in SecOptions)<>(oso_Data in objsec.SecOptions)) then
|
||||||
Comment(V_Error,'Incompatible section options');
|
Comment(V_Error,'Incompatible section options');
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1396,7 +1400,6 @@ implementation
|
|||||||
ObjSection:=internalObjData.findsection('*'+aname);
|
ObjSection:=internalObjData.findsection('*'+aname);
|
||||||
if not assigned(ObjSection) then
|
if not assigned(ObjSection) then
|
||||||
internalerror(200603041);
|
internalerror(200603041);
|
||||||
ObjSection.SecOptions:=CurrExeSec.SecOptions;
|
|
||||||
CurrExeSec.AddObjSection(ObjSection);
|
CurrExeSec.AddObjSection(ObjSection);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2005,6 +2005,8 @@ const win32stub : array[0..131] of byte=(
|
|||||||
for i:=0 to ObjSectionList.Count-1 do
|
for i:=0 to ObjSectionList.Count-1 do
|
||||||
begin
|
begin
|
||||||
objsec:=TObjSection(ObjSectionList[i]);
|
objsec:=TObjSection(ObjSectionList[i]);
|
||||||
|
if oso_data in objsec.secoptions then
|
||||||
|
begin
|
||||||
if not assigned(objsec.data) then
|
if not assigned(objsec.data) then
|
||||||
internalerror(200603042);
|
internalerror(200603042);
|
||||||
FWriter.writezeros(objsec.dataalignbytes);
|
FWriter.writezeros(objsec.dataalignbytes);
|
||||||
@ -2015,6 +2017,7 @@ const win32stub : array[0..131] of byte=(
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tcoffexeoutput.CalcPos_Header;
|
procedure tcoffexeoutput.CalcPos_Header;
|
||||||
@ -2421,6 +2424,11 @@ const win32stub : array[0..131] of byte=(
|
|||||||
Concat(' SYMBOL edata');
|
Concat(' SYMBOL edata');
|
||||||
Concat(' SYMBOL __data_end__');
|
Concat(' SYMBOL __data_end__');
|
||||||
Concat('ENDEXESECTION');
|
Concat('ENDEXESECTION');
|
||||||
|
Concat('EXESECTION .bss');
|
||||||
|
Concat(' SYMBOL __bss_start__');
|
||||||
|
Concat(' OBJSECTION .bss*');
|
||||||
|
Concat(' SYMBOL __bss_end__');
|
||||||
|
Concat('ENDEXESECTION');
|
||||||
Concat('EXESECTION .idata');
|
Concat('EXESECTION .idata');
|
||||||
Concat(' OBJSECTION .idata$2');
|
Concat(' OBJSECTION .idata$2');
|
||||||
Concat(' OBJSECTION .idata$3');
|
Concat(' OBJSECTION .idata$3');
|
||||||
@ -2430,11 +2438,6 @@ const win32stub : array[0..131] of byte=(
|
|||||||
Concat(' OBJSECTION .idata$6');
|
Concat(' OBJSECTION .idata$6');
|
||||||
Concat(' OBJSECTION .idata$7');
|
Concat(' OBJSECTION .idata$7');
|
||||||
Concat('ENDEXESECTION');
|
Concat('ENDEXESECTION');
|
||||||
Concat('EXESECTION .bss');
|
|
||||||
Concat(' SYMBOL __bss_start__');
|
|
||||||
Concat(' OBJSECTION .bss*');
|
|
||||||
Concat(' SYMBOL __bss_end__');
|
|
||||||
Concat('ENDEXESECTION');
|
|
||||||
Concat('EXESECTION .rsrc');
|
Concat('EXESECTION .rsrc');
|
||||||
Concat(' OBJSECTION .rsrc*');
|
Concat(' OBJSECTION .rsrc*');
|
||||||
Concat('ENDEXESECTION');
|
Concat('ENDEXESECTION');
|
||||||
|
@ -2094,9 +2094,8 @@ const
|
|||||||
same DLL function. This is also needed for compatability
|
same DLL function. This is also needed for compatability
|
||||||
with Delphi and TP7 }
|
with Delphi and TP7 }
|
||||||
case target_info.system of
|
case target_info.system of
|
||||||
system_i386_wdosx,
|
system_i386_emx,
|
||||||
system_i386_emx,system_i386_os2,
|
system_i386_os2 :
|
||||||
system_arm_wince,system_i386_wince :
|
|
||||||
begin
|
begin
|
||||||
{ keep normal mangledname }
|
{ keep normal mangledname }
|
||||||
end;
|
end;
|
||||||
|
@ -42,14 +42,13 @@ interface
|
|||||||
pStr4=^tStr4;
|
pStr4=^tStr4;
|
||||||
|
|
||||||
twin32imported_item = class(timported_item)
|
twin32imported_item = class(timported_item)
|
||||||
procdef : tprocdef;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
timportlibwin32=class(timportlib)
|
timportlibwin32=class(timportlib)
|
||||||
private
|
private
|
||||||
procedure win32importproc(aprocdef:tprocdef;const func,module : string;index : longint;const name : string);
|
procedure win32importproc(const module : string;index : longint;const name : string);
|
||||||
procedure importvariable_str(const s:string;const name,module:string);
|
procedure importvariable_str(const s:string;const name,module:string);
|
||||||
procedure importprocedure_str(const func,module:string;index:longint;const name:string);
|
procedure importprocedure_str(const module:string;index:longint;const name:string);
|
||||||
procedure generateimportlib;
|
procedure generateimportlib;
|
||||||
procedure generateidatasection;
|
procedure generateidatasection;
|
||||||
public
|
public
|
||||||
@ -124,15 +123,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure timportlibwin32.win32importproc(aprocdef:tprocdef;const func,module : string;index : longint;const name : string);
|
procedure timportlibwin32.win32importproc(const module : string;index : longint;const name : string);
|
||||||
var
|
var
|
||||||
hp1 : timportList;
|
hp1 : timportList;
|
||||||
hp2 : twin32imported_item;
|
hp2 : twin32imported_item;
|
||||||
hs : string;
|
hs : string;
|
||||||
begin
|
begin
|
||||||
{ procdef or funcname must be give, not both }
|
|
||||||
if assigned(aprocdef) and (func<>'') then
|
|
||||||
internalerror(200411161);
|
|
||||||
{ append extension if required }
|
{ append extension if required }
|
||||||
hs:=AddExtension(module,target_info.sharedlibext);
|
hs:=AddExtension(module,target_info.sharedlibext);
|
||||||
{ search for the module }
|
{ search for the module }
|
||||||
@ -150,30 +146,16 @@ implementation
|
|||||||
current_module.imports.concat(hp1);
|
current_module.imports.concat(hp1);
|
||||||
end;
|
end;
|
||||||
{ search for reuse of old import item }
|
{ search for reuse of old import item }
|
||||||
if assigned(aprocdef) then
|
|
||||||
begin
|
|
||||||
hp2:=twin32imported_item(hp1.imported_items.first);
|
hp2:=twin32imported_item(hp1.imported_items.first);
|
||||||
while assigned(hp2) do
|
while assigned(hp2) do
|
||||||
begin
|
begin
|
||||||
if (hp2.procdef=aprocdef) then
|
if (hp2.name^=name) then
|
||||||
break;
|
break;
|
||||||
hp2:=twin32imported_item(hp2.next);
|
hp2:=twin32imported_item(hp2.next);
|
||||||
end;
|
end;
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
hp2:=twin32imported_item(hp1.imported_items.first);
|
|
||||||
while assigned(hp2) do
|
|
||||||
begin
|
|
||||||
if (hp2.func^=func) then
|
|
||||||
break;
|
|
||||||
hp2:=twin32imported_item(hp2.next);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if not assigned(hp2) then
|
if not assigned(hp2) then
|
||||||
begin
|
begin
|
||||||
hp2:=twin32imported_item.create(func,name,index);
|
hp2:=twin32imported_item.create(name,name,index);
|
||||||
hp2.procdef:=aprocdef;
|
|
||||||
hp1.imported_items.concat(hp2);
|
hp1.imported_items.concat(hp2);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -181,13 +163,13 @@ implementation
|
|||||||
|
|
||||||
procedure timportlibwin32.importprocedure(aprocdef:tprocdef;const module : string;index : longint;const name : string);
|
procedure timportlibwin32.importprocedure(aprocdef:tprocdef;const module : string;index : longint;const name : string);
|
||||||
begin
|
begin
|
||||||
win32importproc(aprocdef,'',module,index,name);
|
win32importproc(module,index,name);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure timportlibwin32.importprocedure_str(const func,module : string;index : longint;const name : string);
|
procedure timportlibwin32.importprocedure_str(const module : string;index : longint;const name : string);
|
||||||
begin
|
begin
|
||||||
win32importproc(nil,func,module,index,name);
|
win32importproc(module,index,name);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +201,6 @@ implementation
|
|||||||
current_module.imports.concat(hp1);
|
current_module.imports.concat(hp1);
|
||||||
end;
|
end;
|
||||||
hp2:=twin32imported_item.create_var(s,name);
|
hp2:=twin32imported_item.create_var(s,name);
|
||||||
hp2.procdef:=nil;
|
|
||||||
hp1.imported_items.concat(hp2);
|
hp1.imported_items.concat(hp2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -332,7 +313,7 @@ implementation
|
|||||||
objdata.free;
|
objdata.free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure AddImport(const afuncname, implabelname:string;ordnr:word;isvar:boolean);
|
procedure AddImport(const afuncname:string;ordnr:word;isvar:boolean);
|
||||||
const
|
const
|
||||||
{$ifdef x86_64}
|
{$ifdef x86_64}
|
||||||
jmpopcode : array[0..2] of byte = (
|
jmpopcode : array[0..2] of byte = (
|
||||||
@ -404,7 +385,7 @@ implementation
|
|||||||
if not isvar then
|
if not isvar then
|
||||||
begin
|
begin
|
||||||
objdata.SetSection(textobjsection);
|
objdata.SetSection(textobjsection);
|
||||||
implabel:=objdata.SymbolDefine(implabelname,AB_GLOBAL,AT_FUNCTION);
|
implabel:=objdata.SymbolDefine(afuncname,AB_GLOBAL,AT_FUNCTION);
|
||||||
objdata.writebytes(jmpopcode,sizeof(jmpopcode));
|
objdata.writebytes(jmpopcode,sizeof(jmpopcode));
|
||||||
objdata.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
|
objdata.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
|
||||||
objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,sizeof(nopopcodes))-objdata.CurrObjSec.size);
|
objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,sizeof(nopopcodes))-objdata.CurrObjSec.size);
|
||||||
@ -417,9 +398,6 @@ implementation
|
|||||||
var
|
var
|
||||||
hp1 : timportList;
|
hp1 : timportList;
|
||||||
hp2 : twin32imported_item;
|
hp2 : twin32imported_item;
|
||||||
{$ifdef arm}
|
|
||||||
mangledstring : string;
|
|
||||||
{$endif arm}
|
|
||||||
begin
|
begin
|
||||||
AsmPrefix:='imp'+Lower(current_module.modulename^);
|
AsmPrefix:='imp'+Lower(current_module.modulename^);
|
||||||
idatalabnr:=0;
|
idatalabnr:=0;
|
||||||
@ -435,15 +413,7 @@ implementation
|
|||||||
hp2:=twin32imported_item(hp1.imported_items.first);
|
hp2:=twin32imported_item(hp1.imported_items.first);
|
||||||
while assigned(hp2) do
|
while assigned(hp2) do
|
||||||
begin
|
begin
|
||||||
{$ifdef arm}
|
AddImport(hp2.name^,hp2.ordnr,hp2.is_var);
|
||||||
if assigned(hp2.procdef) then
|
|
||||||
mangledstring:=hp2.procdef.mangledname
|
|
||||||
else
|
|
||||||
mangledstring:=hp2.name^;
|
|
||||||
AddImport(hp2.name^,mangledstring,hp2.ordnr,hp2.is_var);
|
|
||||||
{$else arm}
|
|
||||||
AddImport(hp2.name^,hp2.name^,hp2.ordnr,hp2.is_var);
|
|
||||||
{$endif arm}
|
|
||||||
hp2:=twin32imported_item(hp2.next);
|
hp2:=twin32imported_item(hp2.next);
|
||||||
end;
|
end;
|
||||||
EndImport;
|
EndImport;
|
||||||
@ -459,7 +429,6 @@ implementation
|
|||||||
hp1 : timportList;
|
hp1 : timportList;
|
||||||
hp2 : twin32imported_item;
|
hp2 : twin32imported_item;
|
||||||
l1,l2,l3,l4 {$ifdef ARM} ,l5 {$endif ARM} : tasmlabel;
|
l1,l2,l3,l4 {$ifdef ARM} ,l5 {$endif ARM} : tasmlabel;
|
||||||
mangledstring : string;
|
|
||||||
importname : string;
|
importname : string;
|
||||||
suffix : integer;
|
suffix : integer;
|
||||||
href : treference;
|
href : treference;
|
||||||
@ -549,11 +518,7 @@ implementation
|
|||||||
{ create indirect jump and }
|
{ create indirect jump and }
|
||||||
{ place jump in al_procedures }
|
{ place jump in al_procedures }
|
||||||
new_section(current_asmdata.asmlists[al_imports],sec_code,'',0);
|
new_section(current_asmdata.asmlists[al_imports],sec_code,'',0);
|
||||||
if assigned(hp2.procdef) then
|
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(target_info.cprefix+hp2.func^,AT_FUNCTION,0));
|
||||||
mangledstring:=hp2.procdef.mangledname
|
|
||||||
else
|
|
||||||
mangledstring:=hp2.func^;
|
|
||||||
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(mangledstring,AT_FUNCTION,0));
|
|
||||||
current_asmdata.asmlists[al_imports].concat(tai_function_name.create(''));
|
current_asmdata.asmlists[al_imports].concat(tai_function_name.create(''));
|
||||||
{$ifdef ARM}
|
{$ifdef ARM}
|
||||||
reference_reset_symbol(href,l5,0);
|
reference_reset_symbol(href,l5,0);
|
||||||
@ -1642,10 +1607,7 @@ end;
|
|||||||
current_module.uses_imports:=true;
|
current_module.uses_imports:=true;
|
||||||
importlib.preparelib(current_module.modulename^);
|
importlib.preparelib(current_module.modulename^);
|
||||||
end;
|
end;
|
||||||
// if IsData then
|
timportlibwin32(importlib).importprocedure_str(dllname,0,funcname);
|
||||||
// timportlibwin32(importlib).importvariable_str(funcname,dllname,funcname)
|
|
||||||
// else
|
|
||||||
timportlibwin32(importlib).importprocedure_str(funcname,dllname,0,funcname);
|
|
||||||
importfound:=true;
|
importfound:=true;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user