ソースを参照

* Replace ? and @ in external names only if the external is imported from DLL on Windows.
Also @ character is allowed in symbol names by GNU AS for x86.

git-svn-id: trunk@12842 -

yury 16 年 前
コミット
afa7ade545
2 ファイル変更13 行追加8 行削除
  1. 6 4
      compiler/ogbase.pas
  2. 7 4
      compiler/pdecsub.pas

+ 6 - 4
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;
 

+ 7 - 4
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;