6. Support for Certified Systems¶
6.1. The Certification Philosophy¶
GNAT is intended to reduce costs and risks in meeting software safety or security certification standards for applications written in Ada.
One way this goal is met is through the use of language profiles: using one of the language profiles designed for certification, or an appropriately constrained Ada subset selected by the programmer. The following GNAT defined-profiles have been designed with certification in mind and are know in this chapter as the Certifiable Profiles:
Zero Footprint Profile
Ravenscar Small Footprint Profile (SFP)
Depending on the predefined or self-defined profile chosen, this will restrict Ada construct usage so that either no run-time library or a simple certifiable library is used by a conforming application. For the no run-time library option, the Zero Footprint Profile has little to no object code outside the application code to certify. Note some run-time source files still exist in this profile. A few of these files provide support for basic language features, like the secondary stack, and are simple enough to certify yourself or can be avoided by customizing the run-time. Other files present in the run-time provide definitions used by the compiler, but these files do not generate any object code. Depending on the certification protocol, it may still be necessary to include tests for correct access to these definitions in these run-time files.
For the case of a simple certifiable library, or a user-defined configuration, the run-time library is designed to expedite the certification process for an application that needs to use its features (e.g. concurrency or exception propagation). For example, it may be simpler and less expensive to certify a concurrent program built on the Ravenscar Profile than to certify a sequential program with no run-time library (should concurrency need to be simulated in application code).
Although limited in terms of dynamic Ada semantics, all Certifiable Profiles
fully support static Ada constructs such as private types, generic templates,
and child units. Some dynamic semantics are also supported. For example, these
profiles allow the use of tagged types (at library level) and other
Object-Oriented Programming features, including dynamic dispatching. Note that
you can prohibit the general use of dynamic dispatching at the application
level using pragma
A traditional problem with predefined profiles is their inflexibility: if you need to use a feature that is outside a given profile, then it is your responsibility to address the certification issues deriving from its use. GNAT for cross platforms accommodate this need by allowing you to define a profile for the specific set of features you will use. Typically this will be for features with run-time libraries that require associated certification materials. Thus your program will have a tailored run-time library supporting only those features that you have specified.
6.2. Using GNAT Pro Features Relevant to Certification¶
GNAT Pro contain a number of features especially useful for certified software:
-gnatGoptions, the compiler generates a low-level version of the source program in an Ada-like format.
This serves as an intermediate form between the original source program and the generated object code. This intermediate representation may be used to understand the assembly code and verify some of the origins of non-traceable code. This expanded low-level generated code can also be used as the reference point for run-time debugging.
-gnatRoption, the compiler generates information about the choice of data representations.
The compiler produces an extensive set of warning messages to diagnose situations that are likely to be errors, even though they do not correspond to illegalities in Ada Reference Manual terms.
Two restriction identifiers for
pragma Restrictionsprohibit constructs that would generate implicit loops (
No_Implicit_Loops) or implicit conditionals (
No_Implicit_Conditionals). If these restrictions are specified, then either alternative code is generated without the implicit code, or the construct in question is rejected, forcing the programmer to make the loop or conditional explicit in the source. This is desirable in ensuring full testing of conditionals. See Controlling Implicit Conditionals and Loops.
A restriction identifier for
pragma Restrictionscan be used to restrict the form of explicit conditionals. Using the restriction identifier
No_Direct_Boolean_Operatorsprohibits the use of
oroperators, forcing instead the use of
or else. This can be useful in some certification procedures in order to reduce the number of test cases needed to fully exercise compound conditions.
-gnatyxoptions, the compiler performs various style checks that can be used to enforce rigorous coding standards, easing the verification process by ensuring that the source is formatted in a uniform manner.
Annex H of the Ada Reference Manual is fully implemented, and all implementation-dependent characteristics of the GNAT Pro implementation are defined in the GNAT Reference Manual, further supporting the goal of reviewable object code.
The Certifiable Profiles use one of two different exception-handling schemes
depending on the profile. The ZFP and Ravenscar SFP profiles implement the
pragma Restrictions (No_Exception_Propagation) is implicitly
applied to an application (see below). The Cert and Ravenscar Cert profiles
implement full Ada 83 exception handling, plus limited use of Ada 95 / Ada 2005
exception occurrences. Both implementations provide a ‘last chance handler’
capability to deal with unhandled exceptions. Details are described in the
sections on exceptions in the chapters specific to the individual profiles.
No_Exception_Propagation, which is the default
mode for the ZFP and Ravenscar SFP profiles, allows exceptions to be raised
and handled only if the handler is in the same subprogram (more generally
in the same scope not counting packages and blocks). This limits the
handling of exceptions to cases where raising the exception corresponds
to a simple goto to the exception handler. This is especially useful
for predefined exceptions. For example, the following is allowed in the
ZFP or Ravenscar SFP profiles:
begin X := Y + Z; exception when Constraint_Error => ... result of addition outside range of X end;
With this restriction in place, handlers are allowed, but can only be entered if the raise is local to the scope with the handler. The handler may not have a choice parameter, use of GNAT.Current_Exception is not permitted, and use of reraise statements (raise with no operand) is not permitted.
Warnings are given if an implicit or explicit exception raise is not covered by a local handler, or if an exception handler does not cover a case of a local raise. The following example shows these warnings in action:
1. pragma Restrictions (No_Exception_Propagation); 2. procedure p (C : in out Natural) is 3. begin 4. begin 5. C := C - 1; 6. exception 7. when Constraint_Error => 8. null; 9. when Tasking_Error => | >>> warning: pragma Restrictions (No_Exception_Propagation) in effect, this handler can never be entered, and has been removed 10. null; 11. end; 12. 13. begin 14. C := C - 1; | >>> warning: pragma Restrictions (No_Exception_Propagation) in effect, "Constraint_Error" may call Last_Chance_Handler 15. end; 16. 17. begin 18. raise Program_Error; | >>> warning: pragma Restrictions (No_Exception_Propagation) in effect, Last_Chance_Handler will be called on exception 19. end; 20. end p;
These warnings may be turned off globally using the switch -gnatw.X, or by using pragma Warnings (Off) locally.
As shown by the warnings above, if any other exception is raised, it is treated as unhandled, and causes the ‘last chance handler’ to be invoked. This routine is described below.
Exception handling can also be forbidden entirely while still allow the raising of exceptions by using:
pragma Restrictions (No_Exception_Handlers);
No handlers are permitted in a program if this restriction is specified, so
exceptions can never be handled in the usual Ada way. If run-time checking is
enabled, then it is possible for the predefined exceptions
Storage_Error to be raised at
run time. When such an exception is raised, a global ‘last chance handler’
routine is invoked automatically to deal with the fatal errors represented by
these exception occurrences. The term ‘last chance’ is used because the handler
routine is the last code executed. A default implementation is included with
the profile implementation and does nothing other than terminate the
application. This default version can be replaced by the user.
The replacement routine can be written in either Ada or C, and must have the
__gnat_last_chance_handler. For example, a user-defined
Ada procedure can be specified via pragma Export to have the required symbol
name. Note that the parameters to the handler routine are profile-specific.
Details are provided in the sections specific to the individual profiles.
All last chance handler implementations must effectively terminate the application. For example, on a bareboard target, it could enter an infinite loop. Alternatively, it could restart the hardware, thereby invoking a new instance of the application. In no case, however, may the application instance experiencing the exception continue execution after the last chance handler routine executes.
Exception declarations and
raise statements are still permitted under this
raise statement is compiled into a call of
To suppress all run-time error checking and generation of implicit
calls to the last chance handler, and to disallow all
statements, you may use:
pragma Restrictions (No_Exceptions);
The following switch is not relevant if the program has
pragma Restrictions (No_Exception_Handlers) or
pragma Restrictions (No_Exception_Propagation):
This switch causes traceback information to be stored with exception occurrences and is only applicable when there are exception handlers.
The following switches are not relevant if the program has
pragma Restrictions (No_Exceptions) or
pragma Restrictions (No_Exception_Propagation):
-gnatEThis switch enables run-time checks for ‘Access-Before-Elaboration’ errors.
Allocators and unchecked deallocation are permitted in a certification context. Use of these features will generate calls on one of the following C convention functions:
void *__gnat_malloc (size_t size); void __gnat_free (void *ptr);
The corresponding Ada subprogram declarations are:
type Pointer is access Character; -- This is really a void pointer type, the result from -- Gnat_Malloc will always be maximally aligned. function Gnat_Malloc (size : Interfaces.C.size_t) return Pointer; pragma Export (C, Gnat_Malloc, "__gnat_malloc"); procedure Gnat_Free (Ptr : Pointer); pragma Export (C, Gnat_Free, "__gnat_free");
These functions are part of the run-time library for some profiles, and must be
provided by the user otherwise. If included in the run-time library, they
appear in the file
s-memory.adb. To know if a given profile provides
this feature, see the relevant section in The Predefined Profiles.
If these functions are not provided, then the user must define
__gnat_malloc either in C or in Ada, using the above declarations;
otherwise the program will fail to bind. Analogously, if the program uses
__gnat_free must be defined.
For example, on VxWorks 6 Cert, one approach (if no deallocation is to be
allowed) is for the user to implement
Gnat_Malloc through calls on
memNoMoreAllocations function can be invoked to prevent further
allocations, for example at the end of package elaboration.
To prohibit the use of allocators or unchecked deallocation, you can use
pragma Restrictions with the following restriction identifiers
(these are defined in the Ada Reference Manual):
pragma Restrictions (No_Local_Allocators)
This prohibits the use of allocators except at the library level (thus allocations occur only at elaboration time, and not after the invocation of the main subprogram)
pragma Restrictions (No_Allocators)
This prohibits all explicit use of allocators, thus preventing allocators both at the local and library level
pragma Restrictions (No_Implicit_Heap_Allocations)
This prohibits implicit allocations (for example an array with nonstatic subscript bounds declared at library level)
pragma Restrictions (No_Unchecked_Deallocation)
This prohibits all use of the generic procedure
If any or all of these pragmas appear in the
the corresponding construct(s) will be forbidden throughout the
application. If all four of the above restrictions are in place, then
no calls to either
__gnat_free will be
6.2.3. Array and Record Assignments¶
The use of whole-object assignments of arrays and records is permitted.
However, on some targets such constructs may generate calls on the C
There are two ways to deal with this issue.
First, such assignments can be avoided at the source code level. You can replace an array assignment by an explicit loop, and a record assignment by a series of assignments to individual components. You can encapsulate such statements in a procedure if many such assignments occur.
Second, you can reuse or define an appropriate replacement for one (or
more) of the routines. For example, if certification protocols permit,
you can reuse the
routine(s) from the C library. An an example of defining one’s own
implementation, the following Ada procedure will supply the needed
with System; use System; with Interfaces.C; use Interfaces.C; function memcpy (dest, src : Address; n : size_t) return Address; pragma Export (C, memcpy, "memcpy"); with Ada.Unchecked_Conversion; function memcpy (dest, src : Address; n : size_t) return Address is subtype mem is char_array (size_t); type memptr is access mem; function to_memptr is new Ada.Unchecked_Conversion (address, memptr); dest_p : constant memptr := to_memptr (dest); src_p : constant memptr := to_memptr (src); begin if n > 0 then -- need to guard against n=0 since size_t is a modular type for J in 0 .. n - 1 loop dest_p (J) := src_p (J); end loop; end if; return dest; end memcpy;
memcpy routine provides the minimal required functionality.
A more elaborate version that deals with alignments and moves by words
rather than bytes where possible would improve performance. On some
targets there may be hardware instructions (e.g.
rep movsb on
the x86 architecture) that can be used to provide the needed
memcpy is not required to handle the overlap case, and the
GNAT Pro compiler ensures that any call to
memcpy meets the requirement
that the operands do not overlap.
On the other hand,
bcopy are required to handle
overlaps. Note that the order of the arguments of
bcopy differs from
memmove. A user-supplied version of
should take into account these differences.
6.2.4. Object-Oriented Programming¶
Large part of Ada’s object-oriented programming facilities is supported on the Certifiable Profiles. Objects of tagged and class-wide types may be declared. Dispatching and class-wide subprograms are allowed.
Tagged types must be declared at the library level.
No controlled types.
Ada.Tags.Tag_Errorare not available in the default implementations of these profiles.
The method invocation syntax of
Object.Operation (...) is fully
supported under the ZFP profile.
Generic dispatching constructors are not supported under the ZFP profile.
A subset of interface types is supported under the ZFP profile, with the following restrictions:
No task interfaces, protected interfaces or synchronized interfaces.
No dynamic membership test applied to interfaces (only those cases in which the evaluation can be performed at compile-time are supported).
No class-wide interface conversions.
No declaration of a tagged type covering interfaces in which its parent type has variable-size components.
Addressattribute is not supported on objects whose visible type is a class-wide interface.
Note: Dispatch tables are used to implement dynamic dispatching. Each tagged type has an associated data structure including a table containing the address of each of its primitive operations. The format of dispatch tables is compatible with the format described in the Itanium C++ ABI. This means, in particular, that the dispatching mechanism is deterministic and bounded in time, with a performance similar to an indirect call. Furthermore, dispatch tables are generated by the compiler as static data that is placed in a read-only data section of the object code; restriction Static_Dispatch_Tables can be used to identify tagged type declarations that cannot be placed in a read-only section. Appropriate linker scripts can be used to ensure that such sections are placed in ROM. Placing such tables in ROM is recommended because it offers some level of robustness to the dispatching mechanism: it prevents the possibility of unintended changes in such tables that could affect the control flow of the code. In addition, declarations of tagged types in this profile are statically elaborable and thus can be used in the presence of the restriction No_Elaboration_Code.
In order for the debugger to be able to print the complete type description of a tagged type, the program must have Ada.Tags as part of its closure. Otherwise, the debugger will not be able to print the name of the type from which the tagged type has been derived. This limitation can easily be addressed by introducing an artificial dependency on the Ada.Tags unit. Another option is to compile one unit that declares a tagged type with -fno-eliminate-unused-debug-types. This does not affect the ability to print the value of tagged objects, which should work without problem regardless.
6.2.5. Functions Returning Unconstrained Objects¶
By default, the cross and bareboard run-times allow functions returning objects of unconstrained types, such as unconstrained array types or discriminated record types without default values for the discriminants. For such functions, the amount of storage required for the result is not known at the point of the call. To implement this capability, the compiler generates references to a secondary-stack mechanism that requires run-time support.
If you need to use this capability, you should refer to the relevant section in
The Predefined Profiles, to see if it is already provided in the
run-time library or if you are responsible for providing an appropriate
implementation of this unit for a given profile. The specification of the
secondary-stack mechanism is described in the Ada package
System.Secondary_Stack, which is in the file
If you wish to disable this capability, you can use the
pragma Restrictions (No_Secondary_Stack);
this will generate an error
at compile time for each call to a function returning an unconstrained object.
6.2.6. Controlling Implicit Conditionals and Loops¶
Certain complex constructs in Ada result in generated code that contains
implicit conditionals, or implicit
for loops. (‘Implicit’ means that the
conditionals/loops are not present in the Ada source code.) For example, slice
assignments result in both kinds of generated code.
In some certification protocols, conditionals and loops require special treatment. For example, in the case of a conditional, it may be necessary to ensure that the test suite contains cases that branch in both directions for a given conditional. A question arises as to whether implicit conditionals and loops generated by the compiler are subject to the same verification requirements.
To address this issue, GNAT define two restriction identifiers that control whether the compiler is permitted to generate implicit conditionals and loops :
pragma Restrictions (No_Implicit_Conditionals); pragma Restrictions (No_Implicit_Loops);
These are partition-wide restrictions that ensure that the generated code respectively contains no conditionals and no loops. This is achieved in one of two ways. Either the compiler generates alternative code to avoid the implicit construct (possibly with some loss of efficiency) or, if it cannot find an equivalent code sequence, it rejects the program and flags the offending construct. In the latter situation, the programmer will need to revise the source program to avoid the implicit conditional or loop.
As an example, consider the slice assignment:
Data (J .. K) := Data (R .. S);
Ada language semantics requires that a slice assignment of this type be
performed nondestructively, as though the right-hand side were computed first
into a temporary, with the value then assigned to the left-hand side. In
practice it is more efficient to use a single loop, but the direction of the
loop needs to depend on the values of
J is less than
R then the move can take place left to right; otherwise it needs to be done
right to left. The normal code generated by GNAT Pro reflects this requirement:
if J < R then for L in J .. K loop Data (L) := Data (L - J + R); end loop; else for L in reverse J .. K loop Data (L) := Data (L - J + R); end loop; end if;
This code clearly contains both implicit conditionals and implicit loops.
If the restriction
No_Implicit_Conditionals is active, then the
effect is to generate code that uses a temporary:
This code avoids an implicit conditional at the expense of doing twice as many
moves. If the restriction
No_Implicit_Loops is also specified, then the
slice assignment above would not be permitted, and would be rejected as
illegal. This means that the programmer would need to modify the source program
to have an explicit loop (in the appropriate direction). This loop could then
be treated in whatever manner is required by the certification protocols in
The following constructs are not permitted in the presence of
No_Implicit_Conditionals (note that some are in any event
excluded from the Certifiable Profiles):
Comparison of record or array values
Conditional entry call
Timed entry call
Distributed System Annex features (shared passive partitions, etc.)
Widthattribute applied to real type
Absolute value operator if checks are on
mod, and division operators if checks are on
Dynamic elaboration check
The following constructs are not permitted in the presence
No_Implicit_Loops (note that entry families are in any event
excluded from some or all Certifiable Profiles):
Array aggregate with
Array types with implicit component initialization
Array equality test
Logical operations on array types
Controlled array types
Default array stream attributes
6.2.7. Controlling Use of Conditional Operators¶
Some testing procedures for certification can be more efficient if application
programs avoid the explicit use of
or and instead use
or else. This can facilitate meeting the requirement for MCDC
(‘Modified Condition / Decision Coverage’) testing. The net effect of using
the short-circuit versions is a significant reduction in the number of test
cases needed to demonstrate code and condition coverage.
GNAT provide an additional restriction identifier that addresses this issue by controlling the presence of direct boolean conditional operators:
pragma Restrictions (No_Direct_Boolean_Operators);
These are partition-wide restrictions that ensure that the source code does not
contain any instances of the direct boolean operators
will alert the programmer to the requirement to use
and then or
6.2.8. Avoiding Elaboration Code¶
Ada allows constructs (e.g., variables with implicit initializations) for which so-called elaboration code must be generated. In a certification context the need to certify elaboration code will increase costs, as it will be necessary to address questions such as why the compiler implicitly generated the elaboration code, which Ada requirement it met, which test cases are needed.
GNAT provides the pragma
Restrictions (No_Elaboration_Code), which alerts
you to constructs for which elaboration code would be generated by the
compiler. When this pragma is specified for a compilation unit, the compiler
outputs an error message whenever it needs to generate elaboration code. You
must then revise the program so that no elaboration code is generated. As an
example consider the following:
package List is type Elmt; type Temperature is range 0 .. 1_000; type Elmt_Ptr is access all Elmt; type Elmt is record T : Temperature; Next : Elmt_Ptr; end record; X : Elmt; end List;
When compiling unit
List, the compiler will generate the error
list.ads:11:04: violation of restriction "No_Elaboration_Code" at line 1
In this example GNAT Pro needs to generate elaboration code for object
X. To see the elaboration code that would be generated you can remove the
No_Elaboration_Code restriction and use the
-gnatG switch to view the
low-level version of the Ada code generated by GNAT Pro. In this case we
package list is type list__elmt; type list__temperature is range 0 .. 1000; type list__elmt_ptr is access all list__elmt; type list__elmt is record t : list__temperature; next : list__elmt_ptr; end record; [type list__TtemperatureB is new short_integer] freeze list__TtemperatureB  freeze list__elmt [ procedure list__elmtIP (_init : out list__elmt) is begin _init.next := null; return; end list__elmtIP; ] list__x : list__elmt; list__elmtIP (list__x); end list;
Elaboration code is generated inside package
List to null-initialize the
access value inside
X, by calling the initialization procedure for the
To avoid generating elaboration code, you can add explicit initialization as follows:
pragma Restrictions (No_Elaboration_Code); package List is type Elmt; type Temperature is range 0 .. 1_000; type Elmt_Ptr is access all Elmt; type Elmt is record T : Temperature; Next : Elmt_Ptr; end record; X : Elmt := (0, null); end List;
Since the initialization is now explicit, it becomes part of the requirements mapping and application design. In a certification context it is preferable to certify code that you write explicitly rather than code that gets generated implicitly.
6.2.9. Removal of Deactivated Code¶
Deactivated code in the executable requires specific treatment with standards such ED12/DO-178B (see 22.214.171.124d). This treatment can be simplified by diminishing the footprint of deactivated code in the final executable. This section summarizes the various features that can be used to minimize the footprint of deactivated code in the final executable program.
The compiler automatically removes local nested subprograms that are never used at all levels of optimization. It also removes unused library-level subprograms declared within package bodies at optimization level -O1 or higher.
Static Boolean conditionals
The compiler eliminates automatically all code protected by conditionals, if and case statements, that are statically detected to be false. For instance, with those declarations:
type Configs is (config1, config2, config3); ... C : constant Configs := config2;
the following code
if C = config1 then some_code0; end if; case C is when config1 => some_code1; when config2 => some_code2; when config3 => some_code3; end case;
is transformed into:
The elimination done by the compiler can be traced using an optional compiler warning enabled with
The user can prevent code generation for subprograms that are known to be deactivated by placing Eliminate pragmas in the configuration pragmas file:
pragma Eliminate (Unit, Unused_Subp, Source_Location => "unit.adb:19")
The compiler will issue an error if an attempt is made to call an eliminated subprogram.
Linker Level Removal
Some configurations support linker level removal of unused subprograms and data. The source code needs to be compiled with the options
-fdata-sectionsand the linking must be performed with option
-Wl,--gc-sections. Traceability of the code removal is provided through a chapter called “Discarded Input sections” in the map file that can be produced by the linker with option
These methods can be used to reduce the amount of code in the final executable corresponding to deactivated source code. The last three offer means of tracing the removed code and thus can be used for traceability purposes or as documentation of the deactivation mechanism. The last method can also remove code added by the compiler such as the implicit initialization procedures associated with composite types when they are not used. It therefore simplifies the reverse traceability from object to source.
6.2.10. Traceability from Source Code to Object Code¶
During the build process, the GNAT Pro toolchain manipulates several program representations, in particular:
The initial source code;
The expanded code, which is low level Ada pseudo-code;
Assembler code; and
In order to help the traceability process, GNAT Pro gives access to the intermediate format, through the following options:
This switch causes a listing of a pseudo-Ada low-level version of the compilation unit to be directed to a file.
This switch produces a listing of a pseudo-Ada low-level version of the compilation unit.
This switch enhances traceability of the expanded code by adding the original source code as comments just before the corresponding expansion. It has to be used in conjunction with
This switch causes generation of an assembly language version of the compilation unit, instead of an object file.
This switch causes the compiler to save temporary files (in particular, the
.sfile) while still generating
This switch causes the compiler to decorate the assembly output with comments containing the names of the entities (e.g. local variables) being manipulated by the current assembly instruction.
This switch causes the compiler to emit symbolic names for register in the assembly output. This switch is specific to PowerPC and even though it is not directly related to traceability, it is worth mentioning because it greatly improves assembly code readability.
-Wa,-adhlThis switch instructs the GNU assembler to produce a text listing of the generated code containing the high-level source and the assembly while excluding debugger directives (for readability reasons). The listing goes to standard output and can be redirected to a file using the syntax
-Wa,-adhl=file.lstwhich save it in the file
-gnatRThis switch causes representation information to be generated for declared types and objects.
These options can be combined in various ways. A fairly complete source to object traceability is provided by:
$ <target>-gcc -c -gnatDL -Wa,-adhl -fverbose-asm -mregnames prg.adb
6.2.11. Optimization issues¶
-On compiler switch sets the optimization level to
n is an integer between 0 and 3.
n is omitted, it is set to 1.
Generally you should use the
-On switch to enable optimization,
because this is the level at which you can most easily track the correspondence
between source code and object code. Although for safety-critical programs
optimizations are often regarded with suspicion, the fundamental reason for
this concern is traceability. At the
-O0 level, traceability is in fact
more difficult due to the large amount of naive code that is generated. The
optimizations performed at level
-O1 eliminate redundant code, but
avoid the kind of code-shuffling transformations that can obscure the
correspondence between source and object code.
If you consider coverage, it can be useful to disable optimizations on
conditional statements. The option -fno-short-circuit-optimize specifically
disables boolean operator optimizations (those which transform
or else into
and then into
and), and the options -fno-if-conversion and
-fno-if-conversion2 disable optimization passes that try to remove
conditional jumps for if statements and use conditional move instead. These
switches help to preserve the original jump structure implied by the source,
thus helping source-to-object traceability, and facilitating certification and
coverage analysis at the object level.
6.2.12. Other useful features¶
The -gnaty compiler switches direct the compiler to enforce style consistency checks, which can be useful in ensuring a uniform lexical appearance (and easing program readability) across a project.
Annex H in the Ada Reference Manual defines a set of restrictions
identifiers, many of which are relevant for code that needs to be certified.
If you provide a
pragma Restrictions with any of these identifiers,
the compiler will prohibit your program from using the corresponding construct.
6.2.13. Program Build Options¶
For the most part, you can build programs using the Certifiable Profiles in the same way, and with the same set of switches, as in a full Ada environment. However, certain switches are not relevant for the Certifiable Profiles. This section lists these switches; a complete description of the compiler switches appears in the GNAT User’s Guide for Native Platforms and, in the case of general gcc switches, the Using GNU GCC manual.
126.96.36.199. Compiler Switches¶
The following switches are not relevant in certain Certifiable Profiles, since they are associated with features that are outside these profiles:
This switch enables stack overflow checking, and is allowed for the Cert and Ravenscar Cert profiles on VxWorks 653, but not for ZFP or Ravenscar SFP.
This switch enables pragma
Assert, but is subject to exception propagation and handling restrictions in ZFP and Ravenscar SFP.
This switch enables run-time checks for integer overflow, but is subject to exception propagation and handling restrictions in ZFP and Ravenscar SFP.
This switch sets the timeslice in a tasking program.
This switch is used for distributed Ada programs.
The following switches are not relevant in Zero Footprint, Cert, or Ravenscar modes:
-staticThis switch specifies linking with a static GNAT run-time library.
-sharedThis switch specifies linking with a shared GNAT run-time library.
-TThis switch sets the timeslice for a tasking program.
In addition, the
-t switch overrides standard Ada unit consistency
checks and would generally not be used for high-integrity applications.
-f switch for elaboration-order control should
not be used; see the discussion of elaboration-order issues in
GNAT User’s Guide for Native Platforms.