浏览代码

+ generate the stack segment for i8086 far data memory models from within fpc
itself (instead of having a fixed 16k stack in the startup code). This allows
setting the stack size in these models with the -Cs option.

git-svn-id: trunk@27820 -

nickysn 11 年之前
父节点
当前提交
3cc8ff11e3

+ 1 - 0
.gitattributes

@@ -263,6 +263,7 @@ compiler/i8086/n8086ld.pas svneol=native#text/plain
 compiler/i8086/n8086mat.pas svneol=native#text/plain
 compiler/i8086/n8086mem.pas svneol=native#text/plain
 compiler/i8086/n8086tcon.pas svneol=native#text/plain
+compiler/i8086/n8086util.pas svneol=native#text/plain
 compiler/i8086/r8086ari.inc svneol=native#text/plain
 compiler/i8086/r8086att.inc svneol=native#text/plain
 compiler/i8086/r8086con.inc svneol=native#text/plain

+ 3 - 1
compiler/aasmbase.pas

@@ -140,7 +140,9 @@ interface
          sec_objc_nlclasslist,
          sec_objc_catlist,
          sec_objc_nlcatlist,
-         sec_objc_protolist
+         sec_objc_protolist,
+         { stack segment for 16-bit DOS }
+         sec_stack
        );
 
        TAsmSectionOrder = (secorder_begin,secorder_default,secorder_end);

+ 6 - 3
compiler/aggas.pas

@@ -347,7 +347,8 @@ implementation
           '.objc_nlclasslist',
           '.objc_catlist',
           '.obcj_nlcatlist',
-          '.objc_protolist'
+          '.objc_protolist',
+          '.stack'
         );
         secnames_pic : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
           '.text',
@@ -404,7 +405,8 @@ implementation
           '.objc_nlclasslist',
           '.objc_catlist',
           '.obcj_nlcatlist',
-          '.objc_protolist'
+          '.objc_protolist',
+          '.stack'
         );
       var
         sep     : string[3];
@@ -2014,7 +2016,8 @@ implementation
          sec_none (* sec_objc_nlclasslist *),
          sec_none (* sec_objc_catlist *),
          sec_none (* sec_objc_nlcatlist *),
-         sec_none (* sec_objc_protlist *)
+         sec_none (* sec_objc_protlist *),
+         sec_none (* sec_stack *)
         );
       begin
         Result := inherited SectionName (SecXTable [AType], AName, AOrder);

+ 1 - 1
compiler/i8086/cpunode.pas

@@ -57,7 +57,7 @@ unit cpunode;
        n8086mat,
        n8086con,
        { these are not really nodes }
-       n8086tcon,tgcpu,
+       n8086util,n8086tcon,tgcpu,
        { symtable }
        symcpu
        ;

+ 58 - 0
compiler/i8086/n8086util.pas

@@ -0,0 +1,58 @@
+{
+    Copyright (c) 2014 by Nikolay Nikolov
+
+    i8086 version of some node tree helper routines
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit n8086util;
+
+{$i fpcdefs.inc}
+
+interface
+
+  uses
+    ngenutil;
+
+
+  type
+    ti8086nodeutils = class(tnodeutils)
+      class procedure InsertMemorySizes; override;
+    end;
+
+
+implementation
+
+  uses
+    globals,cpuinfo,
+    aasmbase,aasmdata,aasmtai;
+
+
+  class procedure ti8086nodeutils.InsertMemorySizes;
+    begin
+      inherited;
+      if current_settings.x86memorymodel in x86_far_data_models then
+        begin
+          new_section(current_asmdata.asmlists[al_globals],sec_stack,'__stack', 16);
+          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___stack', stacksize));
+        end;
+    end;
+
+
+begin
+  cnodeutils:=ti8086nodeutils;
+end.

+ 2 - 1
compiler/ogbase.pas

@@ -1079,7 +1079,8 @@ implementation
           {sec_objc_nlclasslist} [oso_data,oso_load],
           {sec_objc_catlist} [oso_data,oso_load],
           {sec_objc_nlcatlist} [oso_data,oso_load],
-          {sec_objc_protolist'} [oso_data,oso_load]
+          {sec_objc_protolist'} [oso_data,oso_load],
+          {stack} [oso_load,oso_write]
         );
       begin
         result:=secoptions[atype];

+ 2 - 1
compiler/ogcoff.pas

@@ -539,7 +539,8 @@ implementation
           '.objc_nlclasslist',
           '.objc_catlist',
           '.obcj_nlcatlist',
-          '.objc_protolist'
+          '.objc_protolist',
+          '.stack'
         );
 
 const go32v2stub : array[0..2047] of byte=(

+ 2 - 1
compiler/ogelf.pas

@@ -793,7 +793,8 @@ implementation
           '.objc_nlclasslist',
           '.objc_catlist',
           '.obcj_nlcatlist',
-          '.objc_protolist'
+          '.objc_protolist',
+          '.stack'
         );
       var
         sep : string[3];

+ 1 - 0
compiler/powerpc/agppcmpw.pas

@@ -115,6 +115,7 @@ interface
         '',
         '',
         '',
+        '',
         ''
       );
 

+ 14 - 1
compiler/ppc8086.lpi

@@ -28,7 +28,7 @@
         <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
       </local>
     </RunParams>
-    <Units Count="229">
+    <Units Count="230">
       <Unit0>
         <Filename Value="pp.pas"/>
         <IsPartOfProject Value="True"/>
@@ -180,6 +180,7 @@
       <Unit30>
         <Filename Value="x86\agx86int.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="agx86int"/>
       </Unit30>
       <Unit31>
         <Filename Value="x86\cga.pas"/>
@@ -506,10 +507,12 @@
       <Unit97>
         <Filename Value="aasmbase.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="aasmbase"/>
       </Unit97>
       <Unit98>
         <Filename Value="aasmdata.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="aasmdata"/>
       </Unit98>
       <Unit99>
         <Filename Value="aasmsym.pas"/>
@@ -518,6 +521,7 @@
       <Unit100>
         <Filename Value="aggas.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="aggas"/>
       </Unit100>
       <Unit101>
         <Filename Value="agjasmin.pas"/>
@@ -673,6 +677,7 @@
       <Unit138>
         <Filename Value="gendef.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="gendef"/>
       </Unit138>
       <Unit139>
         <Filename Value="globstat.pas"/>
@@ -794,10 +799,12 @@
       <Unit167>
         <Filename Value="ogbase.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="ogbase"/>
       </Unit167>
       <Unit168>
         <Filename Value="ogelf.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="ogelf"/>
       </Unit168>
       <Unit169>
         <Filename Value="oglx.pas"/>
@@ -878,6 +885,7 @@
       <Unit188>
         <Filename Value="pdecobj.pas"/>
         <IsPartOfProject Value="True"/>
+        <UnitName Value="pdecobj"/>
       </Unit188>
       <Unit189>
         <Filename Value="pdecvar.pas"/>
@@ -1050,6 +1058,11 @@
         <IsPartOfProject Value="True"/>
         <UnitName Value="tgcpu"/>
       </Unit228>
+      <Unit229>
+        <Filename Value="i8086\n8086util.pas"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="n8086util"/>
+      </Unit229>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 2 - 0
compiler/x86/agx86int.pas

@@ -106,6 +106,7 @@ implementation
         '',
         '',
         '',
+        '',
         ''
       );
 
@@ -156,6 +157,7 @@ implementation
         '',
         '',
         '',
+        '',
         ''
       );
 

+ 8 - 2
compiler/x86/agx86nsm.pas

@@ -569,7 +569,8 @@ interface
           '.objc_nlclasslist',
           '.objc_catlist',
           '.obcj_nlcatlist',
-          '.objc_protolist'
+          '.objc_protolist',
+          '.stack'
         );
       begin
         AsmLn;
@@ -1225,11 +1226,16 @@ interface
       AsmWriteLn('SECTION .fpc');
       { WLINK requires class=bss in order to leave the BSS section out of the executable }
       AsmWriteLn('SECTION .bss class=bss');
+      if current_settings.x86memorymodel in x86_far_data_models then
+        AsmWriteLn('SECTION stack stack class=stack align=16');
       { group these sections in the same segment }
       if current_settings.x86memorymodel=mm_tiny then
         AsmWriteLn('GROUP dgroup text rodata data fpc bss')
       else
-        AsmWriteLn('GROUP dgroup rodata data fpc bss');
+        if current_settings.x86memorymodel in x86_far_data_models then
+          AsmWriteLn('GROUP dgroup rodata data fpc bss stack')
+        else
+          AsmWriteLn('GROUP dgroup rodata data fpc bss');
       if paratargetdbg in [dbg_dwarf2,dbg_dwarf3,dbg_dwarf4] then
         begin
           AsmWriteLn('SECTION .debug_frame  use32 class=DWARF');

+ 4 - 4
rtl/msdos/prt0comn.asm

@@ -473,15 +473,15 @@ __nullarea:
         segment stack stack class=stack
         resb 256
         stacktop:
-    %else
-        ; todo: make FPC create the stack segment in far data models
-        segment stack stack class=stack align=16
-        resb 16384
     %endif
 %endif
 
 %ifdef __TINY__
         group dgroup text data bss
 %else
+    %ifdef __NEAR_DATA__
         group dgroup _NULL _AFTERNULL data bss stack
+    %else
+        group dgroup _NULL _AFTERNULL data bss
+    %endif
 %endif