mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-22 13:31:34 +02: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;
|
||||
|
||||
var
|
||||
CurrSecType : TAsmSectiontype; { last section type written }
|
||||
lastfileinfo : tfileposinfo;
|
||||
infile,
|
||||
lastinfile : tinputfile;
|
||||
symendcount : longint;
|
||||
|
||||
type
|
||||
@ -393,7 +389,7 @@ implementation
|
||||
end;
|
||||
end;
|
||||
AsmLn;
|
||||
CurrSecType:=atype;
|
||||
LastSecType:=atype;
|
||||
end;
|
||||
|
||||
|
||||
@ -576,7 +572,7 @@ implementation
|
||||
AsmWrite(','+tostr(tai_align_abstract(hp).fillop))
|
||||
{$ifdef x86}
|
||||
{ force NOP as alignment op code }
|
||||
else if CurrSecType=sec_code then
|
||||
else if LastSecType=sec_code then
|
||||
AsmWrite(',0x90');
|
||||
{$endif x86}
|
||||
end
|
||||
@ -623,8 +619,8 @@ implementation
|
||||
asmwrite('.zerofill __DATA, __common, ');
|
||||
asmwrite(tai_datablock(hp).sym.name);
|
||||
asmwriteln(', '+tostr(tai_datablock(hp).size)+','+tostr(last_align));
|
||||
if not(CurrSecType in [sec_data,sec_none]) then
|
||||
writesection(CurrSecType,'',secorder_default);
|
||||
if not(LastSecType in [sec_data,sec_none]) then
|
||||
writesection(LastSecType,'',secorder_default);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -742,7 +738,7 @@ implementation
|
||||
{ Values with symbols are written on a single line to improve
|
||||
reading of the .s file (PFV) }
|
||||
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
|
||||
(hp.next=nil) 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
|
||||
begin
|
||||
if tai(hp.next).typ=ait_section then
|
||||
CurrSecType:=tai_section(hp.next).sectype;
|
||||
LastSecType:=tai_section(hp.next).sectype;
|
||||
hp:=tai(hp.next);
|
||||
end;
|
||||
if CurrSecType<>sec_none then
|
||||
WriteSection(CurrSecType,'',secorder_default);
|
||||
if LastSecType<>sec_none then
|
||||
WriteSection(LastSecType,'',secorder_default);
|
||||
AsmStartSize:=AsmSize;
|
||||
end;
|
||||
end;
|
||||
@ -1054,10 +1050,6 @@ implementation
|
||||
Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource^);
|
||||
{$endif}
|
||||
|
||||
CurrSecType:=sec_none;
|
||||
FillChar(lastfileinfo,sizeof(lastfileinfo),0);
|
||||
LastInfile:=nil;
|
||||
|
||||
if assigned(current_module.mainsource) then
|
||||
n:=ExtractFileName(current_module.mainsource^)
|
||||
else
|
||||
|
@ -33,7 +33,7 @@ interface
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase;
|
||||
systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase,finput;
|
||||
|
||||
const
|
||||
{ maximum of aasmoutput lists there will be }
|
||||
@ -75,6 +75,12 @@ interface
|
||||
outbuf : array[0..AsmOutSize-1] of char;
|
||||
outfile : file;
|
||||
ioerror : boolean;
|
||||
{input source info}
|
||||
lastfileinfo : tfileposinfo;
|
||||
infile,
|
||||
lastinfile : tinputfile;
|
||||
{last section type written}
|
||||
lastsectype : TAsmSectionType;
|
||||
public
|
||||
{# Returns the complete path and executable name of the assembler
|
||||
program.
|
||||
@ -604,6 +610,10 @@ Implementation
|
||||
procedure TExternalAssembler.MakeObject;
|
||||
begin
|
||||
AsmCreate(cut_normal);
|
||||
FillChar(lastfileinfo, sizeof(lastfileinfo), 0);
|
||||
lastfileinfo.line := -1;
|
||||
lastinfile := nil;
|
||||
lastsectype := sec_none;
|
||||
WriteAsmList;
|
||||
AsmClose;
|
||||
if not(ioerror) then
|
||||
|
@ -67,11 +67,6 @@ interface
|
||||
{$i r386nasm.inc}
|
||||
);
|
||||
|
||||
var
|
||||
lastfileinfo : tfileposinfo;
|
||||
infile,
|
||||
lastinfile : tinputfile;
|
||||
|
||||
function nasm_regname(r:Tregister):string;
|
||||
var
|
||||
p : tregisterindex;
|
||||
@ -442,10 +437,6 @@ interface
|
||||
end;
|
||||
|
||||
|
||||
|
||||
var
|
||||
LastSecType : TAsmSectiontype;
|
||||
|
||||
const
|
||||
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,
|
||||
@ -1053,14 +1044,9 @@ interface
|
||||
if assigned(current_module.mainsource) then
|
||||
comment(v_info,'Start writing nasm-styled assembler output for '+current_module.mainsource^);
|
||||
{$endif}
|
||||
LasTSecType:=sec_none;
|
||||
AsmWriteLn('BITS 32');
|
||||
AsmLn;
|
||||
|
||||
lastfileinfo.line:=-1;
|
||||
lastfileinfo.fileindex:=0;
|
||||
lastinfile:=nil;
|
||||
|
||||
WriteExternals;
|
||||
|
||||
for hal:=low(TasmlistType) to high(TasmlistType) do
|
||||
|
@ -663,12 +663,6 @@ interface
|
||||
AsmLn;
|
||||
end;
|
||||
|
||||
var
|
||||
LasTSec : TAsmSectiontype;
|
||||
lastfileinfo : tfileposinfo;
|
||||
infile,
|
||||
lastinfile : tinputfile;
|
||||
|
||||
const
|
||||
ait_const2str:array[aitconst_32bit..aitconst_8bit] of string[8]=
|
||||
(#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
|
||||
@ -1231,7 +1225,6 @@ interface
|
||||
if assigned(current_module.mainsource) then
|
||||
comment(v_info,'Start writing MPW-styled assembler output for '+current_module.mainsource^);
|
||||
{$endif}
|
||||
LasTSec:=sec_none;
|
||||
|
||||
WriteAsmFileHeader;
|
||||
WriteExternals;
|
||||
|
@ -342,13 +342,6 @@ implementation
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
LasTSectype : TAsmSectiontype;
|
||||
lastfileinfo : tfileposinfo;
|
||||
infile,
|
||||
lastinfile : tinputfile;
|
||||
|
||||
const
|
||||
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,
|
||||
@ -547,6 +540,7 @@ implementation
|
||||
else
|
||||
s:=tostr(tai_const(hp).value);
|
||||
AsmWrite(s);
|
||||
inc(l,length(s));
|
||||
if (l>line_length) or
|
||||
(hp.next=nil) or
|
||||
(tai(hp.next).typ<>ait_const) or
|
||||
@ -569,7 +563,7 @@ implementation
|
||||
ait_real_80bit :
|
||||
AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
|
||||
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 :
|
||||
begin
|
||||
counter := 0;
|
||||
@ -883,7 +877,6 @@ implementation
|
||||
if assigned(current_module.mainsource) then
|
||||
comment(v_info,'Start writing intel-styled assembler output for '+current_module.mainsource^);
|
||||
{$endif}
|
||||
LasTSecType:=sec_none;
|
||||
if target_asm.id<>as_x86_64_masm then
|
||||
begin
|
||||
AsmWriteLn(#9'.386p');
|
||||
@ -906,6 +899,14 @@ implementation
|
||||
AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]);
|
||||
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');
|
||||
AsmLn;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user