Ver Fonte

+ support mixing initialized and bss data in the same object section (only in
case the section options contain the new option 'oso_sparse_data') in the
internal object writer (needed for the huge memory model)

git-svn-id: trunk@31503 -

nickysn há 10 anos atrás
pai
commit
4a855b140a
3 ficheiros alterados com 21 adições e 3 exclusões
  1. 2 1
      compiler/assemble.pas
  2. 9 2
      compiler/ogbase.pas
  3. 10 0
      compiler/ogomf.pas

+ 2 - 1
compiler/assemble.pas

@@ -1413,7 +1413,8 @@ Implementation
                end;
              ait_datablock :
                begin
-                 if (oso_data in ObjData.CurrObjSec.secoptions) then
+                 if (oso_data in ObjData.CurrObjSec.secoptions) and
+                    not (oso_sparse_data in ObjData.CurrObjSec.secoptions) then
                    Message(asmw_e_alloc_data_only_in_bss);
 {$ifdef USE_COMM_IN_BSS}
                  if writingpackages and

+ 9 - 2
compiler/ogbase.pas

@@ -157,7 +157,9 @@ interface
        { Must be cloned when writing separate debug file }
        oso_debug_copy,
        { Has relocations with explicit addends (ELF-specific) }
-       oso_rela_relocs
+       oso_rela_relocs,
+       { Supports bss-like allocation of data, even though it is written in file (i.e. also has oso_Data) }
+       oso_sparse_data
      );
 
      TObjSectionOptions = set of TObjSectionOption;
@@ -968,7 +970,10 @@ implementation
         if (qword(size)+l)>high(size) then
           SectionTooLargeError;
 {$endif}
-        inc(size,l);
+        if oso_sparse_data in SecOptions then
+          WriteZeros(l)
+        else
+          inc(size,l);
       end;
 
 
@@ -1366,6 +1371,8 @@ implementation
             Size:=0;
             Datapos:=0;
             mempos:=0;
+            if assigned(Data) then
+              Data.reset;
           end;
       end;
 

+ 10 - 0
compiler/ogomf.pas

@@ -100,6 +100,7 @@ interface
         class function CodeSectionName(const aname:string): string;
       public
         constructor create(const n:string);override;
+        function sectiontype2options(atype:TAsmSectiontype):TObjSectionOptions;override;
         function sectiontype2align(atype:TAsmSectiontype):shortint;override;
         function sectiontype2class(atype:TAsmSectiontype):string;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
@@ -507,6 +508,15 @@ implementation
         CObjSection:=TOmfObjSection;
       end;
 
+    function TOmfObjData.sectiontype2options(atype: TAsmSectiontype): TObjSectionOptions;
+      begin
+        Result:=inherited sectiontype2options(atype);
+        { in the huge memory model, BSS data is actually written in the regular
+          FAR_DATA segment of the module }
+        if sectiontype2class(atype)='FAR_DATA' then
+          Result:=Result+[oso_data,oso_sparse_data];
+      end;
+
     function TOmfObjData.sectiontype2align(atype: TAsmSectiontype): shortint;
       begin
         Result:=omf_sectiontype2align(atype);