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

View File

@ -149,7 +149,7 @@ implementation
hp2:=twin32imported_item(hp1.imported_items.first);
while assigned(hp2) do
begin
if (hp2.name^=name) then
if (hp2.name^=name) and (hp2.ordnr=index) then
break;
hp2:=twin32imported_item(hp2.next);
end;
@ -369,9 +369,28 @@ implementation
objdata.writebytes(emptyint,align(objdata.CurrObjSec.size,2)-objdata.CurrObjSec.size);
{ idata4, import lookup table }
objdata.SetSection(idata4objsection);
objdata.writereloc(0,sizeof(longint),idata6label,RELOC_RVA);
if target_info.system=system_x86_64_win64 then
objdata.writebytes(emptyint,sizeof(emptyint));
if afuncname<>'' then
begin
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 }
objdata.SetSection(idata5objsection);
if isvar then
@ -385,7 +404,10 @@ implementation
if not isvar then
begin
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.writereloc(0,sizeof(longint),idata5label,RELOC_ABSOLUTE32);
objdata.writebytes(nopopcodes,align(objdata.CurrObjSec.size,sizeof(nopopcodes))-objdata.CurrObjSec.size);
@ -518,7 +540,10 @@ implementation
{ create indirect jump and }
{ place jump in al_procedures }
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(''));
{$ifdef ARM}
reference_reset_symbol(href,l5,0);