mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-05 16:26:14 +02:00
aggas.pas: Make WriteSection method of TGNUAssembler class virtual.
ppcgen/agppcgas.pas: Override WriteSection method in TPPCAIXAssembler class to compute required alignment for base sections. git-svn-id: trunk@36227 -
This commit is contained in:
parent
de8c780fa7
commit
f7c2ab2e7c
@ -49,7 +49,7 @@ interface
|
|||||||
function sectionattrs(atype:TAsmSectiontype):string;virtual;
|
function sectionattrs(atype:TAsmSectiontype):string;virtual;
|
||||||
function sectionattrs_coff(atype:TAsmSectiontype):string;virtual;
|
function sectionattrs_coff(atype:TAsmSectiontype):string;virtual;
|
||||||
function sectionalignment_aix(atype:TAsmSectiontype;secalign: byte):string;
|
function sectionalignment_aix(atype:TAsmSectiontype;secalign: byte):string;
|
||||||
procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte);
|
procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte);virtual;
|
||||||
procedure WriteExtraHeader;virtual;
|
procedure WriteExtraHeader;virtual;
|
||||||
procedure WriteExtraFooter;virtual;
|
procedure WriteExtraFooter;virtual;
|
||||||
procedure WriteInstruction(hp: tai);
|
procedure WriteInstruction(hp: tai);
|
||||||
|
@ -54,9 +54,12 @@ unit agppcgas;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
TPPCAIXAssembler=class(TPPCGNUAssembler)
|
TPPCAIXAssembler=class(TPPCGNUAssembler)
|
||||||
|
max_alignment : array[TAsmSectionType] of byte;
|
||||||
constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
|
constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
|
||||||
protected
|
protected
|
||||||
function sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string; override;
|
function sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string; override;
|
||||||
|
procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte); override;
|
||||||
|
procedure WriteAsmList; override;
|
||||||
procedure WriteExtraHeader; override;
|
procedure WriteExtraHeader; override;
|
||||||
procedure WriteExtraFooter; override;
|
procedure WriteExtraFooter; override;
|
||||||
procedure WriteDirectiveName(dir: TAsmDirective); override;
|
procedure WriteDirectiveName(dir: TAsmDirective); override;
|
||||||
@ -467,11 +470,75 @@ unit agppcgas;
|
|||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
|
|
||||||
constructor TPPCAIXAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
|
constructor TPPCAIXAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
|
||||||
|
var
|
||||||
|
cur_sectype : TAsmSectionType;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
InstrWriter := TPPCInstrWriter.create(self);
|
InstrWriter := TPPCInstrWriter.create(self);
|
||||||
|
{ Use 8-byte alignment as default for all sections }
|
||||||
|
for cur_sectype:=low(TAsmSectionType) to high(TAsmSectionType) do
|
||||||
|
max_alignment[cur_sectype]:=8;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPPCAIXAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:byte);
|
||||||
|
|
||||||
|
begin
|
||||||
|
secalign:=max_alignment[atype];
|
||||||
|
Inherited WriteSection(atype,aname,aorder,secalign);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPPCAIXAssembler.WriteAsmList;
|
||||||
|
var
|
||||||
|
cur_sectype : TAsmSectionType;
|
||||||
|
cur_list : TAsmList;
|
||||||
|
hal : tasmlisttype;
|
||||||
|
hp : tai;
|
||||||
|
max_al : byte;
|
||||||
|
begin
|
||||||
|
{ Parse all asmlists to get maximum alignement used for all types }
|
||||||
|
for hal:=low(TasmlistType) to high(TasmlistType) do
|
||||||
|
begin
|
||||||
|
if not (current_asmdata.asmlists[hal].empty) then
|
||||||
|
begin
|
||||||
|
cur_sectype:=sec_none;
|
||||||
|
hp:=tai(current_asmdata.asmlists[hal].First);
|
||||||
|
while assigned(hp) do
|
||||||
|
begin
|
||||||
|
case hp.typ of
|
||||||
|
ait_align :
|
||||||
|
begin
|
||||||
|
if tai_align_abstract(hp).aligntype > max_alignment[cur_sectype] then
|
||||||
|
begin
|
||||||
|
max_alignment[cur_sectype]:=tai_align_abstract(hp).aligntype;
|
||||||
|
current_asmdata.asmlists[hal].InsertAfter(tai_comment.Create(strpnew('Alignment put to '+tostr(tai_align_abstract(hp).aligntype))),hp);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
ait_section :
|
||||||
|
begin
|
||||||
|
cur_sectype:=tai_section(hp).sectype;
|
||||||
|
if tai_section(hp).secalign > max_alignment[cur_sectype] then
|
||||||
|
begin
|
||||||
|
max_alignment[cur_sectype]:=tai_section(hp).secalign;
|
||||||
|
current_asmdata.asmlists[hal].InsertAfter(tai_comment.Create(strpnew('Section '
|
||||||
|
+sectionname(tai_section(hp).sectype,'',secorder_default)+' alignment put to '+tostr(tai_section(hp).secalign))),hp);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
hp:=tai(hp.next);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{ sec_data, sec_rodata and sec_bss all are converted into .data[RW],
|
||||||
|
in WriteSection below,
|
||||||
|
so we take the maximum alignment of the three }
|
||||||
|
max_al:=max_alignment[sec_data];
|
||||||
|
max_al:=max(max_al,max_alignment[sec_rodata]);
|
||||||
|
max_al:=max(max_al,max_alignment[sec_bss]);
|
||||||
|
max_alignment[sec_data]:=max_al;
|
||||||
|
max_alignment[sec_rodata]:=max_al;
|
||||||
|
max_alignment[sec_bss]:=max_al;
|
||||||
|
Inherited WriteAsmList;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPPCAIXAssembler.WriteExtraHeader;
|
procedure TPPCAIXAssembler.WriteExtraHeader;
|
||||||
var
|
var
|
||||||
@ -485,13 +552,14 @@ unit agppcgas;
|
|||||||
required for correct RTTI alignment.
|
required for correct RTTI alignment.
|
||||||
AIX assembler seems to only care for the first
|
AIX assembler seems to only care for the first
|
||||||
alignment value given }
|
alignment value given }
|
||||||
writer.AsmWriteln(#9'.csect .data[RW],3');
|
writer.AsmWriteln(#9'.csect .data[RW],'+sectionalignment_aix(sec_data,max_alignment[sec_data]));
|
||||||
|
writer.AsmWriteln(#9'.csect _data.bss_[BS],'+sectionalignment_aix(sec_data,max_alignment[sec_data]));
|
||||||
{ .rodata is translated into .text[RO]
|
{ .rodata is translated into .text[RO]
|
||||||
see sectionname in aggas unit. }
|
see sectionname in aggas unit. }
|
||||||
writer.AsmWriteln(#9'.csect .text[RO],3');
|
writer.AsmWriteln(#9'.csect .text[RO],'+sectionalignment_aix(sec_rodata_norel,max_alignment[sec_rodata_norel]));
|
||||||
{ make sure we always have a code and toc section,
|
{ make sure we always have a code and toc section,
|
||||||
the linker expects that }
|
the linker expects that }
|
||||||
writer.AsmWriteln(#9'.csect .text[PR]');
|
writer.AsmWriteln(#9'.csect .text[PR],'+sectionalignment_aix(sec_code,max_alignment[sec_code]));
|
||||||
{ set _text_s, to be used by footer below }
|
{ set _text_s, to be used by footer below }
|
||||||
writer.AsmWriteln(#9'_text_s:');
|
writer.AsmWriteln(#9'_text_s:');
|
||||||
writer.AsmWriteln(#9'.toc');
|
writer.AsmWriteln(#9'.toc');
|
||||||
|
Loading…
Reference in New Issue
Block a user