* fixed import by ordinal number for all Windows targets when using external linker.

git-svn-id: trunk@3830 -
This commit is contained in:
yury 2006-06-09 20:02:03 +00:00
parent 90b40e9385
commit 8bef50f29f
2 changed files with 59 additions and 35 deletions

View File

@ -2078,38 +2078,37 @@ const
result:=''; result:='';
if not(po_external in pd.procoptions) then if not(po_external in pd.procoptions) then
internalerror(200412151); internalerror(200412151);
{ import by number? } { external name or number is specified }
if pd.import_nr<>0 then if assigned(pd.import_name) or (pd.import_nr<>0) then
begin begin
{ Nothing to do } if assigned(pd.import_dll) then
end begin
else { If we are not using direct dll linking under win32 then imports
{ external name specified } need to use the normal name since to functions can refer to the
if assigned(pd.import_name) then same DLL function. This is also needed for compatability
begin with Delphi and TP7 }
if assigned(pd.import_dll) then case target_info.system of
begin system_i386_emx,
{ If we are not using direct dll linking under win32 then imports system_i386_os2 :
need to use the normal name since to functions can refer to the begin
same DLL function. This is also needed for compatability { keep normal mangledname }
with Delphi and TP7 } end;
case target_info.system of else
system_i386_emx, if assigned(pd.import_name) then
system_i386_os2 :
begin begin
{ keep normal mangledname } if target_info.system in system_all_windows then
end; { cprefix is not used in DLL imports under Windows }
result:=pd.import_name^
else
result:=maybe_cprefix(pd.import_name^);
end
else else
if target_info.system in system_all_windows then result:=splitfilename(pd.import_dll^)+'_index_'+tostr(pd.import_nr);
{ cprefix is not used in DLL imports under Windows } end;
result:=pd.import_name^ end
else else
result:=maybe_cprefix(pd.import_name^); result:=maybe_cprefix(pd.import_name^);
end; end
end
else
result:=maybe_cprefix(pd.import_name^);
end
else else
begin begin
{ Default names when importing variables } { Default names when importing variables }

View File

@ -149,7 +149,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
if (hp2.name^=name) then if (hp2.name^=name) and (hp2.ordnr=index) then
break; break;
hp2:=twin32imported_item(hp2.next); hp2:=twin32imported_item(hp2.next);
end; end;
@ -369,9 +369,28 @@ implementation
objdata.writebytes(emptyint,align(objdata.CurrObjSec.size,2)-objdata.CurrObjSec.size); objdata.writebytes(emptyint,align(objdata.CurrObjSec.size,2)-objdata.CurrObjSec.size);
{ idata4, import lookup table } { idata4, import lookup table }
objdata.SetSection(idata4objsection); objdata.SetSection(idata4objsection);
objdata.writereloc(0,sizeof(longint),idata6label,RELOC_RVA); if afuncname<>'' then
if target_info.system=system_x86_64_win64 then begin
objdata.writebytes(emptyint,sizeof(emptyint)); objdata.writereloc(0,sizeof(longint),idata6label,RELOC_RVA);
if target_info.system=system_x86_64_win64 then
objdata.writebytes(emptyint,sizeof(emptyint));
end
else
begin
emptyint:=ordnr;
if target_info.system=system_x86_64_win64 then
begin
objdata.writebytes(emptyint,sizeof(emptyint));
emptyint:=$80000000;
objdata.writebytes(emptyint,sizeof(emptyint));
end
else
begin
emptyint:=emptyint or $80000000;
objdata.writebytes(emptyint,sizeof(emptyint));
end;
emptyint:=0;
end;
{ idata5, import address table } { idata5, import address table }
objdata.SetSection(idata5objsection); objdata.SetSection(idata5objsection);
if isvar then if isvar then
@ -385,7 +404,10 @@ implementation
if not isvar then if not isvar then
begin begin
objdata.SetSection(textobjsection); objdata.SetSection(textobjsection);
implabel:=objdata.SymbolDefine(afuncname,AB_GLOBAL,AT_FUNCTION); if afuncname <> '' then
implabel:=objdata.SymbolDefine(afuncname,AB_GLOBAL,AT_FUNCTION)
else
implabel:=objdata.SymbolDefine(basedllname+'_index_'+tostr(ordnr),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);
@ -518,7 +540,10 @@ 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);
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(target_info.cprefix+hp2.func^,AT_FUNCTION,0)); if hp2.name^ <> '' then
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0))
else
current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(splitfilename(hp1.dllname^)+'_index_'+tostr(hp2.ordnr),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);