浏览代码

Adjust resourcestrings so they use indirect references as well.

cresstr.pas, Tresourcestrings:
  * CreateResourceStringData: generate indirect symbols for the single resourcestrings if the target supports packages
ncgld.pas, tcgloadnode:
  * pass_generate_code: load resourcestrings using their indirect symbols if required

git-svn-id: branches/svenbarth/packages@32501 -
svenbarth 9 年之前
父节点
当前提交
fe4f179082
共有 2 个文件被更改,包括 27 次插入1 次删除
  1. 16 0
      compiler/cresstr.pas
  2. 11 1
      compiler/ncgld.pas

+ 16 - 0
compiler/cresstr.pas

@@ -139,6 +139,7 @@ uses
         resstrlab : tasmsymbol;
         endsymlab : tasmsymbol;
         R : TResourceStringItem;
+        listind : TAsmList;
       begin
         { Put resourcestrings in a new objectfile. Putting it in multiple files
           makes the linking too dependent on the linker script requiring a SORT(*) for
@@ -168,6 +169,7 @@ uses
 {$endif cpu64bitaddr}
 
         { Add entries }
+        listind:=TAsmList.create_without_marker;
         R:=TResourceStringItem(List.First);
         while assigned(R) do
           begin
@@ -204,6 +206,16 @@ uses
             current_asmdata.asmlists[al_resourcestrings].concat(tai_const.create_32bit(0));
 {$endif cpu64bitaddr}
             current_asmdata.asmlists[al_resourcestrings].concat(tai_symbol_end.create(resstrlab));
+
+            if tf_supports_packages in target_info.flags then
+              begin
+                { indirect symbol }
+                labind:=current_asmdata.DefineAsmSymbol(resstrlab.name+indirect_suffix,AB_GLOBAL,AT_DATA);
+                listind.concat(Tai_symbol.Create_Global(labind,0));
+                listind.concat(Tai_const.Create_sym(resstrlab));
+                listind.concat(tai_symbol_end.Create(labind));
+              end;
+
             R:=TResourceStringItem(R.Next);
           end;
         new_section(current_asmdata.asmlists[al_resourcestrings],sec_data,make_mangledname('RESSTR',current_module.localsymtable,'3_END'),sizeof(pint));
@@ -214,6 +226,10 @@ uses
         current_asmdata.asmlists[al_resourcestrings].concat(Tai_symbol.Create_Global(labind,0));
         current_asmdata.asmlists[al_resourcestrings].concat(Tai_const.Create_sym(endsymlab));
         current_asmdata.asmlists[al_resourcestrings].concat(tai_symbol_end.Create(labind));
+        { append the list of indirect resource string symbols }
+        if tf_supports_packages in target_info.flags then
+          current_asmdata.asmlists[al_resourcestrings].concatList(listind);
+        listind.free;
         { The darwin/ppc64 assembler or linker seems to have trouble       }
         { if a section ends with a global label without any data after it. }
         { So for safety, just put a dummy value here.                      }

+ 11 - 1
compiler/ncgld.pas

@@ -288,7 +288,17 @@ implementation
                 if tconstsym(symtableentry).consttyp=constresourcestring then
                   begin
                      location_reset_ref(location,LOC_CREFERENCE,def_cgsize(cansistringtype),cansistringtype.size);
-                     location.reference.symbol:=current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',symtableentry.owner,symtableentry.name),AT_DATA);
+                     if tf_supports_packages in target_info.flags then
+                       begin
+                         hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
+                         location.reference.symbol:=current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',symtableentry.owner,symtableentry.name)+indirect_suffix,AT_DATA);
+                         cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,location.reference,hregister);
+                         reference_reset_base(location.reference,hregister,0,location.reference.alignment);
+                       end
+                     else
+                       begin
+                         location.reference.symbol:=current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',symtableentry.owner,symtableentry.name),AT_DATA);
+                       end;
                      { Resourcestring layout:
                          TResourceStringRecord = Packed Record
                             Name,