mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 02:30:41 +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 WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
|
||||
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
|
||||
procedure WriteTree(p:TAsmList);override;
|
||||
procedure WriteAsmList;override;
|
||||
@ -505,7 +505,8 @@ interface
|
||||
#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
|
||||
secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
|
||||
'.text',
|
||||
@ -596,6 +597,12 @@ interface
|
||||
begin
|
||||
AsmWrite('.');
|
||||
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;
|
||||
AsmLn;
|
||||
LastSecType:=atype;
|
||||
@ -624,6 +631,7 @@ interface
|
||||
{$endif cpuextended}
|
||||
fixed_opcode: TAsmOp;
|
||||
prefix, LastSecName : string;
|
||||
LastAlign : Byte;
|
||||
begin
|
||||
if not assigned(p) then
|
||||
exit;
|
||||
@ -668,7 +676,7 @@ interface
|
||||
ait_section :
|
||||
begin
|
||||
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;
|
||||
end;
|
||||
|
||||
@ -1113,17 +1121,19 @@ interface
|
||||
{ avoid empty files }
|
||||
LastSecType:=sec_none;
|
||||
LastSecName:='';
|
||||
LastAlign:=4;
|
||||
while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
|
||||
begin
|
||||
if tai(hp.next).typ=ait_section then
|
||||
begin
|
||||
LastSecType:=tai_section(hp.next).sectype;
|
||||
LastSecName:=tai_section(hp.next).name^;
|
||||
LastAlign:=tai_section(hp.next).secalign;
|
||||
end;
|
||||
hp:=tai(hp.next);
|
||||
end;
|
||||
if LastSecType<>sec_none then
|
||||
WriteSection(LastSecType,LastSecName);
|
||||
WriteSection(LastSecType,LastSecName,LastAlign);
|
||||
AsmStartSize:=AsmSize;
|
||||
end;
|
||||
end;
|
||||
@ -1392,7 +1402,7 @@ interface
|
||||
asmbin : 'nasm';
|
||||
asmcmd : '-f win32 -o $OBJ -w-orphan-labels $EXTRAOPT $ASM';
|
||||
supported_targets : [system_i386_win32];
|
||||
flags : [af_needar,af_no_debug];
|
||||
flags : [af_needar,af_no_debug,af_smartlink_sections];
|
||||
labelprefix : '..@';
|
||||
comment : '; ';
|
||||
dollarsign: '$';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user