From 24c7b7f4334240b8a3a7488f49beb4a046b783d1 Mon Sep 17 00:00:00 2001 From: sergei Date: Tue, 24 Jul 2012 08:38:11 +0000 Subject: [PATCH] * 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 - --- compiler/assemble.pas | 5 +++++ compiler/ogbase.pas | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 324fffd672..ca4d4d140e 100644 --- a/compiler/assemble.pas +++ b/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) diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 7669e3b3a3..6db26c343a 100644 --- a/compiler/ogbase.pas +++ b/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;