Browse Source

* 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 -

Jonas Maebe 13 years ago
parent
commit
5433db6a49
1 changed files with 31 additions and 8 deletions
  1. 31 8
      compiler/aggas.pas

+ 31 - 8
compiler/aggas.pas

@@ -46,7 +46,8 @@ interface
       protected
       protected
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;
         function sectionattrs_coff(atype:TAsmSectiontype):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 WriteExtraHeader;virtual;
         procedure WriteExtraFooter;virtual;
         procedure WriteExtraFooter;virtual;
         procedure WriteInstruction(hp: tai);
         procedure WriteInstruction(hp: tai);
@@ -463,7 +464,23 @@ implementation
       end;
       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
       var
         s : string;
         s : string;
       begin
       begin
@@ -532,7 +549,13 @@ implementation
               s:=sectionattrs_coff(atype);
               s:=sectionattrs_coff(atype);
               if (s<>'') then
               if (s<>'') then
                 AsmWrite(',"'+s+'"');
                 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;
         end;
         AsmLn;
         AsmLn;
         LastSecType:=atype;
         LastSecType:=atype;
@@ -698,9 +721,9 @@ implementation
              begin
              begin
                if tai_section(hp).sectype<>sec_none then
                if tai_section(hp).sectype<>sec_none then
                  if replaceforbidden 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
                  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
                else
                  begin
                  begin
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
@@ -729,7 +752,7 @@ implementation
                        asmwrite(tai_datablock(hp).sym.name);
                        asmwrite(tai_datablock(hp).sym.name);
                        asmwriteln(', '+tostr(tai_datablock(hp).size)+','+tostr(last_align));
                        asmwriteln(', '+tostr(tai_datablock(hp).size)+','+tostr(last_align));
                        if not(LastSecType in [sec_data,sec_none]) then
                        if not(LastSecType in [sec_data,sec_none]) then
-                         writesection(LastSecType,'',secorder_default);
+                         writesection(LastSecType,'',secorder_default,last_align);
                      end
                      end
                    else
                    else
                      begin
                      begin
@@ -751,7 +774,7 @@ implementation
                        asmwrite(#9'.space ');
                        asmwrite(#9'.space ');
                        asmwriteln(tostr(tai_datablock(hp).size));
                        asmwriteln(tostr(tai_datablock(hp).size));
                        if not(LastSecType in [sec_data,sec_none]) then
                        if not(LastSecType in [sec_data,sec_none]) then
-                         writesection(LastSecType,'',secorder_default);
+                         writesection(LastSecType,'',secorder_default,last_align);
                      end
                      end
                    else
                    else
                      begin
                      begin
@@ -1281,7 +1304,7 @@ implementation
                      hp:=tai(hp.next);
                      hp:=tai(hp.next);
                    end;
                    end;
                   if LastSecType<>sec_none then
                   if LastSecType<>sec_none then
-                    WriteSection(LastSecType,'',secorder_default);
+                    WriteSection(LastSecType,'',secorder_default,last_align);
                   AsmStartSize:=AsmSize;
                   AsmStartSize:=AsmSize;
                 end;
                 end;
              end;
              end;