mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-29 19:01:41 +01:00
- garbage was being output sometimes instead of source lines when compiling with -al. This is because lastfileinfo and lastinfile were never initialized for MASM writer. This is true for TPPCMPWAssembler, too.
- long lines were not wrapped. - constants of type ait_comp_64bit output incorrectly. - at end of file, current segment was not closed. patch from Sergei Gorelkin git-svn-id: trunk@9331 -
This commit is contained in:
parent
6058b2c247
commit
59365a6db9
@ -100,10 +100,6 @@ implementation
|
|||||||
line_length = 70;
|
line_length = 70;
|
||||||
|
|
||||||
var
|
var
|
||||||
CurrSecType : TAsmSectiontype; { last section type written }
|
|
||||||
lastfileinfo : tfileposinfo;
|
|
||||||
infile,
|
|
||||||
lastinfile : tinputfile;
|
|
||||||
symendcount : longint;
|
symendcount : longint;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -393,7 +389,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
AsmLn;
|
AsmLn;
|
||||||
CurrSecType:=atype;
|
LastSecType:=atype;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -576,7 +572,7 @@ implementation
|
|||||||
AsmWrite(','+tostr(tai_align_abstract(hp).fillop))
|
AsmWrite(','+tostr(tai_align_abstract(hp).fillop))
|
||||||
{$ifdef x86}
|
{$ifdef x86}
|
||||||
{ force NOP as alignment op code }
|
{ force NOP as alignment op code }
|
||||||
else if CurrSecType=sec_code then
|
else if LastSecType=sec_code then
|
||||||
AsmWrite(',0x90');
|
AsmWrite(',0x90');
|
||||||
{$endif x86}
|
{$endif x86}
|
||||||
end
|
end
|
||||||
@ -623,8 +619,8 @@ implementation
|
|||||||
asmwrite('.zerofill __DATA, __common, ');
|
asmwrite('.zerofill __DATA, __common, ');
|
||||||
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(CurrSecType in [sec_data,sec_none]) then
|
if not(LastSecType in [sec_data,sec_none]) then
|
||||||
writesection(CurrSecType,'',secorder_default);
|
writesection(LastSecType,'',secorder_default);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -742,7 +738,7 @@ implementation
|
|||||||
{ Values with symbols are written on a single line to improve
|
{ Values with symbols are written on a single line to improve
|
||||||
reading of the .s file (PFV) }
|
reading of the .s file (PFV) }
|
||||||
if assigned(tai_const(hp).sym) or
|
if assigned(tai_const(hp).sym) or
|
||||||
not(CurrSecType in [sec_data,sec_rodata,sec_rodata_norel]) or
|
not(LastSecType in [sec_data,sec_rodata,sec_rodata_norel]) or
|
||||||
(l>line_length) or
|
(l>line_length) or
|
||||||
(hp.next=nil) or
|
(hp.next=nil) or
|
||||||
(tai(hp.next).typ<>ait_const) or
|
(tai(hp.next).typ<>ait_const) or
|
||||||
@ -1002,11 +998,11 @@ implementation
|
|||||||
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
|
||||||
CurrSecType:=tai_section(hp.next).sectype;
|
LastSecType:=tai_section(hp.next).sectype;
|
||||||
hp:=tai(hp.next);
|
hp:=tai(hp.next);
|
||||||
end;
|
end;
|
||||||
if CurrSecType<>sec_none then
|
if LastSecType<>sec_none then
|
||||||
WriteSection(CurrSecType,'',secorder_default);
|
WriteSection(LastSecType,'',secorder_default);
|
||||||
AsmStartSize:=AsmSize;
|
AsmStartSize:=AsmSize;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1054,10 +1050,6 @@ implementation
|
|||||||
Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource^);
|
Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource^);
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
CurrSecType:=sec_none;
|
|
||||||
FillChar(lastfileinfo,sizeof(lastfileinfo),0);
|
|
||||||
LastInfile:=nil;
|
|
||||||
|
|
||||||
if assigned(current_module.mainsource) then
|
if assigned(current_module.mainsource) then
|
||||||
n:=ExtractFileName(current_module.mainsource^)
|
n:=ExtractFileName(current_module.mainsource^)
|
||||||
else
|
else
|
||||||
|
|||||||
@ -33,7 +33,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils,
|
SysUtils,
|
||||||
systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase;
|
systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase,finput;
|
||||||
|
|
||||||
const
|
const
|
||||||
{ maximum of aasmoutput lists there will be }
|
{ maximum of aasmoutput lists there will be }
|
||||||
@ -75,6 +75,12 @@ interface
|
|||||||
outbuf : array[0..AsmOutSize-1] of char;
|
outbuf : array[0..AsmOutSize-1] of char;
|
||||||
outfile : file;
|
outfile : file;
|
||||||
ioerror : boolean;
|
ioerror : boolean;
|
||||||
|
{input source info}
|
||||||
|
lastfileinfo : tfileposinfo;
|
||||||
|
infile,
|
||||||
|
lastinfile : tinputfile;
|
||||||
|
{last section type written}
|
||||||
|
lastsectype : TAsmSectionType;
|
||||||
public
|
public
|
||||||
{# Returns the complete path and executable name of the assembler
|
{# Returns the complete path and executable name of the assembler
|
||||||
program.
|
program.
|
||||||
@ -604,6 +610,10 @@ Implementation
|
|||||||
procedure TExternalAssembler.MakeObject;
|
procedure TExternalAssembler.MakeObject;
|
||||||
begin
|
begin
|
||||||
AsmCreate(cut_normal);
|
AsmCreate(cut_normal);
|
||||||
|
FillChar(lastfileinfo, sizeof(lastfileinfo), 0);
|
||||||
|
lastfileinfo.line := -1;
|
||||||
|
lastinfile := nil;
|
||||||
|
lastsectype := sec_none;
|
||||||
WriteAsmList;
|
WriteAsmList;
|
||||||
AsmClose;
|
AsmClose;
|
||||||
if not(ioerror) then
|
if not(ioerror) then
|
||||||
|
|||||||
@ -67,11 +67,6 @@ interface
|
|||||||
{$i r386nasm.inc}
|
{$i r386nasm.inc}
|
||||||
);
|
);
|
||||||
|
|
||||||
var
|
|
||||||
lastfileinfo : tfileposinfo;
|
|
||||||
infile,
|
|
||||||
lastinfile : tinputfile;
|
|
||||||
|
|
||||||
function nasm_regname(r:Tregister):string;
|
function nasm_regname(r:Tregister):string;
|
||||||
var
|
var
|
||||||
p : tregisterindex;
|
p : tregisterindex;
|
||||||
@ -442,10 +437,6 @@ interface
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var
|
|
||||||
LastSecType : TAsmSectiontype;
|
|
||||||
|
|
||||||
const
|
const
|
||||||
ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
|
ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
|
||||||
#9'FIXME_128BIT'#9,#9'FIXME_64BIT'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
|
#9'FIXME_128BIT'#9,#9'FIXME_64BIT'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
|
||||||
@ -1053,14 +1044,9 @@ interface
|
|||||||
if assigned(current_module.mainsource) then
|
if assigned(current_module.mainsource) then
|
||||||
comment(v_info,'Start writing nasm-styled assembler output for '+current_module.mainsource^);
|
comment(v_info,'Start writing nasm-styled assembler output for '+current_module.mainsource^);
|
||||||
{$endif}
|
{$endif}
|
||||||
LasTSecType:=sec_none;
|
|
||||||
AsmWriteLn('BITS 32');
|
AsmWriteLn('BITS 32');
|
||||||
AsmLn;
|
AsmLn;
|
||||||
|
|
||||||
lastfileinfo.line:=-1;
|
|
||||||
lastfileinfo.fileindex:=0;
|
|
||||||
lastinfile:=nil;
|
|
||||||
|
|
||||||
WriteExternals;
|
WriteExternals;
|
||||||
|
|
||||||
for hal:=low(TasmlistType) to high(TasmlistType) do
|
for hal:=low(TasmlistType) to high(TasmlistType) do
|
||||||
|
|||||||
@ -663,12 +663,6 @@ interface
|
|||||||
AsmLn;
|
AsmLn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
LasTSec : TAsmSectiontype;
|
|
||||||
lastfileinfo : tfileposinfo;
|
|
||||||
infile,
|
|
||||||
lastinfile : tinputfile;
|
|
||||||
|
|
||||||
const
|
const
|
||||||
ait_const2str:array[aitconst_32bit..aitconst_8bit] of string[8]=
|
ait_const2str:array[aitconst_32bit..aitconst_8bit] of string[8]=
|
||||||
(#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
|
(#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
|
||||||
@ -1231,7 +1225,6 @@ interface
|
|||||||
if assigned(current_module.mainsource) then
|
if assigned(current_module.mainsource) then
|
||||||
comment(v_info,'Start writing MPW-styled assembler output for '+current_module.mainsource^);
|
comment(v_info,'Start writing MPW-styled assembler output for '+current_module.mainsource^);
|
||||||
{$endif}
|
{$endif}
|
||||||
LasTSec:=sec_none;
|
|
||||||
|
|
||||||
WriteAsmFileHeader;
|
WriteAsmFileHeader;
|
||||||
WriteExternals;
|
WriteExternals;
|
||||||
|
|||||||
@ -342,13 +342,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
var
|
|
||||||
LasTSectype : TAsmSectiontype;
|
|
||||||
lastfileinfo : tfileposinfo;
|
|
||||||
infile,
|
|
||||||
lastinfile : tinputfile;
|
|
||||||
|
|
||||||
const
|
const
|
||||||
ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
|
ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
|
||||||
#9''#9,#9'DQ'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
|
#9''#9,#9'DQ'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
|
||||||
@ -547,6 +540,7 @@ implementation
|
|||||||
else
|
else
|
||||||
s:=tostr(tai_const(hp).value);
|
s:=tostr(tai_const(hp).value);
|
||||||
AsmWrite(s);
|
AsmWrite(s);
|
||||||
|
inc(l,length(s));
|
||||||
if (l>line_length) or
|
if (l>line_length) or
|
||||||
(hp.next=nil) or
|
(hp.next=nil) or
|
||||||
(tai(hp.next).typ<>ait_const) or
|
(tai(hp.next).typ<>ait_const) or
|
||||||
@ -569,7 +563,7 @@ implementation
|
|||||||
ait_real_80bit :
|
ait_real_80bit :
|
||||||
AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
|
AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
|
||||||
ait_comp_64bit :
|
ait_comp_64bit :
|
||||||
AsmWriteLn(#9#9'DQ'#9+comp2str(tai_real_80bit(hp).value));
|
AsmWriteLn(#9#9'DQ'#9+extended2str(tai_comp_64bit(hp).value));
|
||||||
ait_string :
|
ait_string :
|
||||||
begin
|
begin
|
||||||
counter := 0;
|
counter := 0;
|
||||||
@ -883,7 +877,6 @@ implementation
|
|||||||
if assigned(current_module.mainsource) then
|
if assigned(current_module.mainsource) then
|
||||||
comment(v_info,'Start writing intel-styled assembler output for '+current_module.mainsource^);
|
comment(v_info,'Start writing intel-styled assembler output for '+current_module.mainsource^);
|
||||||
{$endif}
|
{$endif}
|
||||||
LasTSecType:=sec_none;
|
|
||||||
if target_asm.id<>as_x86_64_masm then
|
if target_asm.id<>as_x86_64_masm then
|
||||||
begin
|
begin
|
||||||
AsmWriteLn(#9'.386p');
|
AsmWriteLn(#9'.386p');
|
||||||
@ -906,6 +899,14 @@ implementation
|
|||||||
AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]);
|
AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ better do this at end of WriteTree, but then there comes a trouble with
|
||||||
|
al_const which does not have leading ait_section and thus goes out of segment }
|
||||||
|
|
||||||
|
{ TODO: probably ml64 needs 'closing' last section, too }
|
||||||
|
if LastSecType <> sec_none then
|
||||||
|
AsmWriteLn('_'+secnames[LasTSecType]+#9#9'ENDS');
|
||||||
|
LastSecType := sec_none;
|
||||||
|
|
||||||
AsmWriteLn(#9'END');
|
AsmWriteLn(#9'END');
|
||||||
AsmLn;
|
AsmLn;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user