From 5433db6a49a0540c242efed5e63db7a06c4186b7 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 11 Apr 2012 18:06:05 +0000 Subject: [PATCH] * also specify the section alignment with the section statements themselves on AIX. Adding ".align" statements only align relative to the section start, but does not influence the alignment of the section itself git-svn-id: trunk@20835 - --- compiler/aggas.pas | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 2fc9dde536..b00264c1a9 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -46,7 +46,8 @@ interface protected function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual; function sectionattrs_coff(atype:TAsmSectiontype):string;virtual; - procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder); + function sectionalignment_aix(atype:TAsmSectiontype;secalign: byte):string; + procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte); procedure WriteExtraHeader;virtual; procedure WriteExtraFooter;virtual; procedure WriteInstruction(hp: tai); @@ -463,7 +464,23 @@ implementation end; - procedure TGNUAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder); + function TGNUAssembler.sectionalignment_aix(atype:TAsmSectiontype;secalign: byte): string; + var + l: longint; + begin + if (secalign=0) or + not(atype in [sec_code,sec_bss,sec_rodata_norel]) then + begin + result:=''; + exit; + end; + if not ispowerof2(secalign,l) then + internalerror(2012022201); + result:=tostr(l); + end; + + + procedure TGNUAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte); var s : string; begin @@ -532,7 +549,13 @@ implementation s:=sectionattrs_coff(atype); if (s<>'') then AsmWrite(',"'+s+'"'); - end; + end + else if target_info.system in systems_aix then + begin + s:=sectionalignment_aix(atype,secalign); + if s<>'' then + AsmWrite(','+s); + end; end; AsmLn; LastSecType:=atype; @@ -698,9 +721,9 @@ implementation begin if tai_section(hp).sectype<>sec_none then if replaceforbidden then - WriteSection(tai_section(hp).sectype,ReplaceForbiddenAsmSymbolChars(tai_section(hp).name^),tai_section(hp).secorder) + WriteSection(tai_section(hp).sectype,ReplaceForbiddenAsmSymbolChars(tai_section(hp).name^),tai_section(hp).secorder,tai_section(hp).secalign) else - WriteSection(tai_section(hp).sectype,tai_section(hp).name^,tai_section(hp).secorder) + WriteSection(tai_section(hp).sectype,tai_section(hp).name^,tai_section(hp).secorder,tai_section(hp).secalign) else begin {$ifdef EXTDEBUG} @@ -729,7 +752,7 @@ implementation asmwrite(tai_datablock(hp).sym.name); asmwriteln(', '+tostr(tai_datablock(hp).size)+','+tostr(last_align)); if not(LastSecType in [sec_data,sec_none]) then - writesection(LastSecType,'',secorder_default); + writesection(LastSecType,'',secorder_default,last_align); end else begin @@ -751,7 +774,7 @@ implementation asmwrite(#9'.space '); asmwriteln(tostr(tai_datablock(hp).size)); if not(LastSecType in [sec_data,sec_none]) then - writesection(LastSecType,'',secorder_default); + writesection(LastSecType,'',secorder_default,last_align); end else begin @@ -1281,7 +1304,7 @@ implementation hp:=tai(hp.next); end; if LastSecType<>sec_none then - WriteSection(LastSecType,'',secorder_default); + WriteSection(LastSecType,'',secorder_default,last_align); AsmStartSize:=AsmSize; end; end;