From 7602a89157006cb2028016f4cdd6224a75f1b49c Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Mon, 28 Jan 2008 16:26:51 +0000 Subject: [PATCH] correct stack depth checking git-svn-id: svn://kolibrios.org@705 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/open watcom/trunk/clib.wpj | 2 +- .../open watcom/trunk/clib/crt/chk.asm | 58 --- .../open watcom/trunk/clib/crt/stackwnt.c | 27 -- .../open watcom/trunk/clib/crt/stkwnt.asm | 2 +- programs/develop/open watcom/trunk/crt.tgt | 352 +++++++++--------- 5 files changed, 169 insertions(+), 272 deletions(-) delete mode 100644 programs/develop/open watcom/trunk/clib/crt/chk.asm diff --git a/programs/develop/open watcom/trunk/clib.wpj b/programs/develop/open watcom/trunk/clib.wpj index 82d64c1a1e..668b70cc79 100644 --- a/programs/develop/open watcom/trunk/clib.wpj +++ b/programs/develop/open watcom/trunk/clib.wpj @@ -59,5 +59,5 @@ WFileName 7 crt.tgt 0 -20 +32 8 diff --git a/programs/develop/open watcom/trunk/clib/crt/chk.asm b/programs/develop/open watcom/trunk/clib/crt/chk.asm deleted file mode 100644 index b3fcf326b3..0000000000 --- a/programs/develop/open watcom/trunk/clib/crt/chk.asm +++ /dev/null @@ -1,58 +0,0 @@ -;***************************************************************************** -;* -;* Open Watcom Project -;* -;* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. -;* -;* ======================================================================== -;* -;* This file contains Original Code and/or Modifications of Original -;* Code as defined in and that are subject to the Sybase Open Watcom -;* Public License version 1.0 (the 'License'). You may not use this file -;* except in compliance with the License. BY USING THIS FILE YOU AGREE TO -;* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is -;* provided with the Original Code and Modifications, and is also -;* available at www.sybase.com/developer/opensource. -;* -;* The Original Code and all software distributed under the License are -;* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -;* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM -;* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF -;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR -;* NON-INFRINGEMENT. Please see the License for the specific language -;* governing rights and limitations under the License. -;* -;* ======================================================================== -;* -;* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE -;* DESCRIBE IT HERE! -;* -;***************************************************************************** - - -include mdef.inc -include struct.inc - - xref __STK - - modstart chk - - xdefp __CHK - xdefp __GRO - - - defp __CHK - xchg eax,4[esp] - call __STK - mov eax,4[esp] - ret 4 - endproc __CHK - - - defp __GRO - ret 4 - endproc __GRO - - - endmod - end diff --git a/programs/develop/open watcom/trunk/clib/crt/stackwnt.c b/programs/develop/open watcom/trunk/clib/crt/stackwnt.c index c279749613..212cd282a0 100644 --- a/programs/develop/open watcom/trunk/clib/crt/stackwnt.c +++ b/programs/develop/open watcom/trunk/clib/crt/stackwnt.c @@ -34,35 +34,8 @@ #include "stacklow.h" #include "exitwmsg.h" -#if defined(__AXP__) || defined(__PPC__) -void _init_stk( void ) -{ -} - -_WCRTLINK unsigned __CHK( unsigned i ) -{ - return( i ); -} - -_WCRTLINK void __GRO( unsigned i ) -{ - i = i; -} - -_WCRTLINK void __STKOVERFLOW( void ) -{ - __fatal_runtime_error( "stack overflow", -1 ); -} -#endif _WCRTLINK unsigned stackavail() { -#if defined(__AXP__) || defined(__PPC__) - unsigned _SP; - - _SP = (unsigned)&_SP; - return( _SP - _RWD_stacklow ); -#else return( _SP() - _RWD_stacklow ); -#endif } diff --git a/programs/develop/open watcom/trunk/clib/crt/stkwnt.asm b/programs/develop/open watcom/trunk/clib/crt/stkwnt.asm index 079908b81e..edfc27285b 100644 --- a/programs/develop/open watcom/trunk/clib/crt/stkwnt.asm +++ b/programs/develop/open watcom/trunk/clib/crt/stkwnt.asm @@ -68,7 +68,7 @@ msg db "Stack Overflow!", 0dh, 0ah, 0 _quif ae ; - ... sub eax,esp ; - calculate new low point neg eax ; - calc what new SP would be - cmp eax,_STACKLOW ; - quit if too much + cmp eax,[_STACKLOW] ; - quit if too much _quif be ; - ... call __GRO ; - return ret diff --git a/programs/develop/open watcom/trunk/crt.tgt b/programs/develop/open watcom/trunk/crt.tgt index 29d26525a0..7a23ddc32b 100644 --- a/programs/develop/open watcom/trunk/crt.tgt +++ b/programs/develop/open watcom/trunk/crt.tgt @@ -51,7 +51,7 @@ WVList 0 13 WPickList -35 +34 14 MItem 5 @@ -178,8 +178,8 @@ WVList 0 44 MItem -16 -CLIB\CRT\chk.asm +19 +CLIB\CRT\cmodel.asm 45 WString 6 @@ -196,8 +196,8 @@ WVList 0 48 MItem -19 -CLIB\CRT\cmodel.asm +20 +CLIB\CRT\crwd386.asm 49 WString 6 @@ -214,8 +214,8 @@ WVList 0 52 MItem -20 -CLIB\CRT\crwd386.asm +21 +CLIB\CRT\cstrtwnt.asm 53 WString 6 @@ -233,7 +233,7 @@ WVList 56 MItem 21 -CLIB\CRT\cstrtwnt.asm +CLIB\CRT\segdefns.asm 57 WString 6 @@ -251,7 +251,7 @@ WVList 60 MItem 21 -CLIB\CRT\segdefns.asm +CLIB\CRT\stjmp386.asm 61 WString 6 @@ -268,8 +268,8 @@ WVList 0 64 MItem -21 -CLIB\CRT\stjmp386.asm +19 +CLIB\CRT\stkwnt.asm 65 WString 6 @@ -286,228 +286,228 @@ WVList 0 68 MItem -19 -CLIB\CRT\stkwnt.asm -69 -WString -6 -ASMOBJ -70 -WVList -0 -71 -WVList -0 -14 -1 -1 -0 -72 -MItem 3 *.c -73 +69 WString 4 COBJ -74 +70 WVList 15 -75 +71 MVState +72 +WString +3 +WCC +73 +WString +25 +n????Include directories: +1 +74 +WString +80 +$(%watcom)\h;$(%watcom)\h\nt; "E:\Kos\programs\develop\open watcom\trunk\clib\h" +0 +75 +MRState 76 WString 3 WCC 77 WString -25 -n????Include directories: -1 -78 -WString -80 -$(%watcom)\h;$(%watcom)\h\nt; "E:\Kos\programs\develop\open watcom\trunk\clib\h" -0 -79 -MRState -80 -WString -3 -WCC -81 -WString 27 ?????Default byte alignment 1 0 -82 +78 MRState -83 +79 WString 3 WCC -84 +80 WString 21 ?????1 byte alignment 1 1 -85 +81 MRState -86 +82 WString 3 WCC -87 +83 WString 21 ?????No optimizations 1 0 -88 +84 MRState -89 +85 WString 3 WCC -90 +86 WString 24 ?????Space optimizations 1 1 -91 +87 MCState -92 +88 WString 3 WCC -93 +89 WString 33 ?????Disable stack depth checking 1 1 -94 +90 MCState -95 +91 WString 3 WCC -96 +92 WString 30 ?????Call/return optimizations 1 1 -97 +93 MCState -98 +94 WString 3 WCC -99 +95 WString 25 ?????Relax alias checking 1 1 -100 +96 MRState +97 +WString +3 +WCC +98 +WString +21 +?????Compiler default +1 +0 +99 +MRState +100 +WString +3 +WCC 101 WString -3 -WCC +21 +?????Compiler default +1 +0 102 -WString -21 -?????Compiler default -1 -0 +MRState 103 -MRState +WString +3 +WCC 104 WString -3 -WCC -105 -WString -21 -?????Compiler default -1 -0 -106 -MRState -107 -WString -3 -WCC -108 -WString 37 ?????In-line Pentium Pro instructions 1 1 -109 +105 MRState -110 +106 WString 3 WCC -111 +107 WString 21 ?????Compiler default 1 0 -112 +108 MRState -113 +109 WString 3 WCC -114 +110 WString 29 ?????In-line with coprocessor 1 1 -115 +111 MRState -116 +112 WString 3 WCC -117 +113 WString 21 ??2??32bit Flat model 1 0 -118 +114 MRState -119 +115 WString 3 WCC -120 +116 WString 22 ??2??32bit Small model 1 1 -121 +117 WVList 0 -1 1 1 0 -122 +118 MItem 17 CLIB\CRT\8087cw.c +119 +WString +4 +COBJ +120 +WVList +0 +121 +WVList +0 +68 +1 +1 +0 +122 +MItem +18 +CLIB\CRT\___argc.c 123 WString 4 @@ -518,14 +518,14 @@ WVList 125 WVList 0 -72 +68 1 1 0 126 MItem -18 -CLIB\CRT\___argc.c +16 +CLIB\CRT\_exit.c 127 WString 4 @@ -536,14 +536,14 @@ WVList 129 WVList 0 -72 +68 1 1 0 130 MItem 16 -CLIB\CRT\_exit.c +CLIB\CRT\abort.c 131 WString 4 @@ -554,14 +554,14 @@ WVList 133 WVList 0 -72 +68 1 1 0 134 MItem 16 -CLIB\CRT\abort.c +CLIB\CRT\argcv.c 135 WString 4 @@ -572,14 +572,14 @@ WVList 137 WVList 0 -72 +68 1 1 0 138 MItem -16 -CLIB\CRT\argcv.c +17 +CLIB\CRT\atexit.c 139 WString 4 @@ -590,14 +590,14 @@ WVList 141 WVList 0 -72 +68 1 1 0 142 MItem -17 -CLIB\CRT\atexit.c +18 +CLIB\CRT\binmode.c 143 WString 4 @@ -608,14 +608,14 @@ WVList 145 WVList 0 -72 +68 1 1 0 146 MItem 18 -CLIB\CRT\binmode.c +CLIB\CRT\chk8087.c 147 WString 4 @@ -626,14 +626,14 @@ WVList 149 WVList 0 -72 +68 1 1 0 150 MItem -18 -CLIB\CRT\chk8087.c +16 +CLIB\CRT\cinit.c 151 WString 4 @@ -644,14 +644,14 @@ WVList 153 WVList 0 -72 +68 1 1 0 154 MItem -16 -CLIB\CRT\cinit.c +18 +CLIB\CRT\cmdname.c 155 WString 4 @@ -662,14 +662,14 @@ WVList 157 WVList 0 -72 +68 1 1 0 158 MItem 18 -CLIB\CRT\cmdname.c +CLIB\CRT\commode.c 159 WString 4 @@ -680,14 +680,14 @@ WVList 161 WVList 0 -72 +68 1 1 0 162 MItem -18 -CLIB\CRT\commode.c +17 +CLIB\CRT\cvtbuf.c 163 WString 4 @@ -698,14 +698,14 @@ WVList 165 WVList 0 -72 +68 1 1 0 166 MItem -17 -CLIB\CRT\cvtbuf.c +16 +CLIB\CRT\errno.c 167 WString 4 @@ -716,14 +716,14 @@ WVList 169 WVList 0 -72 +68 1 1 0 170 MItem -16 -CLIB\CRT\errno.c +19 +CLIB\CRT\errnovar.c 171 WString 4 @@ -734,14 +734,14 @@ WVList 173 WVList 0 -72 +68 1 1 0 174 MItem -19 -CLIB\CRT\errnovar.c +15 +CLIB\CRT\exit.c 175 WString 4 @@ -752,14 +752,14 @@ WVList 177 WVList 0 -72 +68 1 1 0 178 MItem -15 -CLIB\CRT\exit.c +18 +CLIB\CRT\fltused.c 179 WString 4 @@ -770,14 +770,14 @@ WVList 181 WVList 0 -72 +68 1 1 0 182 MItem -18 -CLIB\CRT\fltused.c +19 +CLIB\CRT\fpexcept.c 183 WString 4 @@ -788,14 +788,14 @@ WVList 185 WVList 0 -72 +68 1 1 0 186 MItem 19 -CLIB\CRT\fpexcept.c +CLIB\CRT\initargv.c 187 WString 4 @@ -806,14 +806,14 @@ WVList 189 WVList 0 -72 +68 1 1 0 190 MItem 19 -CLIB\CRT\initargv.c +CLIB\CRT\initrtns.c 191 WString 4 @@ -824,14 +824,14 @@ WVList 193 WVList 0 -72 +68 1 1 0 194 MItem -19 -CLIB\CRT\initrtns.c +17 +CLIB\CRT\ioexit.c 195 WString 4 @@ -842,14 +842,14 @@ WVList 197 WVList 0 -72 +68 1 1 0 198 MItem -17 -CLIB\CRT\ioexit.c +18 +CLIB\CRT\ljmphdl.c 199 WString 4 @@ -860,14 +860,14 @@ WVList 201 WVList 0 -72 +68 1 1 0 202 MItem -18 -CLIB\CRT\ljmphdl.c +19 +CLIB\CRT\main2wnt.c 203 WString 4 @@ -878,14 +878,14 @@ WVList 205 WVList 0 -72 +68 1 1 0 206 MItem 19 -CLIB\CRT\main2wnt.c +CLIB\CRT\seterrno.c 207 WString 4 @@ -896,14 +896,14 @@ WVList 209 WVList 0 -72 +68 1 1 0 210 MItem 19 -CLIB\CRT\seterrno.c +CLIB\CRT\stackwnt.c 211 WString 4 @@ -914,14 +914,14 @@ WVList 213 WVList 0 -72 +68 1 1 0 214 MItem -19 -CLIB\CRT\stackwnt.c +18 +CLIB\CRT\xmsgwnt.c 215 WString 4 @@ -932,25 +932,7 @@ WVList 217 WVList 0 -72 -1 -1 -0 -218 -MItem -18 -CLIB\CRT\xmsgwnt.c -219 -WString -4 -COBJ -220 -WVList -0 -221 -WVList -0 -72 +68 1 1 0