소스 검색

Write indirect symbols for the RTTI (basically a merge of r28238, but using the typed constant builder and the new indirect asmbinds)

ncgrtti.pas, TRTTIWriter:
  * write_rtti & write_rtti_extrasyms: generate an indirect symbol for each of the RTTI symbols (they are not used yet, but soon will be)
  * write_rtti: reorder operations a bit: first free the tcb (we don't need it anymore), then write the indirect symbol and only then write any extra symbols that might be needed (this way the RTTI data and the indirect symbol will be next to each other)
  

git-svn-id: trunk@33447 -
svenbarth 9 년 전
부모
커밋
140f5b5f94
1개의 변경된 파일29개의 추가작업 그리고 4개의 파일을 삭제
  1. 29 4
      compiler/ncgrtti.pas

+ 29 - 4
compiler/ncgrtti.pas

@@ -1268,7 +1268,7 @@ implementation
           in sstrings.inc. }
         procedure enumdef_rtti_ord2stringindex(rttidef: trecorddef; const syms: tfplist);
 
-        var rttilab:Tasmsymbol;
+        var rttilab,rttilabind:Tasmsymbol;
             h,i,o,prev_value:longint;
             mode:(lookup,search); {Modify with care, ordinal value of enum is written.}
             r:single;             {Must be real type because of integer overflow risk.}
@@ -1369,6 +1369,14 @@ implementation
               rttilab,tcb.end_anonymous_record,sec_rodata,
               rttilab.name,const_align(sizeof(pint))));
             tcb.free;
+
+            { write indirect symbol }
+            tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
+            rttilabind:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_o2s',AB_INDIRECT,AT_DATA);
+            tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
+            current_asmdata.AsmLists[al_rtti].concatList(
+              tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
+            tcb.free;
         end;
 
 
@@ -1379,7 +1387,8 @@ implementation
 
         var
           tcb: ttai_typedconstbuilder;
-          rttilab:Tasmsymbol;
+          rttilab,
+          rttilabind : Tasmsymbol;
           i:longint;
         begin
           { write rtti data }
@@ -1412,6 +1421,13 @@ implementation
             rttilab,tcb.end_anonymous_record,sec_rodata,
             rttilab.name,const_align(sizeof(pint))));
           tcb.free;
+          { write indirect symbol }
+          tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
+          rttilabind:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_s2o',AB_INDIRECT,AT_DATA);
+          tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
+          current_asmdata.AsmLists[al_rtti].concatList(
+            tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
+          tcb.free;
         end;
 
         procedure enumdef_rtti_extrasyms(def:Tenumdef);
@@ -1525,7 +1541,8 @@ implementation
     procedure TRTTIWriter.write_rtti(def:tdef;rt:trttitype);
       var
         tcb: ttai_typedconstbuilder;
-        rttilab: tasmsymbol;
+        rttilab,
+        rttilabind : tasmsymbol;
         rttidef: tdef;
       begin
         { only write rtti of definitions from the current module }
@@ -1553,8 +1570,16 @@ implementation
         rttidef:=tcb.end_anonymous_record;
         current_asmdata.AsmLists[al_rtti].concatList(
           tcb.get_final_asmlist(rttilab,rttidef,sec_rodata,rttilab.name,const_align(sizeof(pint))));
-        write_rtti_extrasyms(def,rt,rttilab);
         tcb.free;
+        { write indirect symbol }
+        tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
+        rttilabind:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_INDIRECT,AT_DATA);
+        tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
+        current_asmdata.AsmLists[al_rtti].concatList(
+          tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
+        tcb.free;
+        { write additional data }
+        write_rtti_extrasyms(def,rt,rttilab);
       end;