152419Sjulian------------------------------------------------------------------------------ 252419Sjulian-- -- 352419Sjulian-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- 452419Sjulian-- -- 552419Sjulian-- S Y S T E M . S T A C K _ C H E C K I N G -- 670700Sjulian-- -- 752419Sjulian-- S p e c -- 852419Sjulian-- -- 952419Sjulian-- Copyright (C) 1999-2013, Free Software Foundation, Inc. -- 1052419Sjulian-- -- 1152419Sjulian-- GNARL is free software; you can redistribute it and/or modify it under -- 1252419Sjulian-- terms of the GNU General Public License as published by the Free Soft- -- 1352419Sjulian-- ware Foundation; either version 3, or (at your option) any later ver- -- 1452419Sjulian-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 1552419Sjulian-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- 1652419Sjulian-- or FITNESS FOR A PARTICULAR PURPOSE. -- 1770700Sjulian-- -- 1852419Sjulian-- As a special exception under Section 7 of GPL version 3, you are granted -- 1952419Sjulian-- additional permissions described in the GCC Runtime Library Exception, -- 2052419Sjulian-- version 3.1, as published by the Free Software Foundation. -- 2152419Sjulian-- -- 2252419Sjulian-- You should have received a copy of the GNU General Public License and -- 2352419Sjulian-- a copy of the GCC Runtime Library Exception along with this program; -- 2452419Sjulian-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 2552419Sjulian-- <http://www.gnu.org/licenses/>. -- 2652419Sjulian-- -- 2752419Sjulian-- GNARL was developed by the GNARL team at Florida State University. -- 2852419Sjulian-- Extensive contributions were provided by Ada Core Technologies, Inc. -- 2952419Sjulian-- -- 3052419Sjulian------------------------------------------------------------------------------ 3152419Sjulian 3252419Sjulian-- This package provides a system-independent implementation of stack 3352419Sjulian-- checking using comparison with stack base and limit. 3452419Sjulian 3552419Sjulian-- This package defines basic types and objects. Operations related to 3667506Sjulian-- stack checking can be found in package System.Stack_Checking.Operations. 3767506Sjulian 3852419Sjulianpragma Compiler_Unit_Warning; 3952419Sjulian 4052419Sjulianwith System.Storage_Elements; 4152419Sjulian 4252419Sjulianpackage System.Stack_Checking is 4352419Sjulian pragma Preelaborate; 4452419Sjulian pragma Elaborate_Body; 4552419Sjulian -- This unit has a junk null body. The reason is that historically we 4652419Sjulian -- used to have a real body, and it causes bootstrapping path problems 4752419Sjulian -- to eliminate it, since the old body may still be present in the 4852419Sjulian -- compilation environment for a build. 4952419Sjulian 5052419Sjulian type Stack_Info is record 5152419Sjulian Limit : System.Address := System.Null_Address; 5252419Sjulian Base : System.Address := System.Null_Address; 5370700Sjulian Size : System.Storage_Elements.Storage_Offset := 0; 5452419Sjulian end record; 5552419Sjulian -- This record may be part of a larger data structure like the 5652419Sjulian -- task control block in the tasking case. 5752843Sphk -- This specific layout has the advantage of being compatible with the 5852816Sarchie -- Intel x86 BOUNDS instruction. 5952419Sjulian 6052419Sjulian type Stack_Access is access all Stack_Info; 6152419Sjulian -- Unique local storage associated with a specific task. This storage is 6252419Sjulian -- used for the stack base and limit, and is returned by Checked_Self. 6352419Sjulian -- Only self may write this information, it may be read by any task. 6453913Sarchie -- At no time the address range Limit .. Base (or Base .. Limit for 6552419Sjulian -- upgrowing stack) may contain any address that is part of another stack. 6659756Speter -- The Stack_Access may be part of a larger data structure. 6759756Speter 6870784Sjulian Multi_Processor : constant Boolean := False; -- Not supported yet 6970700Sjulian 7070700Sjulianprivate 7152419Sjulian 7270784Sjulian Null_Stack_Info : aliased Stack_Info := 7370784Sjulian (Limit => System.Null_Address, 7470784Sjulian Base => System.Null_Address, 7570784Sjulian Size => 0); 7670784Sjulian -- Use explicit assignment to avoid elaboration code (call to init proc) 7770784Sjulian 7870784Sjulian Null_Stack : constant Stack_Access := Null_Stack_Info'Access; 7970784Sjulian -- Stack_Access value that will return a Stack_Base and Stack_Limit 8070784Sjulian -- that fail any stack check. 8170784Sjulian 8270784Sjulianend System.Stack_Checking; 8370784Sjulian