Преглед на файлове

* If alignment requirement of data is bigger than alignment of the section being written to, increase section alignment to match. This mostly affects cases of non-smart linking, where wrong initial alignment used to cause hard to catch misalignment issues. It also largely obsoletes the need to supply the initial section alignment (hidden tai_section constructor,etc).
* Likewise, when merging object sections into exe sections, set alignment of exe section to maximum value.

git-svn-id: trunk@21964 -

sergei преди 13 години
родител
ревизия
24c7b7f433
променени са 2 файла, в които са добавени 6 реда и са изтрити 1 реда
  1. 5 0
      compiler/assemble.pas
  2. 1 1
      compiler/ogbase.pas

+ 5 - 0
compiler/assemble.pas

@@ -1107,6 +1107,9 @@ Implementation
                        short jumps to become out of range }
                      Tai_align_abstract(hp).fillsize:=Tai_align_abstract(hp).aligntype;
                      ObjData.alloc(Tai_align_abstract(hp).fillsize);
+                     { may need to increase alignment of section }
+                     if tai_align_abstract(hp).aligntype>ObjData.CurrObjSec.secalign then
+                       ObjData.CurrObjSec.secalign:=tai_align_abstract(hp).aligntype;
                    end
                  else
                    Tai_align_abstract(hp).fillsize:=0;
@@ -1353,6 +1356,8 @@ Implementation
            case hp.typ of
              ait_align :
                begin
+                 if tai_align_abstract(hp).aligntype>ObjData.CurrObjSec.secalign then
+                   InternalError(2012072301);
                  if oso_data in ObjData.CurrObjSec.secoptions then
                    ObjData.writebytes(Tai_align_abstract(hp).calculatefillbuf(fillbuffer,oso_executable in ObjData.CurrObjSec.secoptions)^,
                      Tai_align_abstract(hp).fillsize)

+ 1 - 1
compiler/ogbase.pas

@@ -1443,10 +1443,10 @@ implementation
         else
           begin
             { inherit section options }
-            SecAlign:=objsec.SecAlign;
             SecOptions:=SecOptions+objsec.SecOptions;
           end;
         { relate ObjSection to ExeSection, and mark it Used by default }
+        SecAlign:=max(objsec.SecAlign,SecAlign);
         objsec.ExeSection:=self;
         objsec.Used:=true;
       end;