* fixed smartlinking

This commit is contained in:
peter 1999-07-31 12:33:11 +00:00
parent 73151c592c
commit ab7c74f60a

View File

@ -66,6 +66,7 @@ unit ag386bin;
procedure WriteFileLineInfo(var fileinfo : tfileposinfo); procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
procedure StartFileLineInfo; procedure StartFileLineInfo;
{$endif} {$endif}
function MaybeNextList(var hp:pai):boolean;
function TreePass0(hp:pai):pai; function TreePass0(hp:pai):pai;
function TreePass1(hp:pai):pai; function TreePass1(hp:pai):pai;
function TreePass2(hp:pai):pai; function TreePass2(hp:pai):pai;
@ -338,6 +339,27 @@ unit ag386bin;
{$endif GDB} {$endif GDB}
function ti386binasmlist.MaybeNextList(var hp:pai):boolean;
begin
{ maybe end of list }
while not assigned(hp) do
begin
if currlistidx<lists then
begin
inc(currlistidx);
currlist:=list[currlistidx];
hp:=pai(currlist^.first);
end
else
begin
MaybeNextList:=false;
exit;
end;
end;
MaybeNextList:=true;
end;
function ti386binasmlist.TreePass0(hp:pai):pai; function ti386binasmlist.TreePass0(hp:pai):pai;
var var
lastsec : tsection; lastsec : tsection;
@ -360,23 +382,28 @@ unit ag386bin;
ait_datablock : ait_datablock :
begin begin
{$ifdef EXTERNALBSS} {$ifdef EXTERNALBSS}
if not pai_datablock(hp)^.is_global then if not SmartAsm then
begin
if not pai_datablock(hp)^.is_global then
begin
l:=pai_datablock(hp)^.size;
if l>2 then
objectalloc^.sectionalign(4)
else if l>1 then
objectalloc^.sectionalign(2);
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
end;
end
else
begin begin
l:=pai_datablock(hp)^.size;
if l>2 then
objectalloc^.sectionalign(4)
else if l>1 then
objectalloc^.sectionalign(2);
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
end;
{$else}
l:=pai_datablock(hp)^.size;
if l>2 then
objectalloc^.sectionalign(4)
else if l>1 then
objectalloc^.sectionalign(2);
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
{$endif} {$endif}
l:=pai_datablock(hp)^.size;
if l>2 then
objectalloc^.sectionalign(4)
else if l>1 then
objectalloc^.sectionalign(2);
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
end;
end; end;
ait_const_32bit : ait_const_32bit :
objectalloc^.sectionalloc(4); objectalloc^.sectionalloc(4);
@ -417,16 +444,6 @@ unit ag386bin;
end; end;
hp:=pai(hp^.next); hp:=pai(hp^.next);
{ maybe end of list }
if not assigned(hp) then
begin
if currlistidx<lists then
begin
inc(currlistidx);
currlist:=list[currlistidx];
hp:=pai(currlist^.first);
end;
end;
end; end;
TreePass0:=hp; TreePass0:=hp;
@ -469,35 +486,40 @@ unit ag386bin;
if objectalloc^.currsec<>sec_bss then if objectalloc^.currsec<>sec_bss then
Message(asmw_e_alloc_data_only_in_bss); Message(asmw_e_alloc_data_only_in_bss);
{$ifdef EXTERNALBSS} {$ifdef EXTERNALBSS}
if pai_datablock(hp)^.is_global then if not SmartAsm then
begin begin
pai_datablock(hp)^.sym^.typ:=AS_EXTERNAL; if pai_datablock(hp)^.is_global then
pai_datablock(hp)^.sym^.setaddress(sec_none,pai_datablock(hp)^.size,pai_datablock(hp)^.size); begin
end pai_datablock(hp)^.sym^.typ:=AS_EXTERNAL;
else pai_datablock(hp)^.sym^.setaddress(sec_none,pai_datablock(hp)^.size,pai_datablock(hp)^.size);
begin end
l:=pai_datablock(hp)^.size; else
if l>2 then begin
objectalloc^.sectionalign(4) l:=pai_datablock(hp)^.size;
else if l>1 then if l>2 then
objectalloc^.sectionalign(2); objectalloc^.sectionalign(4)
pai_datablock(hp)^.sym^.typ:=AS_LOCAL; else if l>1 then
pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size); objectalloc^.sectionalign(2);
objectalloc^.sectionalloc(pai_datablock(hp)^.size); pai_datablock(hp)^.sym^.typ:=AS_LOCAL;
end; pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size);
{$else} objectalloc^.sectionalloc(pai_datablock(hp)^.size);
if pai_datablock(hp)^.is_global then end;
pai_datablock(hp)^.sym^.typ:=AS_GLOBAL end
else else
pai_datablock(hp)^.sym^.typ:=AS_LOCAL;
l:=pai_datablock(hp)^.size;
if l>2 then
objectalloc^.sectionalign(4)
else if l>1 then
objectalloc^.sectionalign(2);
pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size);
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
{$endif} {$endif}
begin
if pai_datablock(hp)^.is_global then
pai_datablock(hp)^.sym^.typ:=AS_GLOBAL
else
pai_datablock(hp)^.sym^.typ:=AS_LOCAL;
l:=pai_datablock(hp)^.size;
if l>2 then
objectalloc^.sectionalign(4)
else if l>1 then
objectalloc^.sectionalign(2);
pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size);
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
end;
end; end;
ait_const_32bit : ait_const_32bit :
objectalloc^.sectionalloc(4); objectalloc^.sectionalloc(4);
@ -639,9 +661,11 @@ unit ag386bin;
ait_datablock : ait_datablock :
begin begin
objectoutput^.writesymbol(pai_datablock(hp)^.sym); objectoutput^.writesymbol(pai_datablock(hp)^.sym);
if SmartAsm
{$ifdef EXTERNALBSS} {$ifdef EXTERNALBSS}
if not pai_datablock(hp)^.is_global then or (not pai_datablock(hp)^.is_global)
{$endif} {$endif}
then
begin begin
l:=pai_datablock(hp)^.size; l:=pai_datablock(hp)^.size;
if l>2 then if l>2 then
@ -726,19 +750,8 @@ unit ag386bin;
while assigned(hp) do while assigned(hp) do
begin begin
hp:=TreePass1(hp); hp:=TreePass1(hp);
{ maybe end of list } MaybeNextList(hp);
if not assigned(hp) then end;
begin
if currlistidx<lists then
begin
inc(currlistidx);
currlist:=list[currlistidx];
hp:=pai(currlist^.first);
end
else
break;
end;
end;
{ set section sizes } { set section sizes }
objectoutput^.setsectionsizes(objectalloc^.secsize); objectoutput^.setsectionsizes(objectalloc^.secsize);
@ -754,19 +767,8 @@ unit ag386bin;
while assigned(hp) do while assigned(hp) do
begin begin
hp:=TreePass2(hp); hp:=TreePass2(hp);
{ maybe end of list } MaybeNextList(hp);
if not assigned(hp) then end;
begin
if currlistidx<lists then
begin
inc(currlistidx);
currlist:=list[currlistidx];
hp:=pai(currlist^.first);
end
else
break;
end;
end;
end; end;
@ -798,26 +800,17 @@ unit ag386bin;
{$endif GDB} {$endif GDB}
hp:=TreePass2(hp); hp:=TreePass2(hp);
{ maybe end of list } if not MaybeNextList(hp) then
if not assigned(hp) then break;
begin
if currlistidx<lists then
begin
inc(currlistidx);
currlist:=list[currlistidx];
hp:=pai(currlist^.first);
end
else
break;
end;
{ write the current objectfile } { write the current objectfile }
objectoutput^.donewriting; objectoutput^.donewriting;
{ start the writing again }
objectoutput^.initwriting;
{ we will start a new objectfile so reset everything } { we will start a new objectfile so reset everything }
ResetAsmsymbolList; objectoutput^.initwriting;
objectalloc^.resetsections; objectalloc^.resetsections;
ResetAsmsymbolList;
{ avoid empty files } { avoid empty files }
while assigned(hp^.next) and while assigned(hp^.next) and
(pai(hp^.next)^.typ in [ait_marker,ait_comment,ait_section,ait_cut]) do (pai(hp^.next)^.typ in [ait_marker,ait_comment,ait_section,ait_cut]) do
@ -829,7 +822,11 @@ unit ag386bin;
end; end;
hp:=pai(hp^.next); hp:=pai(hp^.next);
end; end;
hp:=pai(hp^.next); hp:=pai(hp^.next);
if not MaybeNextList(hp) then
break;
end; end;
end; end;
@ -908,7 +905,10 @@ unit ag386bin;
end. end.
{ {
$Log$ $Log$
Revision 1.19 1999-07-22 09:37:30 florian Revision 1.20 1999-07-31 12:33:11 peter
* fixed smartlinking
Revision 1.19 1999/07/22 09:37:30 florian
+ resourcestring implemented + resourcestring implemented
+ start of longstring support + start of longstring support