mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-25 03:41:28 +01:00
+ support section smartlinking with nasm
+ set alignment for smartlinked sections in nasm * enable section smartlinking for nasm/coff win32 git-svn-id: trunk@29654 -
This commit is contained in:
parent
06fd4223e9
commit
7c1cf07484
@ -41,7 +41,7 @@ interface
|
|||||||
procedure WriteReference(var ref : treference);
|
procedure WriteReference(var ref : treference);
|
||||||
procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
|
procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
|
||||||
procedure WriteOper_jmp(const o:toper; ai : taicpu);
|
procedure WriteOper_jmp(const o:toper; ai : taicpu);
|
||||||
procedure WriteSection(atype:TAsmSectiontype;const aname:string);
|
procedure WriteSection(atype:TAsmSectiontype;const aname:string;alignment : byte);
|
||||||
public
|
public
|
||||||
procedure WriteTree(p:TAsmList);override;
|
procedure WriteTree(p:TAsmList);override;
|
||||||
procedure WriteAsmList;override;
|
procedure WriteAsmList;override;
|
||||||
@ -505,7 +505,8 @@ interface
|
|||||||
#9'DW'#9,#9'DD'#9,#9'FIXME_64BIT_UNALIGNED'#9
|
#9'DW'#9,#9'DD'#9,#9'FIXME_64BIT_UNALIGNED'#9
|
||||||
);
|
);
|
||||||
|
|
||||||
procedure TX86NasmAssembler.WriteSection(atype:TAsmSectiontype;const aname:string);
|
procedure TX86NasmAssembler.WriteSection(atype : TAsmSectiontype;
|
||||||
|
const aname : string; alignment : byte);
|
||||||
const
|
const
|
||||||
secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
|
secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
|
||||||
'.text',
|
'.text',
|
||||||
@ -596,6 +597,12 @@ interface
|
|||||||
begin
|
begin
|
||||||
AsmWrite('.');
|
AsmWrite('.');
|
||||||
AsmWrite(aname);
|
AsmWrite(aname);
|
||||||
|
if atype in [sec_init, sec_fini, sec_stub, sec_code] then
|
||||||
|
AsmWrite(' code align='+tostr(alignment))
|
||||||
|
else if atype in [sec_rodata, sec_rodata_norel] then
|
||||||
|
AsmWrite(' rdata align='+tostr(alignment))
|
||||||
|
else
|
||||||
|
AsmWrite(' data align='+tostr(alignment))
|
||||||
end;
|
end;
|
||||||
AsmLn;
|
AsmLn;
|
||||||
LastSecType:=atype;
|
LastSecType:=atype;
|
||||||
@ -624,6 +631,7 @@ interface
|
|||||||
{$endif cpuextended}
|
{$endif cpuextended}
|
||||||
fixed_opcode: TAsmOp;
|
fixed_opcode: TAsmOp;
|
||||||
prefix, LastSecName : string;
|
prefix, LastSecName : string;
|
||||||
|
LastAlign : Byte;
|
||||||
begin
|
begin
|
||||||
if not assigned(p) then
|
if not assigned(p) then
|
||||||
exit;
|
exit;
|
||||||
@ -668,7 +676,7 @@ interface
|
|||||||
ait_section :
|
ait_section :
|
||||||
begin
|
begin
|
||||||
if tai_section(hp).sectype<>sec_none then
|
if tai_section(hp).sectype<>sec_none then
|
||||||
WriteSection(tai_section(hp).sectype,tai_section(hp).name^);
|
WriteSection(tai_section(hp).sectype,tai_section(hp).name^,tai_section(hp).secalign);
|
||||||
LastSecType:=tai_section(hp).sectype;
|
LastSecType:=tai_section(hp).sectype;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1113,17 +1121,19 @@ interface
|
|||||||
{ avoid empty files }
|
{ avoid empty files }
|
||||||
LastSecType:=sec_none;
|
LastSecType:=sec_none;
|
||||||
LastSecName:='';
|
LastSecName:='';
|
||||||
|
LastAlign:=4;
|
||||||
while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
|
while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
|
||||||
begin
|
begin
|
||||||
if tai(hp.next).typ=ait_section then
|
if tai(hp.next).typ=ait_section then
|
||||||
begin
|
begin
|
||||||
LastSecType:=tai_section(hp.next).sectype;
|
LastSecType:=tai_section(hp.next).sectype;
|
||||||
LastSecName:=tai_section(hp.next).name^;
|
LastSecName:=tai_section(hp.next).name^;
|
||||||
|
LastAlign:=tai_section(hp.next).secalign;
|
||||||
end;
|
end;
|
||||||
hp:=tai(hp.next);
|
hp:=tai(hp.next);
|
||||||
end;
|
end;
|
||||||
if LastSecType<>sec_none then
|
if LastSecType<>sec_none then
|
||||||
WriteSection(LastSecType,LastSecName);
|
WriteSection(LastSecType,LastSecName,LastAlign);
|
||||||
AsmStartSize:=AsmSize;
|
AsmStartSize:=AsmSize;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1392,7 +1402,7 @@ interface
|
|||||||
asmbin : 'nasm';
|
asmbin : 'nasm';
|
||||||
asmcmd : '-f win32 -o $OBJ -w-orphan-labels $EXTRAOPT $ASM';
|
asmcmd : '-f win32 -o $OBJ -w-orphan-labels $EXTRAOPT $ASM';
|
||||||
supported_targets : [system_i386_win32];
|
supported_targets : [system_i386_win32];
|
||||||
flags : [af_needar,af_no_debug];
|
flags : [af_needar,af_no_debug,af_smartlink_sections];
|
||||||
labelprefix : '..@';
|
labelprefix : '..@';
|
||||||
comment : '; ';
|
comment : '; ';
|
||||||
dollarsign: '$';
|
dollarsign: '$';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user