浏览代码

* the function which returns the alignment of omf sections moved to unit
omfbase, so it can be used by the nasm asm writer as well

git-svn-id: trunk@31486 -

nickysn 10 年之前
父节点
当前提交
cc2e27b555
共有 2 个文件被更改,包括 32 次插入26 次删除
  1. 1 26
      compiler/ogomf.pas
  2. 31 0
      compiler/omfbase.pas

+ 1 - 26
compiler/ogomf.pas

@@ -509,32 +509,7 @@ implementation
 
     function TOmfObjData.sectiontype2align(atype: TAsmSectiontype): shortint;
       begin
-        case atype of
-          sec_stabstr:
-            result:=1;
-          sec_code:
-            result:=1;
-          sec_data,
-          sec_rodata,
-          sec_rodata_norel,
-          sec_bss:
-            result:=2;
-          { For idata (at least idata2) it must be 4 bytes, because
-            an entry is always (also in win64) 20 bytes and aligning
-            on 8 bytes will insert 4 bytes between the entries resulting
-            in a corrupt idata section.
-            Same story with .pdata, it has 4-byte elements which should
-            be packed without gaps. }
-          sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_pdata:
-            result:=4;
-          sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev:
-            result:=4;
-          sec_stack,
-          sec_heap:
-            result:=16;
-          else
-            result:=1;
-        end;
+        Result:=omf_sectiontype2align(atype);
       end;
 
     function TOmfObjData.sectiontype2class(atype: TAsmSectiontype): string;

+ 31 - 0
compiler/omfbase.pas

@@ -649,6 +649,7 @@ interface
 
   function compute_omf_lib_hash(const name: string; blocks: Integer): TOmfLibHash;
 
+  function omf_sectiontype2align(atype:TAsmSectiontype):shortint;
   { 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;
@@ -1762,6 +1763,36 @@ implementation
       Result.bucket_d:=max(bucket_d mod nbuckets,1);
     end;
 
+  function omf_sectiontype2align(atype: TAsmSectiontype): shortint;
+    begin
+      case atype of
+        sec_stabstr:
+          result:=1;
+        sec_code:
+          result:=1;
+        sec_data,
+        sec_rodata,
+        sec_rodata_norel,
+        sec_bss:
+          result:=2;
+        { For idata (at least idata2) it must be 4 bytes, because
+          an entry is always (also in win64) 20 bytes and aligning
+          on 8 bytes will insert 4 bytes between the entries resulting
+          in a corrupt idata section.
+          Same story with .pdata, it has 4-byte elements which should
+          be packed without gaps. }
+        sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_pdata:
+          result:=4;
+        sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev:
+          result:=4;
+        sec_stack,
+        sec_heap:
+          result:=16;
+        else
+          result:=1;
+      end;
+    end;
+
   function section_belongs_to_dgroup(atype: TAsmSectiontype): Boolean;
     begin
 {$ifdef i8086}