Prechádzať zdrojové kódy

Generate indirect symbols for global variables and (typed) constants.

Note: It needs to be checked what adjustments will need to be done for JVM and LLVM

Note 2: The indirect symbols will always be generated even if the target won't use them so that assembler code can be consistent among the targets (e.g. i386-win32 needs them while i386-linux does not)

ptconst.pas, read_typed_const:
  * generate the indirect symbol in a read only data section
ngenutil.pas, tnodeutils:
  * insertbsssym: generate the indirect symbol in a read only data section

git-svn-id: trunk@33279 -
svenbarth 9 rokov pred
rodič
commit
6722c611cf
2 zmenil súbory, kde vykonal 18 pridanie a 0 odobranie
  1. 9 0
      compiler/ngenutil.pas
  2. 9 0
      compiler/ptconst.pas

+ 9 - 0
compiler/ngenutil.pas

@@ -562,6 +562,8 @@ implementation
 
 
   class procedure tnodeutils.insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint; varalign: shortint);
+    var
+      symind : tasmsymbol;
     begin
       if sym.globalasmsym then
         begin
@@ -581,6 +583,13 @@ implementation
         end
       else
         list.concat(Tai_datablock.create(sym.mangledname,size));
+
+      { add the indirect symbol if needed }
+      new_section(list,sec_rodata,lower(sym.mangledname),const_align(sym.vardef.alignment));
+      symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA);
+      list.concat(Tai_symbol.Create_Global(symind,0));
+      list.concat(Tai_const.Createname(sym.mangledname,AT_DATA,0));
+      list.concat(tai_symbol_end.Create(symind));
     end;
 
 

+ 9 - 0
compiler/ptconst.pas

@@ -50,6 +50,7 @@ implementation
         datalist     : tasmlist;
         restree,
         previnit     : tnode;
+        symind       : tasmsymbol;
       begin
         { mark the staticvarsym as typedconst }
         include(sym.varoptions,vo_is_typed_const);
@@ -133,6 +134,14 @@ implementation
             { and pointed data, if any }
             current_asmdata.asmlists[al_const].concatlist(datalist);
             { the (empty) lists themselves are freed by tcbuilder }
+
+            { add indirect symbol }
+            { ToDo: do we also need this for the else part? }
+            new_section(list,sec_rodata,lower(sym.mangledname),const_align(sym.vardef.alignment));
+            symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA);
+            list.concat(Tai_symbol.Create_Global(symind,0));
+            list.concat(Tai_const.Createname(sym.mangledname,AT_DATA,0));
+            list.concat(tai_symbol_end.Create(symind));
           end
         else
           begin