浏览代码

* use Tai_symbol.Create_global() when emitting a global symbol for an
abstract method wrapper (tai_symbol.create() currently overrides the
symbol type from global to local; will fix in next commit)
* only generate global abstract method wrappers for the class in which
the abstract method is declared to prevent duplicate symbol errors
after the above fix

git-svn-id: trunk@25265 -

Jonas Maebe 12 年之前
父节点
当前提交
d8c84706dd
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11 3
      compiler/ncgvmt.pas

+ 11 - 3
compiler/ncgvmt.pas

@@ -721,16 +721,24 @@ implementation
       begin
       begin
         { Generate stubs for abstract methods, so their symbols are present and
         { Generate stubs for abstract methods, so their symbols are present and
           can be used e.g. to take address (see issue #24536). }
           can be used e.g. to take address (see issue #24536). }
+        if (po_global in pd.procoptions) and
+           (pd.owner.defowner<>self._class) then
+          exit;
         sym:=current_asmdata.GetAsmSymbol(pd.mangledname);
         sym:=current_asmdata.GetAsmSymbol(pd.mangledname);
         if assigned(sym) and (sym.bind<>AB_EXTERNAL) then
         if assigned(sym) and (sym.bind<>AB_EXTERNAL) then
           exit;
           exit;
         maybe_new_object_file(list);
         maybe_new_object_file(list);
         new_section(list,sec_code,lower(pd.mangledname),target_info.alignment.procalign);
         new_section(list,sec_code,lower(pd.mangledname),target_info.alignment.procalign);
         if (po_global in pd.procoptions) then
         if (po_global in pd.procoptions) then
-          sym:=current_asmdata.DefineAsmSymbol(pd.mangledname,AB_GLOBAL,AT_FUNCTION)
+          begin
+            sym:=current_asmdata.DefineAsmSymbol(pd.mangledname,AB_GLOBAL,AT_FUNCTION);
+            list.concat(Tai_symbol.Create_global(sym,0));
+          end
         else
         else
-          sym:=current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION);
-        list.concat(Tai_symbol.Create(sym,0));
+          begin
+            sym:=current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION);
+            list.concat(Tai_symbol.Create(sym,0));
+          end;
         cg.g_external_wrapper(list,pd,'FPC_ABSTRACTERROR');
         cg.g_external_wrapper(list,pd,'FPC_ABSTRACTERROR');
         list.concat(Tai_symbol_end.Create(sym));
         list.concat(Tai_symbol_end.Create(sym));
       end;
       end;