Ver Fonte

* moved the code for determining whether an omf object section should
belong to group DGROUP to a function in unit omfbase (so it can be used in the
future by the nasm asm writer as well)

git-svn-id: trunk@31484 -

nickysn há 10 anos atrás
pai
commit
efef3882a0
2 ficheiros alterados com 33 adições e 26 exclusões
  1. 5 25
      compiler/ogomf.pas
  2. 28 1
      compiler/omfbase.pas

+ 5 - 25
compiler/ogomf.pas

@@ -469,39 +469,17 @@ implementation
 
     constructor TOmfObjSection.create(AList: TFPHashObjectList;
           const Aname: string; Aalign: shortint; Aoptions: TObjSectionOptions);
-      var
-        dgroup: Boolean;
       begin
         inherited create(AList, Aname, Aalign, Aoptions);
         FCombination:=scPublic;
         FUse:=suUse16;
-        if oso_executable in Aoptions then
-          dgroup:=(current_settings.x86memorymodel=mm_tiny)
-        else if Aname='stack' then
-          begin
-            FCombination:=scStack;
-            dgroup:=current_settings.x86memorymodel in (x86_near_data_models-[mm_tiny]);
-          end
-        else if Aname='heap' then
-          dgroup:=current_settings.x86memorymodel in x86_near_data_models
-        else if Aname='bss' then
-          dgroup:=true
-        else if Aname='data' then
-          dgroup:=true
+        if Aname='stack' then
+          FCombination:=scStack
         else if (Aname='debug_frame') or
                 (Aname='debug_info') or
                 (Aname='debug_line') or
                 (Aname='debug_abbrev') then
-          begin
-            FUse:=suUse32;
-            dgroup:=false;
-          end
-        else
-          dgroup:=true;
-        if dgroup then
-          FPrimaryGroup:='DGROUP'
-        else
-          FPrimaryGroup:='';
+          FUse:=suUse32;
       end;
 
     function TOmfObjSection.MemPosStr(AImageBase: qword): string;
@@ -585,6 +563,8 @@ implementation
       begin
         Result:=inherited createsection(atype, aname, aorder);
         TOmfObjSection(Result).FClassName:=sectiontype2class(atype);
+        if section_belongs_to_dgroup(atype) then
+          TOmfObjSection(Result).FPrimaryGroup:='DGROUP';
       end;
 
     procedure TOmfObjData.writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);

+ 28 - 1
compiler/omfbase.pas

@@ -649,11 +649,17 @@ interface
 
   function compute_omf_lib_hash(const name: string; blocks: Integer): TOmfLibHash;
 
+  { returns whether the specified section type belongs to the group DGROUP in
+    the current memory model. DGROUP is the segment group pointed by DS }
+  function section_belongs_to_dgroup(atype:TAsmSectiontype): Boolean;
+
 implementation
 
   uses
     cutils,
-    verbose;
+    globals,globtype,
+    verbose,
+    cpuinfo;
 
   { TOmfOrderedNameCollection }
 
@@ -1756,4 +1762,25 @@ implementation
       Result.bucket_d:=max(bucket_d mod nbuckets,1);
     end;
 
+  function section_belongs_to_dgroup(atype: TAsmSectiontype): Boolean;
+    begin
+{$ifdef i8086}
+      case omf_segclass[atype] of
+        'CODE':
+          result:=current_settings.x86memorymodel=mm_tiny;
+        'DATA',
+        'BSS':
+          result:=true;
+        'STACK':
+          result:=current_settings.x86memorymodel in (x86_near_data_models-[mm_tiny]);
+        'HEAP':
+          result:=current_settings.x86memorymodel in x86_near_data_models;
+        else
+          result:=false;
+      end;
+{$else i8086}
+      result:=false;
+{$endif i8086}
+    end;
+
 end.