浏览代码

Convert WideStrInits and ResStrInits to indirect symbols.

compiler/ngenutil.pas, tnodeutils:
  * InsertRuntimeInits: also generate an indirect symbol
  * InsertRuntimeInitsTablesTable: use the indirect symbol in the table
rtl/objpas/objpas.pp:
  * UpdateResourceStringRefs: respect the new indirect reference of the table entry
rtl/win/syswin.inc:
  * InitWin32Widestrings: respect the new indirect reference of the table entry

git-svn-id: branches/svenbarth/packages@32638 -
svenbarth 9 年之前
父节点
当前提交
de6c7af448
共有 3 个文件被更改,包括 14 次插入6 次删除
  1. 8 2
      compiler/ngenutil.pas
  2. 3 2
      rtl/objpas/objpas.pp
  3. 3 2
      rtl/win/syswin.inc

+ 8 - 2
compiler/ngenutil.pas

@@ -852,7 +852,7 @@ implementation
        begin
        begin
          if (hp.u.flags and unitflag)=unitflag then
          if (hp.u.flags and unitflag)=unitflag then
           begin
           begin
-            hlist.concat(Tai_const.Createname(make_mangledname(prefix,hp.u.globalsymtable,''),0));
+            hlist.concat(Tai_const.Createname(make_mangledname(prefix,hp.u.globalsymtable,'')+indirect_suffix,0));
             inc(count);
             inc(count);
           end;
           end;
          hp:=tused_unit(hp.next);
          hp:=tused_unit(hp.next);
@@ -860,7 +860,7 @@ implementation
       { Add items from program, if any }
       { Add items from program, if any }
       if (current_module.flags and unitflag)=unitflag then
       if (current_module.flags and unitflag)=unitflag then
        begin
        begin
-         hlist.concat(Tai_const.Createname(make_mangledname(prefix,current_module.localsymtable,''),0));
+         hlist.concat(Tai_const.Createname(make_mangledname(prefix,current_module.localsymtable,'')+indirect_suffix,0));
          inc(count);
          inc(count);
        end;
        end;
       { Insert TableCount at start }
       { Insert TableCount at start }
@@ -879,6 +879,7 @@ implementation
     var
     var
       s: string;
       s: string;
       item: TTCInitItem;
       item: TTCInitItem;
+      labind : tasmsymbol;
     begin
     begin
       item:=TTCInitItem(list.First);
       item:=TTCInitItem(list.First);
       if item=nil then
       if item=nil then
@@ -902,6 +903,11 @@ implementation
       current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(nil));
       current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(nil));
       current_asmdata.asmlists[al_globals].concat(Tai_symbol_end.Createname(s));
       current_asmdata.asmlists[al_globals].concat(Tai_symbol_end.Createname(s));
       current_module.flags:=current_module.flags or unitflag;
       current_module.flags:=current_module.flags or unitflag;
+      { indirect symbol }
+      labind:=current_asmdata.DefineAsmSymbol(s+indirect_suffix,AB_GLOBAL,AT_DATA);
+      current_asmdata.asmlists[al_globals].concat(Tai_symbol.Create_Global(labind,0));
+      current_asmdata.asmlists[al_globals].concat(Tai_const.Createname(s,AT_DATA,0));
+      current_asmdata.asmlists[al_globals].concat(tai_symbol_end.Create(labind));
     end;
     end;
 
 
 
 

+ 3 - 2
rtl/objpas/objpas.pp

@@ -328,10 +328,11 @@ Type
      Addr: PPointer;
      Addr: PPointer;
      Data: PResourceStringRecord;
      Data: PResourceStringRecord;
    end;
    end;
+   PPResStrInitEntry = ^PResStrInitEntry;
 
 
    TResStrInitTable = packed record
    TResStrInitTable = packed record
      Count: {$ifdef VER2_6}longint{$else}sizeint{$endif};
      Count: {$ifdef VER2_6}longint{$else}sizeint{$endif};
-     Tables: packed array[1..{$ifdef cpu16}8191{$else cpu16}32767{$endif cpu16}] of PResStrInitEntry;
+     Tables: packed array[1..{$ifdef cpu16}8191{$else cpu16}32767{$endif cpu16}] of {$ifndef ver2_6}PPResStrInitEntry{$else}PResStrInitEntry{$endif};
    end;
    end;
    PResStrInitTable = ^TResStrInitTable;
    PResStrInitTable = ^TResStrInitTable;
 
 
@@ -350,7 +351,7 @@ var
 begin
 begin
   for i:=1 to ResStrInitTable^.Count do
   for i:=1 to ResStrInitTable^.Count do
     begin
     begin
-      ptable:=ResStrInitTable^.Tables[i];
+      ptable:=ResStrInitTable^.Tables[i]{$ifndef ver2_6}^{$endif};
       while Assigned(ptable^.Addr) do
       while Assigned(ptable^.Addr) do
         begin
         begin
           AnsiString(ptable^.Addr^):=ptable^.Data^.CurrentValue;
           AnsiString(ptable^.Addr^):=ptable^.Data^.CurrentValue;

+ 3 - 2
rtl/win/syswin.inc

@@ -356,11 +356,12 @@ type
     addr: PPointer;
     addr: PPointer;
     data: Pointer;
     data: Pointer;
   end;
   end;
+  PPWStrInitEntry = ^PWStrInitEntry;
 
 
   PWStrInitTablesTable = ^TWStrInitTablesTable;
   PWStrInitTablesTable = ^TWStrInitTablesTable;
   TWStrInitTablesTable = packed record
   TWStrInitTablesTable = packed record
     count  : {$ifdef VER2_6}longint{$else}sizeint{$endif};
     count  : {$ifdef VER2_6}longint{$else}sizeint{$endif};
-    tables : packed array [1..32767] of PWStrInitEntry;
+    tables : packed array [1..32767] of {$ifndef ver2_6}PPWStrInitEntry{$else}PWStrInitEntry{$endif};
   end;
   end;
 
 
 {$if not(defined(VER2_2) or defined(VER2_4))}
 {$if not(defined(VER2_2) or defined(VER2_4))}
@@ -686,7 +687,7 @@ procedure InitWin32Widestrings;
     { assign initial values to global Widestring typed consts }
     { assign initial values to global Widestring typed consts }
     for i:=1 to WStrInitTablesTable^.count do
     for i:=1 to WStrInitTablesTable^.count do
       begin
       begin
-        ptable:=WStrInitTablesTable^.tables[i];
+        ptable:=WStrInitTablesTable^.tables[i]{$ifndef ver2_6}^{$endif};
         while Assigned(ptable^.addr) do
         while Assigned(ptable^.addr) do
           begin
           begin
             fpc_widestr_assign(ptable^.addr^, ptable^.data);
             fpc_widestr_assign(ptable^.addr^, ptable^.data);