Browse Source

* override sectiontype2align in the omf writer and set the same alignments as
the ones, currently produced by nasm

git-svn-id: trunk@30602 -

nickysn 10 years ago
parent
commit
d7416afd88
1 changed files with 28 additions and 0 deletions
  1. 28 0
      compiler/ogomf.pas

+ 28 - 0
compiler/ogomf.pas

@@ -82,6 +82,7 @@ interface
         class function CodeSectionName(const aname:string): string;
         class function CodeSectionName(const aname:string): string;
       public
       public
         constructor create(const n:string);override;
         constructor create(const n:string);override;
+        function sectiontype2align(atype:TAsmSectiontype):shortint;override;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
         procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
         procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
       end;
       end;
@@ -300,6 +301,33 @@ implementation
         CObjSection:=TOmfObjSection;
         CObjSection:=TOmfObjSection;
       end;
       end;
 
 
+    function TOmfObjData.sectiontype2align(atype: TAsmSectiontype): shortint;
+      begin
+        case atype of
+          sec_stabstr,sec_debug_info,sec_debug_line,sec_debug_abbrev:
+            result:=1;
+          sec_code:
+            result:=1;
+          sec_bss:
+            result:=1;
+          sec_data:
+            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_stack,
+          sec_heap:
+            result:=16;
+          else
+            result:=1;
+        end;
+      end;
+
     function TOmfObjData.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
     function TOmfObjData.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
       const
       const
         secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
         secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',