* Register Scrubbing::
* Stack Scrubbing::
* Hardened Conditionals::
+* Hardened Booleans::
Obsolescent Features
* Register Scrubbing::
* Stack Scrubbing::
* Hardened Conditionals::
+* Hardened Booleans::
@end menu
@c Hardened Conditionals:
-@node Hardened Conditionals,,Stack Scrubbing,Security Hardening Features
+@node Hardened Conditionals,Hardened Booleans,Stack Scrubbing,Security Hardening Features
@anchor{gnat_rm/security_hardening_features hardened-conditionals}@anchor{440}
@section Hardened Conditionals
They are separate options, however, because of the significantly
different performance impact of the hardening transformations.
+@c Hardened Booleans:
+
+@node Hardened Booleans,,Hardened Conditionals,Security Hardening Features
+@anchor{gnat_rm/security_hardening_features hardened-booleans}@anchor{441}
+@section Hardened Booleans
+
+
+Ada has built-in support for introducing boolean types with
+alternative representations, using representation clauses:
+
+@example
+type HBool is new Boolean;
+for HBool use (16#5a#, 16#a5#);
+for HBool'Size use 8;
+@end example
+
+When validity checking is enabled, the compiler will check that
+variables of such types hold values corresponding to the selected
+representations.
+
+There are multiple strategies for where to introduce validity checking
+(see @emph{-gnatV} options). Their goal is to guard against various kinds
+of programming errors, and GNAT strives to omit checks when program
+logic rules out an invalid value, and optimizers may further remove
+checks found to be redundant.
+
+For additional hardening, the @code{hardbool} @code{Machine_Attribute}
+pragma can be used to annotate boolean types with representation
+clauses, so that expressions of such types used as conditions are
+checked even when compiling with @emph{-gnatVT}.
+
+@example
+pragma Machine_Attribute (HBool, "hardbool");
+@end example
+
+Note that @emph{-gnatVn} will disable even @code{hardbool} testing.
+
@node Obsolescent Features,Compatibility and Porting Guide,Security Hardening Features,Top
-@anchor{gnat_rm/obsolescent_features doc}@anchor{441}@anchor{gnat_rm/obsolescent_features id1}@anchor{442}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
+@anchor{gnat_rm/obsolescent_features doc}@anchor{442}@anchor{gnat_rm/obsolescent_features id1}@anchor{443}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{16}
@chapter Obsolescent Features
@end menu
@node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id2}@anchor{443}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{444}
+@anchor{gnat_rm/obsolescent_features id2}@anchor{444}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{445}
@section pragma No_Run_Time
includes just those features that are to be made accessible.
@node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id3}@anchor{445}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{446}
+@anchor{gnat_rm/obsolescent_features id3}@anchor{446}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{447}
@section pragma Ravenscar
is part of the new Ada 2005 standard.
@node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id4}@anchor{447}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{448}
+@anchor{gnat_rm/obsolescent_features id4}@anchor{448}@anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{449}
@section pragma Restricted_Run_Time
this kind of implementation dependent addition.
@node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features id5}@anchor{449}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{44a}
+@anchor{gnat_rm/obsolescent_features id5}@anchor{44a}@anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{44b}
@section pragma Task_Info
library.
@node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
-@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{44b}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{44c}
+@anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{44c}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{44d}
@section package System.Task_Info (@code{s-tasinf.ads})
standard replacement for GNAT’s @code{Task_Info} functionality.
@node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
-@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{44d}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{44e}
+@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{44e}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{17}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{44f}
@chapter Compatibility and Porting Guide
@end menu
@node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{44f}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{450}
+@anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{450}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{451}
@section Writing Portable Fixed-Point Declarations
types will be portable.
@node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{451}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{452}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{452}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{453}
@section Compatibility with Ada 83
@end menu
@node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{453}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{454}
+@anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{454}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{455}
@subsection Legal Ada 83 programs that are illegal in Ada 95
@end itemize
@node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{455}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{456}
+@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{456}@anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{457}
@subsection More deterministic semantics
@end itemize
@node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{457}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{458}
+@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{458}@anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{459}
@subsection Changed semantics
@end itemize
@node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
-@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{459}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{45a}
+@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{45a}@anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{45b}
@subsection Other language compatibility issues
@end itemize
@node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{45b}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{45c}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{45c}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{45d}
@section Compatibility between Ada 95 and Ada 2005
@end itemize
@node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{45d}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{45e}
+@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{45e}@anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{45f}
@section Implementation-dependent characteristics
@end menu
@node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{45f}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{460}
+@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{460}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{461}
@subsection Implementation-defined pragmas
relevant in a GNAT context and hence are not otherwise implemented.
@node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{461}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{462}
+@anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{462}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{463}
@subsection Implementation-defined attributes
@code{Type_Class}.
@node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{463}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{464}
+@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{464}@anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{465}
@subsection Libraries
@end itemize
@node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{465}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{466}
+@anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{466}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{467}
@subsection Elaboration order
@end itemize
@node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
-@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{467}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{468}
+@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{468}@anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{469}
@subsection Target-specific aspects
Ada 2005 and Ada 2012) are sometimes
incompatible with typical Ada 83 compiler practices regarding implicit
packing, the meaning of the Size attribute, and the size of access values.
-GNAT’s approach to these issues is described in @ref{469,,Representation Clauses}.
+GNAT’s approach to these issues is described in @ref{46a,,Representation Clauses}.
@node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{46a}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{46b}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{46b}@anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{46c}
@section Compatibility with Other Ada Systems
@end itemize
@node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{46c}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{469}
+@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{46d}@anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{46a}
@section Representation Clauses
@end itemize
@node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
-@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{46d}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{46e}
+@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{46e}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{46f}
@section Compatibility with HP Ada 83
@end itemize
@node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
-@anchor{share/gnu_free_documentation_license doc}@anchor{46f}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{470}
+@anchor{share/gnu_free_documentation_license doc}@anchor{470}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{471}
@chapter GNU Free Documentation License