Browse Source

Adapt resource string tables to use indirect references as well.

compiler/cresstr.pas, Tresourcestrings:
  * CreateResourceStringData: generate indirect labels for the START and END markers of the unit's resource strings
compiler/ngenutil.pas, tnodeutils:
  * InsertResourceTablesTable: reference the indirect symbols of the START and END markers
rtl/objpas/objpas.pp:
  + add pointer to PResourceStringRecord
  * TResourceStringTableList: use PPResourceStringRecord instead of PResourceStringRecord
  * adjust usages of TableStart and TableEnd (the first dereferentiation is by definition always valid)

git-svn-id: branches/svenbarth/packages@32498 -
svenbarth 9 years ago
parent
commit
e9e39707c7
3 changed files with 30 additions and 11 deletions
  1. 14 1
      compiler/cresstr.pas
  2. 2 2
      compiler/ngenutil.pas
  3. 14 8
      rtl/objpas/objpas.pp

+ 14 - 1
compiler/cresstr.pas

@@ -134,6 +134,8 @@ uses
       Var
         namelab,
         valuelab : tasmlabofs;
+        s : tsymstr;
+        labind,
         resstrlab : tasmsymbol;
         endsymlab : tasmsymbol;
         R : TResourceStringItem;
@@ -146,8 +148,14 @@ uses
 
         maybe_new_object_file(current_asmdata.asmlists[al_resourcestrings]);
         new_section(current_asmdata.asmlists[al_resourcestrings],sec_data,make_mangledname('RESSTR',current_module.localsymtable,'1_START'),sizeof(pint));
+        s:=make_mangledname('RESSTR',current_module.localsymtable,'START');
         current_asmdata.AsmLists[al_resourcestrings].concat(tai_symbol.createname_global(
-          make_mangledname('RESSTR',current_module.localsymtable,'START'),AT_DATA,0));
+          s,AT_DATA,0));
+        { indirect symbol }
+        labind:=current_asmdata.DefineAsmSymbol(s+indirect_suffix,AB_GLOBAL,AT_DATA);
+        current_asmdata.asmlists[al_resourcestrings].concat(Tai_symbol.Create_Global(labind,0));
+        current_asmdata.asmlists[al_resourcestrings].concat(Tai_const.Createname(s,AT_DATA,0));
+        current_asmdata.asmlists[al_resourcestrings].concat(tai_symbol_end.Create(labind));
 
         { Write unitname entry }
         namelab:=emit_ansistring_const(current_asmdata.asmlists[al_const],@current_module.localsymtable.name^[1],length(current_module.localsymtable.name^),getansistringcodepage,False);
@@ -201,6 +209,11 @@ uses
         new_section(current_asmdata.asmlists[al_resourcestrings],sec_data,make_mangledname('RESSTR',current_module.localsymtable,'3_END'),sizeof(pint));
         endsymlab:=current_asmdata.DefineAsmSymbol(make_mangledname('RESSTR',current_module.localsymtable,'END'),AB_GLOBAL,AT_DATA);
         current_asmdata.AsmLists[al_resourcestrings].concat(tai_symbol.create_global(endsymlab,0));
+        { indirect symbol }
+        labind:=current_asmdata.DefineAsmSymbol(endsymlab.name+indirect_suffix,AB_GLOBAL,AT_DATA);
+        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));
         { 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.                      }

+ 2 - 2
compiler/ngenutil.pas

@@ -942,8 +942,8 @@ implementation
         begin
           If (hp.flags and uf_has_resourcestrings)=uf_has_resourcestrings then
             begin
-              ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESSTR',hp.localsymtable,'START'),AT_DATA,0));
-              ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESSTR',hp.localsymtable,'END'),AT_DATA,0));
+              ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESSTR',hp.localsymtable,'START')+indirect_suffix,AT_DATA,0));
+              ResourceStringTables.concat(Tai_const.Createname(make_mangledname('RESSTR',hp.localsymtable,'END')+indirect_suffix,AT_DATA,0));
               inc(count);
             end;
           hp:=tmodule(hp.next);

+ 14 - 8
rtl/objpas/objpas.pp

@@ -301,12 +301,18 @@ Type
      Dummy        : LongWord; // alignment
 {$endif cpu64}
    end;
+  PPResourceStringRecord = ^PResourceStringRecord;
 
    TResourceStringTableList = Packed Record
      Count : sizeint;
      Tables : Array[{$ifdef cpu16}Byte{$else cpu16}Word{$endif cpu16}] of record
+{$ifndef ver2_6}
+       TableStart,
+       TableEnd   : PPResourceStringRecord;
+{$else ver2_6}
        TableStart,
        TableEnd   : PResourceStringRecord;
+{$endif ver2_6}
      end;
    end;
    PResourceStringTableList = ^TResourceStringTableList;
@@ -372,10 +378,10 @@ begin
     begin
       For i:=0 to Count-1 do
         begin
-          ResStr:=Tables[I].TableStart;
+          ResStr:=Tables[I].TableStart{$ifndef ver2_6}^{$endif};
           { Skip first entry (name of the Unit) }
           inc(ResStr);
-          while ResStr<Tables[I].TableEnd do
+          while ResStr<Tables[I].TableEnd{$ifndef ver2_6}^{$endif} do
             begin
               s:=SetFunction(ResStr^.Name,ResStr^.DefaultValue,Longint(ResStr^.HashValue),arg);
               if s<>'' then
@@ -402,12 +408,12 @@ begin
       UpUnitName:=UpCase(UnitName);
       For i:=0 to Count-1 do
         begin
-          ResStr:=Tables[I].TableStart;
+          ResStr:=Tables[I].TableStart{$ifndef ver2_6}^{$endif};
           { Check name of the Unit }
           if ResStr^.Name<>UpUnitName then
             continue;
           inc(ResStr);
-          while ResStr<Tables[I].TableEnd do
+          while ResStr<Tables[I].TableEnd{$ifndef ver2_6}^{$endif} do
             begin
               s:=SetFunction(ResStr^.Name,ResStr^.DefaultValue,Longint(ResStr^.HashValue),arg);
               if s<>'' then
@@ -433,10 +439,10 @@ begin
     begin
       For i:=0 to Count-1 do
         begin
-          ResStr:=Tables[I].TableStart;
+          ResStr:=Tables[I].TableStart{$ifndef ver2_6}^{$endif};
           { Skip first entry (name of the Unit) }
           inc(ResStr);
-          while ResStr<Tables[I].TableEnd do
+          while ResStr<Tables[I].TableEnd{$ifndef ver2_6}^{$endif} do
             begin
               ResStr^.CurrentValue:=ResStr^.DefaultValue;
               inc(ResStr);
@@ -455,10 +461,10 @@ begin
     begin
       For i:=0 to Count-1 do
         begin
-          ResStr:=Tables[I].TableStart;
+          ResStr:=Tables[I].TableStart{$ifndef ver2_6}^{$endif};
           { Skip first entry (name of the Unit) }
           inc(ResStr);
-          while ResStr<Tables[I].TableEnd do
+          while ResStr<Tables[I].TableEnd{$ifndef ver2_6}^{$endif} do
             begin
               ResStr^.CurrentValue:='';
               inc(ResStr);