ソースを参照

+ introduce align_objsecofs; use it to align integers of type TObjSectionOfs

git-svn-id: trunk@39086 -
nickysn 7 年 前
コミット
584635c591
1 ファイル変更13 行追加3 行削除
  1. 13 3
      compiler/ogbase.pas

+ 13 - 3
compiler/ogbase.pas

@@ -696,6 +696,7 @@ interface
 
     function align_aword(v:aword;a:longword):aword;
     function align_qword(v:qword;a:longword):qword;
+    function align_objsecofs(v:TObjSectionOfs;a:longword):TObjSectionOfs;
 
 implementation
 
@@ -734,6 +735,15 @@ implementation
       end;
 
 
+    function align_objsecofs(v:TObjSectionOfs;a:longword):TObjSectionOfs;
+      begin
+        if a<=1 then
+          result:=v
+        else
+          result:=((v+a-1) div a) * a;
+      end;
+
+
     procedure MaybeSwapStab(var v:TObjStabEntry);
       begin
         if source_info.endian<>target_info.endian then
@@ -1421,14 +1431,14 @@ implementation
       begin
         if not assigned(CurrObjSec) then
           internalerror(200402253);
-        CurrObjSec.alloc(align_aword(CurrObjSec.size,len)-CurrObjSec.size);
+        CurrObjSec.alloc(align_objsecofs(CurrObjSec.size,len)-CurrObjSec.size);
       end;
 
 
     procedure TObjData.section_afteralloc(p:TObject;arg:pointer);
       begin
         with TObjSection(p) do
-          alloc(align_aword(size,secalign)-size);
+          alloc(align_objsecofs(size,secalign)-size);
       end;
 
 
@@ -1437,7 +1447,7 @@ implementation
         with TObjSection(p) do
           begin
             if assigned(Data) then
-              writezeros(align_aword(size,secalign)-size);
+              writezeros(align_objsecofs(size,secalign)-size);
           end;
       end;