diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 979a340f7c..f6b04f737d 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -1383,13 +1383,15 @@ implementation FOrdNr:=AOrdNr; FIsVar:=AIsVar; FMangledName:=AName; - { Replace ? and @ in import name } - { these replaces broke existing code on i386-win32 at least, while fixed - bug 8391 on arm-wince so limit this to arm-wince (KB) } - if (target_info.system in [system_arm_wince]) then + { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. } + { This allows to import VC++ mangled names from DLLs. } + if target_info.system in system_all_windows then begin Replace(FMangledName,'?','__q$$'); +{$ifdef arm} + { @ symbol is not allowed in ARM assembler only } Replace(FMangledName,'@','__a$$'); +{$endif arm} end; end; diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index f53dde8d4f..9de4693693 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -2266,13 +2266,16 @@ const s:=proc_get_importname(pd); if s<>'' then begin - { Replace ? and @ in import name } - { these replaces broke existing code on i386-win32 at least, while fixed - bug 8391 on arm-wince so limit this to arm-wince (KB) } - if target_info.system in [system_arm_wince] then + { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. } + { This allows to import VC++ mangled names from DLLs. } + { Do not perform replacement, if external symbol is not imported from DLL. } + if (target_info.system in system_all_windows) and (pd.import_dll<>nil) then begin Replace(s,'?','__q$$'); +{$ifdef arm} + { @ symbol is not allowed in ARM assembler only } Replace(s,'@','__a$$'); +{$endif arm} end; pd.setmangledname(s); end;