diff options
Diffstat (limited to 'gcc/ada/gnat_ugn.texi')
-rw-r--r-- | gcc/ada/gnat_ugn.texi | 893 |
1 files changed, 679 insertions, 214 deletions
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 2579b31..6cd0bed 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -3,7 +3,7 @@ @setfilename gnat_ugn.info @documentencoding UTF-8 @ifinfo -@*Generated by Sphinx 8.0.2.@* +@*Generated by Sphinx 8.2.3.@* @end ifinfo @settitle GNAT User's Guide for Native Platforms @defindex ge @@ -19,7 +19,7 @@ @copying @quotation -GNAT User's Guide for Native Platforms , Jan 13, 2025 +GNAT User's Guide for Native Platforms , Jun 27, 2025 AdaCore @@ -334,6 +334,7 @@ GNAT and Program Execution * Performing Dimensionality Analysis in GNAT:: * Stack Related Facilities:: * Memory Management Issues:: +* Sanitizers for Ada:: Running and Debugging Ada Programs @@ -415,6 +416,12 @@ Memory Management Issues * Some Useful Memory Pools:: * The GNAT Debug Pool Facility:: +Sanitizers for Ada + +* AddressSanitizer:: +* UndefinedBehaviorSanitizer:: +* Sanitizers in mixed-language applications:: + Platform-Specific Information * Run-Time Libraries:: @@ -2911,6 +2918,10 @@ You can place configuration pragmas either appear at the start of a compilation unit or in a configuration pragma file that applies to all compilations performed in a given compilation environment. +Configuration pragmas placed before a library level package specification +are not propagated to the corresponding package body (see RM 10.1.5(8)); +they must be added explicitly to the package body. + GNAT includes the @code{gnatchop} utility to provide an automatic way to handle configuration pragmas that follows the semantics for compilations (that is, files with multiple units) described in the RM. @@ -9846,7 +9857,7 @@ Treat pragma Restrictions as Restriction_Warnings. @table @asis -@item @code{-gnatR[0|1|2|3|4][e][j][m][s]} +@item @code{-gnatR[0|1|2|3|4][e][h][m][j][s]} Output representation information for declared types, objects and subprograms. Note that this switch is not allowed if a previous @@ -10072,7 +10083,7 @@ Library (RTL) ALI files. @code{n} controls the optimization level: -@multitable {xxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} +@multitable {xxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} @item `n' @@ -10087,7 +10098,7 @@ Effect @tab -No optimization, the default setting if no @code{-O} appears +No optimization, the default setting if no @code{-O} appears. @item @@ -10095,9 +10106,8 @@ No optimization, the default setting if no @code{-O} appears @tab -Normal optimization, the default if you specify @code{-O} without an -operand. A good compromise between code quality and compilation -time. +Moderate optimization, same as @code{-O} without an operand. +A good compromise between code quality and compilation time. @item @@ -10105,7 +10115,7 @@ time. @tab -Extensive optimization, may improve execution time, possibly at +Extensive optimization, should improve execution time, possibly at the cost of substantially increased compilation time. @item @@ -10114,8 +10124,8 @@ the cost of substantially increased compilation time. @tab -Same as @code{-O2}, and also includes inline expansion for small -subprograms in the same unit. +Full optimization, may further improve execution time, possibly at +the cost of substantially larger generated code. @item @@ -10123,7 +10133,23 @@ subprograms in the same unit. @tab -Optimize space usage +Optimize for size (code and data) rather than speed. + +@item + +`z' + +@tab + +Optimize aggressively for size (code and data) rather than speed. + +@item + +`g' + +@tab + +Optimize for debugging experience rather than speed. @end multitable @@ -15266,7 +15292,7 @@ restriction warnings rather than restrictions. @table @asis -@item @code{-gnatR[0|1|2|3|4][e][j][m][s]} +@item @code{-gnatR[0|1|2|3|4][e][h][m][j][s]} This switch controls output from the compiler of a listing showing representation information for declared types, objects and subprograms. @@ -15295,17 +15321,21 @@ If the switch is followed by an @code{e} (e.g. @code{-gnatR2e}), then extended representation information for record sub-components of records is included. +If the switch is followed by a @code{h} (e.g. @code{-gnatR3h}), then +the components of records are sorted by increasing offsets and holes +between consecutive components are flagged. + If the switch is followed by an @code{m} (e.g. @code{-gnatRm}), then subprogram conventions and parameter passing mechanisms for all the subprograms are included. -If the switch is followed by a @code{j} (e.g., @code{-gnatRj}), then +If the switch is followed by a @code{j} (e.g. @code{-gnatRj}), then the output is in the JSON data interchange format specified by the ECMA-404 standard. The semantic description of this JSON output is available in the specification of the Repinfo unit present in the compiler sources. -If the switch is followed by an @code{s} (e.g., @code{-gnatR3s}), then +If the switch is followed by an @code{s} (e.g. @code{-gnatR3s}), then the output is to a file with the name @code{file.rep} where @code{file} is the name of the corresponding source file, except if @code{j} is also specified, in which case the file name is @code{file.json}. @@ -17634,6 +17664,9 @@ file with @code{gprconfig} and using it with @code{gprbuild}; see the can determine from the first line of the @code{.ali} file which version of GNAT built that file because it contains either @code{GNAT} or @code{GNAT-LLVM}. + +You can also explicitly select GNAT LLVM in your existing GPR project +file by adding @code{for Toolchain_Name("Ada") use "GNAT_LLVM";} @end itemize @@ -18331,6 +18364,9 @@ This chapter covers several topics: @item @ref{151,,Memory Management Issues} + +@item +@ref{152,,Sanitizers for Ada} @end itemize @menu @@ -18341,11 +18377,12 @@ This chapter covers several topics: * Performing Dimensionality Analysis in GNAT:: * Stack Related Facilities:: * Memory Management Issues:: +* Sanitizers for Ada:: @end menu @node Running and Debugging Ada Programs,Profiling,,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id2}@anchor{14b}@anchor{gnat_ugn/gnat_and_program_execution running-and-debugging-ada-programs}@anchor{152} +@anchor{gnat_ugn/gnat_and_program_execution id2}@anchor{14b}@anchor{gnat_ugn/gnat_and_program_execution running-and-debugging-ada-programs}@anchor{153} @section Running and Debugging Ada Programs @@ -18399,7 +18436,7 @@ the incorrect user program. @end menu @node The GNAT Debugger GDB,Running GDB,,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id3}@anchor{153}@anchor{gnat_ugn/gnat_and_program_execution the-gnat-debugger-gdb}@anchor{154} +@anchor{gnat_ugn/gnat_and_program_execution id3}@anchor{154}@anchor{gnat_ugn/gnat_and_program_execution the-gnat-debugger-gdb}@anchor{155} @subsection The GNAT Debugger GDB @@ -18457,7 +18494,7 @@ the debugging information and can respond to user commands to inspect variables and more generally to report on the state of execution. @node Running GDB,Introduction to GDB Commands,The GNAT Debugger GDB,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id4}@anchor{155}@anchor{gnat_ugn/gnat_and_program_execution running-gdb}@anchor{156} +@anchor{gnat_ugn/gnat_and_program_execution id4}@anchor{156}@anchor{gnat_ugn/gnat_and_program_execution running-gdb}@anchor{157} @subsection Running GDB @@ -18484,7 +18521,7 @@ exactly as if the debugger were not present. The following section describes some of the additional commands that you can give to @code{GDB}. @node Introduction to GDB Commands,Using Ada Expressions,Running GDB,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id5}@anchor{157}@anchor{gnat_ugn/gnat_and_program_execution introduction-to-gdb-commands}@anchor{158} +@anchor{gnat_ugn/gnat_and_program_execution id5}@anchor{158}@anchor{gnat_ugn/gnat_and_program_execution introduction-to-gdb-commands}@anchor{159} @subsection Introduction to GDB Commands @@ -18698,7 +18735,7 @@ characters need be typed to disambiguate the command (e.g., “br” for @code{breakpoint}). @node Using Ada Expressions,Calling User-Defined Subprograms,Introduction to GDB Commands,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id6}@anchor{159}@anchor{gnat_ugn/gnat_and_program_execution using-ada-expressions}@anchor{15a} +@anchor{gnat_ugn/gnat_and_program_execution id6}@anchor{15a}@anchor{gnat_ugn/gnat_and_program_execution using-ada-expressions}@anchor{15b} @subsection Using Ada Expressions @@ -18736,7 +18773,7 @@ their packages, regardless of context. Where this causes ambiguity, For details on the supported Ada syntax, see @cite{Debugging with GDB}. @node Calling User-Defined Subprograms,Using the next Command in a Function,Using Ada Expressions,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution calling-user-defined-subprograms}@anchor{15b}@anchor{gnat_ugn/gnat_and_program_execution id7}@anchor{15c} +@anchor{gnat_ugn/gnat_and_program_execution calling-user-defined-subprograms}@anchor{15c}@anchor{gnat_ugn/gnat_and_program_execution id7}@anchor{15d} @subsection Calling User-Defined Subprograms @@ -18795,7 +18832,7 @@ elements directly from GDB, you can write a callable procedure that prints the elements in the format you desire. @node Using the next Command in a Function,Stopping When Ada Exceptions Are Raised,Calling User-Defined Subprograms,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id8}@anchor{15d}@anchor{gnat_ugn/gnat_and_program_execution using-the-next-command-in-a-function}@anchor{15e} +@anchor{gnat_ugn/gnat_and_program_execution id8}@anchor{15e}@anchor{gnat_ugn/gnat_and_program_execution using-the-next-command-in-a-function}@anchor{15f} @subsection Using the `next' Command in a Function @@ -18818,7 +18855,7 @@ The value returned is always that from the first return statement that was stepped through. @node Stopping When Ada Exceptions Are Raised,Ada Tasks,Using the next Command in a Function,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id9}@anchor{15f}@anchor{gnat_ugn/gnat_and_program_execution stopping-when-ada-exceptions-are-raised}@anchor{160} +@anchor{gnat_ugn/gnat_and_program_execution id9}@anchor{160}@anchor{gnat_ugn/gnat_and_program_execution stopping-when-ada-exceptions-are-raised}@anchor{161} @subsection Stopping When Ada Exceptions Are Raised @@ -18875,7 +18912,7 @@ argument, prints out only those exceptions whose name matches `regexp'. @geindex Tasks (in gdb) @node Ada Tasks,Debugging Generic Units,Stopping When Ada Exceptions Are Raised,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution ada-tasks}@anchor{161}@anchor{gnat_ugn/gnat_and_program_execution id10}@anchor{162} +@anchor{gnat_ugn/gnat_and_program_execution ada-tasks}@anchor{162}@anchor{gnat_ugn/gnat_and_program_execution id10}@anchor{163} @subsection Ada Tasks @@ -18962,7 +18999,7 @@ see @cite{Debugging with GDB}. @geindex Generics @node Debugging Generic Units,Remote Debugging with gdbserver,Ada Tasks,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution debugging-generic-units}@anchor{163}@anchor{gnat_ugn/gnat_and_program_execution id11}@anchor{164} +@anchor{gnat_ugn/gnat_and_program_execution debugging-generic-units}@anchor{164}@anchor{gnat_ugn/gnat_and_program_execution id11}@anchor{165} @subsection Debugging Generic Units @@ -19022,7 +19059,7 @@ variables, as you do for other units. @geindex Remote Debugging with gdbserver @node Remote Debugging with gdbserver,GNAT Abnormal Termination or Failure to Terminate,Debugging Generic Units,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id12}@anchor{165}@anchor{gnat_ugn/gnat_and_program_execution remote-debugging-with-gdbserver}@anchor{166} +@anchor{gnat_ugn/gnat_and_program_execution id12}@anchor{166}@anchor{gnat_ugn/gnat_and_program_execution remote-debugging-with-gdbserver}@anchor{167} @subsection Remote Debugging with gdbserver @@ -19081,7 +19118,7 @@ x86_64-linux. @geindex Abnormal Termination or Failure to Terminate @node GNAT Abnormal Termination or Failure to Terminate,Naming Conventions for GNAT Source Files,Remote Debugging with gdbserver,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution gnat-abnormal-termination-or-failure-to-terminate}@anchor{167}@anchor{gnat_ugn/gnat_and_program_execution id13}@anchor{168} +@anchor{gnat_ugn/gnat_and_program_execution gnat-abnormal-termination-or-failure-to-terminate}@anchor{168}@anchor{gnat_ugn/gnat_and_program_execution id13}@anchor{169} @subsection GNAT Abnormal Termination or Failure to Terminate @@ -19136,7 +19173,7 @@ Finally, you can start @code{gdb} directly on the @code{gnat1} executable. @code{gnat1} is the front-end of GNAT and can be run independently (normally it is just called from @code{gcc}). You can use @code{gdb} on @code{gnat1} as you -would on a C program (but @ref{154,,The GNAT Debugger GDB} for caveats). The +would on a C program (but @ref{155,,The GNAT Debugger GDB} for caveats). The @code{where} command is the first line of attack; the variable @code{lineno} (seen by @code{print lineno}), used by the second phase of @code{gnat1} and by the @code{gcc} back end, indicates the source line at @@ -19145,7 +19182,7 @@ the source file. @end itemize @node Naming Conventions for GNAT Source Files,Getting Internal Debugging Information,GNAT Abnormal Termination or Failure to Terminate,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id14}@anchor{169}@anchor{gnat_ugn/gnat_and_program_execution naming-conventions-for-gnat-source-files}@anchor{16a} +@anchor{gnat_ugn/gnat_and_program_execution id14}@anchor{16a}@anchor{gnat_ugn/gnat_and_program_execution naming-conventions-for-gnat-source-files}@anchor{16b} @subsection Naming Conventions for GNAT Source Files @@ -19235,7 +19272,7 @@ the other @code{.c} files are modifications of common @code{gcc} files. @end itemize @node Getting Internal Debugging Information,Stack Traceback,Naming Conventions for GNAT Source Files,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution getting-internal-debugging-information}@anchor{16b}@anchor{gnat_ugn/gnat_and_program_execution id15}@anchor{16c} +@anchor{gnat_ugn/gnat_and_program_execution getting-internal-debugging-information}@anchor{16c}@anchor{gnat_ugn/gnat_and_program_execution id15}@anchor{16d} @subsection Getting Internal Debugging Information @@ -19263,7 +19300,7 @@ are replaced with run-time calls. @geindex stack unwinding @node Stack Traceback,Pretty-Printers for the GNAT runtime,Getting Internal Debugging Information,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id16}@anchor{16d}@anchor{gnat_ugn/gnat_and_program_execution stack-traceback}@anchor{16e} +@anchor{gnat_ugn/gnat_and_program_execution id16}@anchor{16e}@anchor{gnat_ugn/gnat_and_program_execution stack-traceback}@anchor{16f} @subsection Stack Traceback @@ -19292,7 +19329,7 @@ is enabled and no exception is raised during program execution. @end menu @node Non-Symbolic Traceback,Symbolic Traceback,,Stack Traceback -@anchor{gnat_ugn/gnat_and_program_execution id17}@anchor{16f}@anchor{gnat_ugn/gnat_and_program_execution non-symbolic-traceback}@anchor{170} +@anchor{gnat_ugn/gnat_and_program_execution id17}@anchor{170}@anchor{gnat_ugn/gnat_and_program_execution non-symbolic-traceback}@anchor{171} @subsubsection Non-Symbolic Traceback @@ -19614,7 +19651,7 @@ addresses need to be specified in C format, with a leading ‘0x’). @geindex symbolic @node Symbolic Traceback,,Non-Symbolic Traceback,Stack Traceback -@anchor{gnat_ugn/gnat_and_program_execution id18}@anchor{171}@anchor{gnat_ugn/gnat_and_program_execution symbolic-traceback}@anchor{172} +@anchor{gnat_ugn/gnat_and_program_execution id18}@anchor{172}@anchor{gnat_ugn/gnat_and_program_execution symbolic-traceback}@anchor{173} @subsubsection Symbolic Traceback @@ -19733,7 +19770,7 @@ traceback, which will also be printed if an unhandled exception terminates the program. @node Pretty-Printers for the GNAT runtime,,Stack Traceback,Running and Debugging Ada Programs -@anchor{gnat_ugn/gnat_and_program_execution id19}@anchor{173}@anchor{gnat_ugn/gnat_and_program_execution pretty-printers-for-the-gnat-runtime}@anchor{174} +@anchor{gnat_ugn/gnat_and_program_execution id19}@anchor{174}@anchor{gnat_ugn/gnat_and_program_execution pretty-printers-for-the-gnat-runtime}@anchor{175} @subsection Pretty-Printers for the GNAT runtime @@ -19842,7 +19879,7 @@ for more information. @geindex Profiling @node Profiling,Improving Performance,Running and Debugging Ada Programs,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id20}@anchor{175}@anchor{gnat_ugn/gnat_and_program_execution profiling}@anchor{14c} +@anchor{gnat_ugn/gnat_and_program_execution id20}@anchor{176}@anchor{gnat_ugn/gnat_and_program_execution profiling}@anchor{14c} @section Profiling @@ -19858,7 +19895,7 @@ This section describes how to use the @code{gprof} profiler tool on Ada programs @end menu @node Profiling an Ada Program with gprof,,,Profiling -@anchor{gnat_ugn/gnat_and_program_execution id21}@anchor{176}@anchor{gnat_ugn/gnat_and_program_execution profiling-an-ada-program-with-gprof}@anchor{177} +@anchor{gnat_ugn/gnat_and_program_execution id21}@anchor{177}@anchor{gnat_ugn/gnat_and_program_execution profiling-an-ada-program-with-gprof}@anchor{178} @subsection Profiling an Ada Program with gprof @@ -19913,7 +19950,7 @@ to interpret the results. @end menu @node Compilation for profiling,Program execution,,Profiling an Ada Program with gprof -@anchor{gnat_ugn/gnat_and_program_execution compilation-for-profiling}@anchor{178}@anchor{gnat_ugn/gnat_and_program_execution id22}@anchor{179} +@anchor{gnat_ugn/gnat_and_program_execution compilation-for-profiling}@anchor{179}@anchor{gnat_ugn/gnat_and_program_execution id22}@anchor{17a} @subsubsection Compilation for profiling @@ -19944,7 +19981,7 @@ Note that on Windows, @code{gprof} does not support PIE. You should add the @code{-no-pie} switch to the linker flags to disable PIE. @node Program execution,Running gprof,Compilation for profiling,Profiling an Ada Program with gprof -@anchor{gnat_ugn/gnat_and_program_execution id23}@anchor{17a}@anchor{gnat_ugn/gnat_and_program_execution program-execution}@anchor{17b} +@anchor{gnat_ugn/gnat_and_program_execution id23}@anchor{17b}@anchor{gnat_ugn/gnat_and_program_execution program-execution}@anchor{17c} @subsubsection Program execution @@ -19959,7 +19996,7 @@ generated in the directory where the program was launched from. If this file already exists, it will be overwritten by running the program. @node Running gprof,Interpretation of profiling results,Program execution,Profiling an Ada Program with gprof -@anchor{gnat_ugn/gnat_and_program_execution id24}@anchor{17c}@anchor{gnat_ugn/gnat_and_program_execution running-gprof}@anchor{17d} +@anchor{gnat_ugn/gnat_and_program_execution id24}@anchor{17d}@anchor{gnat_ugn/gnat_and_program_execution running-gprof}@anchor{17e} @subsubsection Running gprof @@ -20071,7 +20108,7 @@ switch. @end table @node Interpretation of profiling results,,Running gprof,Profiling an Ada Program with gprof -@anchor{gnat_ugn/gnat_and_program_execution id25}@anchor{17e}@anchor{gnat_ugn/gnat_and_program_execution interpretation-of-profiling-results}@anchor{17f} +@anchor{gnat_ugn/gnat_and_program_execution id25}@anchor{17f}@anchor{gnat_ugn/gnat_and_program_execution interpretation-of-profiling-results}@anchor{180} @subsubsection Interpretation of profiling results @@ -20088,7 +20125,7 @@ and the subprograms that it calls. It also provides an estimate of the time spent in each of those callers and called subprograms. @node Improving Performance,Overflow Check Handling in GNAT,Profiling,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id26}@anchor{14d}@anchor{gnat_ugn/gnat_and_program_execution improving-performance}@anchor{180} +@anchor{gnat_ugn/gnat_and_program_execution id26}@anchor{14d}@anchor{gnat_ugn/gnat_and_program_execution improving-performance}@anchor{181} @section Improving Performance @@ -20109,7 +20146,7 @@ which can reduce the size of program executables. @end menu @node Performance Considerations,Text_IO Suggestions,,Improving Performance -@anchor{gnat_ugn/gnat_and_program_execution id27}@anchor{181}@anchor{gnat_ugn/gnat_and_program_execution performance-considerations}@anchor{182} +@anchor{gnat_ugn/gnat_and_program_execution id27}@anchor{182}@anchor{gnat_ugn/gnat_and_program_execution performance-considerations}@anchor{183} @subsection Performance Considerations @@ -20170,7 +20207,7 @@ some guidelines on debugging optimized code. @end menu @node Controlling Run-Time Checks,Use of Restrictions,,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution controlling-run-time-checks}@anchor{183}@anchor{gnat_ugn/gnat_and_program_execution id28}@anchor{184} +@anchor{gnat_ugn/gnat_and_program_execution controlling-run-time-checks}@anchor{184}@anchor{gnat_ugn/gnat_and_program_execution id28}@anchor{185} @subsubsection Controlling Run-Time Checks @@ -20222,7 +20259,7 @@ remove checks) or @code{pragma Unsuppress} (to add back suppressed checks) in your program source. @node Use of Restrictions,Optimization Levels,Controlling Run-Time Checks,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id29}@anchor{185}@anchor{gnat_ugn/gnat_and_program_execution use-of-restrictions}@anchor{186} +@anchor{gnat_ugn/gnat_and_program_execution id29}@anchor{186}@anchor{gnat_ugn/gnat_and_program_execution use-of-restrictions}@anchor{187} @subsubsection Use of Restrictions @@ -20258,7 +20295,7 @@ this, it also means you can write code without worrying about the possibility of an immediate abort at any point. @node Optimization Levels,Debugging Optimized Code,Use of Restrictions,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id30}@anchor{187}@anchor{gnat_ugn/gnat_and_program_execution optimization-levels}@anchor{f0} +@anchor{gnat_ugn/gnat_and_program_execution id30}@anchor{188}@anchor{gnat_ugn/gnat_and_program_execution optimization-levels}@anchor{f0} @subsubsection Optimization Levels @@ -20277,13 +20314,12 @@ Turning on optimization makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program. -If you use multiple @code{-O} switches, with or without level -numbers, the last such switch is the one that’s used. - -You can use the -@code{-O} switch (the permitted forms are @code{-O0}, @code{-O1} -@code{-O2}, @code{-O3}, and @code{-Os}) -to @code{gcc} to control the optimization level: +You can pass the @code{-O} switch, with or without an operand +(the permitted forms with an operand are @code{-O0}, @code{-O1}, +@code{-O2}, @code{-O3}, @code{-Os}, @code{-Oz}, and +@code{-Og}) to @code{gcc} to control the optimization level. If you +pass multiple @code{-O} switches, with or without an operand, +the last such switch is the one that’s used: @itemize * @@ -20294,8 +20330,7 @@ to @code{gcc} to control the optimization level: @item @code{-O0} -No optimization (the default); -generates unoptimized code but has +No optimization (the default); generates unoptimized code but has the fastest compilation time. Debugging is easiest with this switch. Note that many other compilers do substantial optimization even if @@ -20312,10 +20347,11 @@ mind when doing performance comparisons. @item @code{-O1} -Moderate optimization; optimizes reasonably well but does not -degrade compilation time significantly. You may not be able to see -some variables in the debugger and changing the value of some -variables in the debugger may not have the effect you desire. +Moderate optimization (same as @code{-O} without an operand); +optimizes reasonably well but does not degrade compilation time +significantly. You may not be able to see some variables in the +debugger, and changing the value of some variables in the debugger +may not have the effect you desire. @end table @item @@ -20324,9 +20360,8 @@ variables in the debugger may not have the effect you desire. @item @code{-O2} -Full optimization; -generates highly optimized code and has -the slowest compilation time. You may see significant impacts on +Extensive optimization; generates highly optimized code but has +an increased compilation time. You may see significant impacts on your ability to display and modify variables in the debugger. @end table @@ -20336,9 +20371,9 @@ your ability to display and modify variables in the debugger. @item @code{-O3} -Full optimization as in @code{-O2}; -also uses more aggressive automatic inlining of subprograms within a unit -(@ref{104,,Inlining of Subprograms}) and attempts to vectorize loops. +Full optimization; attempts more sophisticated transformations, in +particular on loops, possibly at the cost of larger generated code. +You may be hardly able to use the debugger at this optimization level. @end table @item @@ -20347,16 +20382,41 @@ also uses more aggressive automatic inlining of subprograms within a unit @item @code{-Os} -Optimize space usage (code and data) of resulting program. +Optimize for size (code and data) of resulting binary rather than +speed; based on the @code{-O2} optimization level, but disables +some of its transformations that often increase code size, as well +as performs further optimizations designed to reduce code size. +@end table + +@item + +@table @asis + +@item @code{-Oz} + +Optimize aggressively for size (code and data) of resulting binary +rather than speed; may increase the number of instructions executed +if these instructions require fewer bytes to be encoded. +@end table + +@item + +@table @asis + +@item @code{-Og} + +Optimize for debugging experience rather than speed; based on the +@code{-O1} optimization level, but attempts to eliminate all the +negative effects of optimization on debugging. @end table @end itemize Higher optimization levels perform more global transformations on the program and apply more expensive analysis algorithms in order to generate faster and more compact code. The price in compilation time, and the -resulting improvement in execution time, -both depend on the particular application and the hardware environment. -You should experiment to find the best level for your application. +resulting improvement in execution time, both depend on the particular +application and the hardware environment. You should experiment to find +the best level for your application. Since the precise set of optimizations done at each level will vary from release to release (and sometime from target to target), it is best to think @@ -20381,7 +20441,7 @@ since it often results in larger executables which may run more slowly. See further discussion of this point in @ref{104,,Inlining of Subprograms}. @node Debugging Optimized Code,Inlining of Subprograms,Optimization Levels,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution debugging-optimized-code}@anchor{188}@anchor{gnat_ugn/gnat_and_program_execution id31}@anchor{189} +@anchor{gnat_ugn/gnat_and_program_execution debugging-optimized-code}@anchor{189}@anchor{gnat_ugn/gnat_and_program_execution id31}@anchor{18a} @subsubsection Debugging Optimized Code @@ -20509,7 +20569,7 @@ on the resulting executable, which removes both debugging information and global symbols. @node Inlining of Subprograms,Floating Point Operations,Debugging Optimized Code,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id32}@anchor{18a}@anchor{gnat_ugn/gnat_and_program_execution inlining-of-subprograms}@anchor{104} +@anchor{gnat_ugn/gnat_and_program_execution id32}@anchor{18b}@anchor{gnat_ugn/gnat_and_program_execution inlining-of-subprograms}@anchor{104} @subsubsection Inlining of Subprograms @@ -20653,7 +20713,7 @@ indeed you should use @code{-O3} only if tests show that it actually improves performance for your program. @node Floating Point Operations,Vectorization of loops,Inlining of Subprograms,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution floating-point-operations}@anchor{18b}@anchor{gnat_ugn/gnat_and_program_execution id33}@anchor{18c} +@anchor{gnat_ugn/gnat_and_program_execution floating-point-operations}@anchor{18c}@anchor{gnat_ugn/gnat_and_program_execution id33}@anchor{18d} @subsubsection Floating Point Operations @@ -20700,7 +20760,7 @@ Note that the ABI has the same form for both floating-point models, so you can mix units compiled with and without these switches. @node Vectorization of loops,Other Optimization Switches,Floating Point Operations,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id34}@anchor{18d}@anchor{gnat_ugn/gnat_and_program_execution vectorization-of-loops}@anchor{18e} +@anchor{gnat_ugn/gnat_and_program_execution id34}@anchor{18e}@anchor{gnat_ugn/gnat_and_program_execution vectorization-of-loops}@anchor{18f} @subsubsection Vectorization of loops @@ -20856,7 +20916,7 @@ omit the non-vectorized version of the loop as well as the run-time test. This is also currently only supported by the GCC back end. @node Other Optimization Switches,Optimization and Strict Aliasing,Vectorization of loops,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id35}@anchor{18f}@anchor{gnat_ugn/gnat_and_program_execution other-optimization-switches}@anchor{190} +@anchor{gnat_ugn/gnat_and_program_execution id35}@anchor{190}@anchor{gnat_ugn/gnat_and_program_execution other-optimization-switches}@anchor{191} @subsubsection Other Optimization Switches @@ -20873,7 +20933,7 @@ full details of these switches, see the `Submodel Options' section in the `Hardware Models and Configurations' chapter of @cite{Using the GNU Compiler Collection (GCC)}. @node Optimization and Strict Aliasing,Aliased Variables and Optimization,Other Optimization Switches,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id36}@anchor{191}@anchor{gnat_ugn/gnat_and_program_execution optimization-and-strict-aliasing}@anchor{e7} +@anchor{gnat_ugn/gnat_and_program_execution id36}@anchor{192}@anchor{gnat_ugn/gnat_and_program_execution optimization-and-strict-aliasing}@anchor{e7} @subsubsection Optimization and Strict Aliasing @@ -21167,7 +21227,7 @@ review any uses of unchecked conversion, particularly if you are getting the warnings described above. @node Aliased Variables and Optimization,Atomic Variables and Optimization,Optimization and Strict Aliasing,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution aliased-variables-and-optimization}@anchor{192}@anchor{gnat_ugn/gnat_and_program_execution id37}@anchor{193} +@anchor{gnat_ugn/gnat_and_program_execution aliased-variables-and-optimization}@anchor{193}@anchor{gnat_ugn/gnat_and_program_execution id37}@anchor{194} @subsubsection Aliased Variables and Optimization @@ -21227,7 +21287,7 @@ avoid code such as this if possible because it’s not portable and may not functin as you expect with all compilers. @node Atomic Variables and Optimization,Passive Task Optimization,Aliased Variables and Optimization,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution atomic-variables-and-optimization}@anchor{194}@anchor{gnat_ugn/gnat_and_program_execution id38}@anchor{195} +@anchor{gnat_ugn/gnat_and_program_execution atomic-variables-and-optimization}@anchor{195}@anchor{gnat_ugn/gnat_and_program_execution id38}@anchor{196} @subsubsection Atomic Variables and Optimization @@ -21308,7 +21368,7 @@ such synchronization code is not required, you may find it useful to disable it. @node Passive Task Optimization,,Atomic Variables and Optimization,Performance Considerations -@anchor{gnat_ugn/gnat_and_program_execution id39}@anchor{196}@anchor{gnat_ugn/gnat_and_program_execution passive-task-optimization}@anchor{197} +@anchor{gnat_ugn/gnat_and_program_execution id39}@anchor{197}@anchor{gnat_ugn/gnat_and_program_execution passive-task-optimization}@anchor{198} @subsubsection Passive Task Optimization @@ -21353,7 +21413,7 @@ that typically clients of the tasks who call entries will not have to be modified, only the task definitions themselves. @node Text_IO Suggestions,Reducing Size of Executables with Unused Subprogram/Data Elimination,Performance Considerations,Improving Performance -@anchor{gnat_ugn/gnat_and_program_execution id40}@anchor{198}@anchor{gnat_ugn/gnat_and_program_execution text-io-suggestions}@anchor{199} +@anchor{gnat_ugn/gnat_and_program_execution id40}@anchor{199}@anchor{gnat_ugn/gnat_and_program_execution text-io-suggestions}@anchor{19a} @subsection @code{Text_IO} Suggestions @@ -21376,7 +21436,7 @@ of the standard output file or change the standard output file to be buffered using @code{Interfaces.C_Streams.setvbuf}. @node Reducing Size of Executables with Unused Subprogram/Data Elimination,,Text_IO Suggestions,Improving Performance -@anchor{gnat_ugn/gnat_and_program_execution id41}@anchor{19a}@anchor{gnat_ugn/gnat_and_program_execution reducing-size-of-executables-with-unused-subprogram-data-elimination}@anchor{19b} +@anchor{gnat_ugn/gnat_and_program_execution id41}@anchor{19b}@anchor{gnat_ugn/gnat_and_program_execution reducing-size-of-executables-with-unused-subprogram-data-elimination}@anchor{19c} @subsection Reducing Size of Executables with Unused Subprogram/Data Elimination @@ -21393,7 +21453,7 @@ your executable just by setting options at compilation time. @end menu @node About unused subprogram/data elimination,Compilation options,,Reducing Size of Executables with Unused Subprogram/Data Elimination -@anchor{gnat_ugn/gnat_and_program_execution about-unused-subprogram-data-elimination}@anchor{19c}@anchor{gnat_ugn/gnat_and_program_execution id42}@anchor{19d} +@anchor{gnat_ugn/gnat_and_program_execution about-unused-subprogram-data-elimination}@anchor{19d}@anchor{gnat_ugn/gnat_and_program_execution id42}@anchor{19e} @subsubsection About unused subprogram/data elimination @@ -21407,7 +21467,7 @@ architecture and on all cross platforms using the ELF binary file format. In both cases, GNU binutils version 2.16 or later are required to enable it. @node Compilation options,Example of unused subprogram/data elimination,About unused subprogram/data elimination,Reducing Size of Executables with Unused Subprogram/Data Elimination -@anchor{gnat_ugn/gnat_and_program_execution compilation-options}@anchor{19e}@anchor{gnat_ugn/gnat_and_program_execution id43}@anchor{19f} +@anchor{gnat_ugn/gnat_and_program_execution compilation-options}@anchor{19f}@anchor{gnat_ugn/gnat_and_program_execution id43}@anchor{1a0} @subsubsection Compilation options @@ -21448,7 +21508,7 @@ eliminate the unused code and data of the GNAT library from your executable. @node Example of unused subprogram/data elimination,,Compilation options,Reducing Size of Executables with Unused Subprogram/Data Elimination -@anchor{gnat_ugn/gnat_and_program_execution example-of-unused-subprogram-data-elimination}@anchor{1a0}@anchor{gnat_ugn/gnat_and_program_execution id44}@anchor{1a1} +@anchor{gnat_ugn/gnat_and_program_execution example-of-unused-subprogram-data-elimination}@anchor{1a1}@anchor{gnat_ugn/gnat_and_program_execution id44}@anchor{1a2} @subsubsection Example of unused subprogram/data elimination @@ -21518,7 +21578,7 @@ appropriate switches. @geindex Checks (overflow) @node Overflow Check Handling in GNAT,Performing Dimensionality Analysis in GNAT,Improving Performance,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id45}@anchor{14e}@anchor{gnat_ugn/gnat_and_program_execution overflow-check-handling-in-gnat}@anchor{1a2} +@anchor{gnat_ugn/gnat_and_program_execution id45}@anchor{14e}@anchor{gnat_ugn/gnat_and_program_execution overflow-check-handling-in-gnat}@anchor{1a3} @section Overflow Check Handling in GNAT @@ -21534,7 +21594,7 @@ This section explains how to control the handling of overflow checks. @end menu @node Background,Management of Overflows in GNAT,,Overflow Check Handling in GNAT -@anchor{gnat_ugn/gnat_and_program_execution background}@anchor{1a3}@anchor{gnat_ugn/gnat_and_program_execution id46}@anchor{1a4} +@anchor{gnat_ugn/gnat_and_program_execution background}@anchor{1a4}@anchor{gnat_ugn/gnat_and_program_execution id46}@anchor{1a5} @subsection Background @@ -21660,7 +21720,7 @@ exception raised because of the intermediate overflow (and we really would prefer this precondition to be considered @code{True} at run time). @node Management of Overflows in GNAT,Specifying the Desired Mode,Background,Overflow Check Handling in GNAT -@anchor{gnat_ugn/gnat_and_program_execution id47}@anchor{1a5}@anchor{gnat_ugn/gnat_and_program_execution management-of-overflows-in-gnat}@anchor{1a6} +@anchor{gnat_ugn/gnat_and_program_execution id47}@anchor{1a6}@anchor{gnat_ugn/gnat_and_program_execution management-of-overflows-in-gnat}@anchor{1a7} @subsection Management of Overflows in GNAT @@ -21774,7 +21834,7 @@ out in the normal manner (with infinite values always failing all range checks). @node Specifying the Desired Mode,Default Settings,Management of Overflows in GNAT,Overflow Check Handling in GNAT -@anchor{gnat_ugn/gnat_and_program_execution id48}@anchor{1a7}@anchor{gnat_ugn/gnat_and_program_execution specifying-the-desired-mode}@anchor{ec} +@anchor{gnat_ugn/gnat_and_program_execution id48}@anchor{1a8}@anchor{gnat_ugn/gnat_and_program_execution specifying-the-desired-mode}@anchor{ec} @subsection Specifying the Desired Mode @@ -21898,7 +21958,7 @@ equivalent to @code{-gnato11}, causing all intermediate operations to be computed using the base type (@code{STRICT} mode). @node Default Settings,Implementation Notes,Specifying the Desired Mode,Overflow Check Handling in GNAT -@anchor{gnat_ugn/gnat_and_program_execution default-settings}@anchor{1a8}@anchor{gnat_ugn/gnat_and_program_execution id49}@anchor{1a9} +@anchor{gnat_ugn/gnat_and_program_execution default-settings}@anchor{1a9}@anchor{gnat_ugn/gnat_and_program_execution id49}@anchor{1aa} @subsection Default Settings @@ -21922,7 +21982,7 @@ checking but has no effect on the method used for computing intermediate results. @node Implementation Notes,,Default Settings,Overflow Check Handling in GNAT -@anchor{gnat_ugn/gnat_and_program_execution id50}@anchor{1aa}@anchor{gnat_ugn/gnat_and_program_execution implementation-notes}@anchor{1ab} +@anchor{gnat_ugn/gnat_and_program_execution id50}@anchor{1ab}@anchor{gnat_ugn/gnat_and_program_execution implementation-notes}@anchor{1ac} @subsection Implementation Notes @@ -21970,7 +22030,7 @@ platforms for which @code{Long_Long_Integer} is at least 64-bits (nearly all GNA platforms). @node Performing Dimensionality Analysis in GNAT,Stack Related Facilities,Overflow Check Handling in GNAT,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id51}@anchor{14f}@anchor{gnat_ugn/gnat_and_program_execution performing-dimensionality-analysis-in-gnat}@anchor{1ac} +@anchor{gnat_ugn/gnat_and_program_execution id51}@anchor{14f}@anchor{gnat_ugn/gnat_and_program_execution performing-dimensionality-analysis-in-gnat}@anchor{1ad} @section Performing Dimensionality Analysis in GNAT @@ -22373,7 +22433,7 @@ package Mks_Numerics is new @end quotation @node Stack Related Facilities,Memory Management Issues,Performing Dimensionality Analysis in GNAT,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id52}@anchor{150}@anchor{gnat_ugn/gnat_and_program_execution stack-related-facilities}@anchor{1ad} +@anchor{gnat_ugn/gnat_and_program_execution id52}@anchor{150}@anchor{gnat_ugn/gnat_and_program_execution stack-related-facilities}@anchor{1ae} @section Stack Related Facilities @@ -22389,7 +22449,7 @@ particular, it deals with dynamic and static stack usage measurements. @end menu @node Stack Overflow Checking,Static Stack Usage Analysis,,Stack Related Facilities -@anchor{gnat_ugn/gnat_and_program_execution id53}@anchor{1ae}@anchor{gnat_ugn/gnat_and_program_execution stack-overflow-checking}@anchor{e8} +@anchor{gnat_ugn/gnat_and_program_execution id53}@anchor{1af}@anchor{gnat_ugn/gnat_and_program_execution stack-overflow-checking}@anchor{e8} @subsection Stack Overflow Checking @@ -22437,7 +22497,7 @@ When using the LLVM back end, this switch doesn’t perform full stack overflow checking, but just checks for very large local dynamic allocations. @node Static Stack Usage Analysis,Dynamic Stack Usage Analysis,Stack Overflow Checking,Stack Related Facilities -@anchor{gnat_ugn/gnat_and_program_execution id54}@anchor{1af}@anchor{gnat_ugn/gnat_and_program_execution static-stack-usage-analysis}@anchor{e9} +@anchor{gnat_ugn/gnat_and_program_execution id54}@anchor{1b0}@anchor{gnat_ugn/gnat_and_program_execution static-stack-usage-analysis}@anchor{e9} @subsection Static Stack Usage Analysis @@ -22489,7 +22549,7 @@ consistent with that in the file documented above. This is not supported by the LLVM back end. @node Dynamic Stack Usage Analysis,,Static Stack Usage Analysis,Stack Related Facilities -@anchor{gnat_ugn/gnat_and_program_execution dynamic-stack-usage-analysis}@anchor{117}@anchor{gnat_ugn/gnat_and_program_execution id55}@anchor{1b0} +@anchor{gnat_ugn/gnat_and_program_execution dynamic-stack-usage-analysis}@anchor{117}@anchor{gnat_ugn/gnat_and_program_execution id55}@anchor{1b1} @subsection Dynamic Stack Usage Analysis @@ -22573,8 +22633,8 @@ This is not suppored by the LLVM back end. The package @code{GNAT.Task_Stack_Usage} provides facilities to get stack-usage reports at run time. See its body for the details. -@node Memory Management Issues,,Stack Related Facilities,GNAT and Program Execution -@anchor{gnat_ugn/gnat_and_program_execution id56}@anchor{151}@anchor{gnat_ugn/gnat_and_program_execution memory-management-issues}@anchor{1b1} +@node Memory Management Issues,Sanitizers for Ada,Stack Related Facilities,GNAT and Program Execution +@anchor{gnat_ugn/gnat_and_program_execution id56}@anchor{151}@anchor{gnat_ugn/gnat_and_program_execution memory-management-issues}@anchor{1b2} @section Memory Management Issues @@ -22590,7 +22650,7 @@ incorrect uses of access values (including ‘dangling references’). @end menu @node Some Useful Memory Pools,The GNAT Debug Pool Facility,,Memory Management Issues -@anchor{gnat_ugn/gnat_and_program_execution id57}@anchor{1b2}@anchor{gnat_ugn/gnat_and_program_execution some-useful-memory-pools}@anchor{1b3} +@anchor{gnat_ugn/gnat_and_program_execution id57}@anchor{1b3}@anchor{gnat_ugn/gnat_and_program_execution some-useful-memory-pools}@anchor{1b4} @subsection Some Useful Memory Pools @@ -22672,7 +22732,7 @@ for T1'Storage_Size use 10_000; @end quotation @node The GNAT Debug Pool Facility,,Some Useful Memory Pools,Memory Management Issues -@anchor{gnat_ugn/gnat_and_program_execution id58}@anchor{1b4}@anchor{gnat_ugn/gnat_and_program_execution the-gnat-debug-pool-facility}@anchor{1b5} +@anchor{gnat_ugn/gnat_and_program_execution id58}@anchor{1b5}@anchor{gnat_ugn/gnat_and_program_execution the-gnat-debug-pool-facility}@anchor{1b6} @subsection The GNAT Debug Pool Facility @@ -22831,11 +22891,415 @@ Debug Pool info: @end quotation +@node Sanitizers for Ada,,Memory Management Issues,GNAT and Program Execution +@anchor{gnat_ugn/gnat_and_program_execution id63}@anchor{152}@anchor{gnat_ugn/gnat_and_program_execution sanitizers-for-ada}@anchor{1b7} +@section Sanitizers for Ada + + +@geindex Sanitizers + +This section explains how to use sanitizers with Ada code. Sanitizers offer code +instrumentation and run-time libraries that detect certain memory issues and +undefined behaviors during execution. They provide dynamic analysis capabilities +useful for debugging and testing. + +While many sanitizer capabilities overlap with Ada’s built-in runtime checks, +they are particularly valuable for identifying issues that arise from unchecked +features or low-level operations. + +@menu +* AddressSanitizer:: +* UndefinedBehaviorSanitizer:: +* Sanitizers in mixed-language applications:: + +@end menu + +@node AddressSanitizer,UndefinedBehaviorSanitizer,,Sanitizers for Ada +@anchor{gnat_ugn/gnat_and_program_execution addresssanitizer}@anchor{1b8}@anchor{gnat_ugn/gnat_and_program_execution id64}@anchor{1b9} +@subsection AddressSanitizer + + +@geindex AddressSanitizer + +@geindex ASan + +@geindex -fsanitize=address + +AddressSanitizer (aka ASan) is a memory error detector activated with the +@code{-fsanitize=address} switch. Note that many of the typical memory errors, +such as use after free or buffer overflow, are detected by Ada’s @code{Access_Check} +and @code{Index_Check}. + +It can detect the following types of problems: + + +@itemize * + +@item +Wrong memory overlay + +A memory overlay is a situation in which an object of one type is placed at the +same memory location as a distinct object of a different type, thus overlaying +one object over the other in memory. When there is an overflow because the +objects do not overlap (like in the following example), the sanitizer can signal +it. + +@quotation + +@example +procedure Wrong_Size_Overlay is + type Block is array (Natural range <>) of Integer; + + Block4 : aliased Block := (1 .. 4 => 4); + Block5 : Block (1 .. 5) with Address => Block4'Address; +begin + Block5 (Block5'Last) := 5; -- Outside the object +end Wrong_Size_Overlay; +@end example +@end quotation + +If the code is built with the @code{-fsanitize=address} and @code{-g} options, +the following error is shown at execution time: + +@quotation + +@example +... +SUMMARY: AddressSanitizer: stack-buffer-overflow wrong_size_overlay.adb:7 in _ada_wrong_size_overlay +... +@end example +@end quotation + +@item +Buffer overflow + +Ada’s @code{Index_Check} detects buffer overflows caused by out-of-bounds array +access. If run-time checks are disabled, the sanitizer can still detect such +overflows at execution time the same way as it signalled the previous wrong +memory overlay. Note that if both the Ada run-time checks and the sanitizer +are enabled, the Ada run-time exception takes precedence. + +@quotation + +@example +procedure Buffer_Overrun is + Size : constant := 100; + Buffer : array (1 .. Size) of Integer := (others => 0); + Wrong_Index : Integer := Size + 1 with Export; +begin + -- Access outside the boundaries + Put_Line ("Value: " & Integer'Image (Buffer (Wrong_Index))); +end Buffer_Overrun; +@end example +@end quotation + +@item +Use after lifetime + +Ada’s @code{Accessibility_Check} helps prevent use-after-return and +use-after-scope errors by enforcing lifetime rules. When these checks are +bypassed using @code{Unchecked_Access}, sanitizers can still detect such +violations during execution. + +@quotation + +@example +with Ada.Text_IO; use Ada.Text_IO; + +procedure Use_After_Return is + type Integer_Access is access all Integer; + Ptr : Integer_Access; + + procedure Inner; + + procedure Inner is + Local : aliased Integer := 42; + begin + Ptr := Local'Unchecked_Access; + end Inner; + +begin + Inner; + -- Accessing Local after it has gone out of scope + Put_Line ("Value: " & Integer'Image (Ptr.all)); +end Use_After_Return; +@end example +@end quotation + +If the code is built with the @code{-fsanitize=address} and @code{-g} +options, the following error is shown at execution time: + +@quotation + +@example +... +==1793927==ERROR: AddressSanitizer: stack-use-after-return on address 0xf6fa1a409060 at pc 0xb20b6cb6cac0 bp 0xffffcc89c8b0 sp 0xffffcc89c8c8 +READ of size 4 at 0xf6fa1a409060 thread T0 + #0 0xb20b6cb6cabc in _ada_use_after_return use_after_return.adb:18 + ... + +Address 0xf6fa1a409060 is located in stack of thread T0 at offset 32 in frame + #0 0xb20b6cb6c794 in use_after_return__inner use_after_return.adb:9 + + This frame has 1 object(s): + [32, 36) 'local' (line 10) <== Memory access at offset 32 is inside this variable +SUMMARY: AddressSanitizer: stack-use-after-return use_after_return.adb:18 in _ada_use_after_return +... +@end example +@end quotation + +@item +Memory leak + +A memory leak happens when a program allocates memory from the heap but fails +to release it after it is no longer needed and loses all references to it like +in the following example. + +@quotation + +@example +procedure Memory_Leak is + type Integer_Access is access Integer; + + procedure Allocate is + Ptr : Integer_Access := new Integer'(42); + begin + null; + end Allocate; +begin + -- Memory leak occurs in the following procedure + Allocate; +end Memory_Leak; +@end example +@end quotation + +If the code is built with the @code{-fsanitize=address} and @code{-g} +options, the following error is emitted at execution time showing the +location of the offending allocation. + +@quotation + +@example +==1810634==ERROR: LeakSanitizer: detected memory leaks + +Direct leak of 4 byte(s) in 1 object(s) allocated from: + #0 0xe3cbee4bb4a8 in __interceptor_malloc asan_malloc_linux.cpp:69 + #1 0xc15bb25d0af8 in __gnat_malloc (memory_leak+0x10af8) (BuildId: f5914a6eac10824f81d512de50b514e7d5f733be) + #2 0xc15bb25c9060 in memory_leak__allocate memory_leak.adb:5 + ... + +SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s). +@end example +@end quotation +@end itemize + +@node UndefinedBehaviorSanitizer,Sanitizers in mixed-language applications,AddressSanitizer,Sanitizers for Ada +@anchor{gnat_ugn/gnat_and_program_execution id65}@anchor{1ba}@anchor{gnat_ugn/gnat_and_program_execution undefinedbehaviorsanitizer}@anchor{1bb} +@subsection UndefinedBehaviorSanitizer + + +@geindex UndefinedBehaviorSanitizer + +@geindex UBSan + +@geindex -fsanitize=undefined + +UndefinedBehaviorSanitizer (aka UBSan) modifies the program at compile-time to +catch various kinds of undefined behavior during program execution. + +Different sanitize options (@code{-fsanitize=alignment,float-cast-overflow,signed-integer-overflow}) +detect the following types of problems: + + +@itemize * + +@item +Wrong alignment + +The @code{-fsanitize=alignment} flag (included also in +@code{-fsanitize=undefined}) enables run-time checks for misaligned memory +accesses, ensuring that objects are accessed at addresses that conform to the +alignment constraints of their declared types. Violations may lead to crashes +or performance penalties on certain architectures. + +In the following example: + +@quotation + +@example +with Ada.Text_IO; use Ada.Text_IO; +with System.Storage_Elements; use System.Storage_Elements; + +procedure Misaligned_Address is + type Aligned_Integer is new Integer with + Alignment => 4; -- Ensure 4-byte alignment + + Reference : Aligned_Integer := 42; -- Properly aligned object + + -- Create a misaligned object by modifying the address manually + Misaligned : Aligned_Integer with Address => Reference'Address + 1; + +begin + -- This causes undefined behavior or an alignment exception on strict architectures + Put_Line ("Misaligned Value: " & Aligned_Integer'Image (Misaligned)); +end Misaligned_Address; +@end example +@end quotation + +If the code is built with the @code{-fsanitize=alignment} and @code{-g} +options, the following error is shown at execution time. + +@quotation + +@example +misaligned_address.adb:15:51: runtime error: load of misaligned address 0xffffd836dd45 for type 'volatile misaligned_address__aligned_integer', which requires 4 byte alignment +@end example +@end quotation + +@item +Signed integer overflow + +Ada performs range checks at runtime in arithmetic operation on signed integers +to ensure the value is within the target type’s bounds. If this check is removed, +the @code{-fsanitize=signed-integer-overflow} flag (included also in +@code{-fsanitize=undefined}) enables run-time checks for signed integer +overflows. + +In the following example: + +@quotation + +@example +procedure Signed_Integer_Overflow is + type Small_Int is range -128 .. 127; + X, Y, Z : Small_Int with Export; +begin + X := 100; + Y := 50; + -- This addition will exceed 127, causing an overflow + Z := X + Y; +end Signed_Integer_Overflow; +@end example +@end quotation + +If the code is built with the @code{-fsanitize=signed-integer-overflow} and +@code{-g} options, the following error is shown at execution time. + +@quotation + +@example +signed_integer_overflow.adb:8:11: runtime error: signed integer overflow: 100 + 50 cannot be represented in type 'signed_integer_overflow__small_int' +@end example +@end quotation + +@item +Float to integer overflow + +When converting a floating-point value to an integer type, Ada performs a range +check at runtime to ensure the value is within the target type’s bounds. If this +check is removed, the sanitizer can detect overflows in conversions from +floating point to integer types. + +In the following code: + +@quotation + +@example +procedure Float_Cast_Overflow is + Flt : Float := Float'Last with Export; + Int : Integer; +begin + Int := Integer (Flt); -- Overflow +end Float_Cast_Overflow; +@end example +@end quotation + +If the code is built with the @code{-fsanitize=float-cast-overflow} and +@code{-g} options, the following error is shown at execution time. + +@quotation + +@example +float_cast_overflow.adb:5:20: runtime error: 3.40282e+38 is outside the range of representable values of type 'integer' +@end example +@end quotation +@end itemize + +@node Sanitizers in mixed-language applications,,UndefinedBehaviorSanitizer,Sanitizers for Ada +@anchor{gnat_ugn/gnat_and_program_execution sanitizers-in-mixed-language-applications}@anchor{1bc} +@subsection Sanitizers in mixed-language applications + + +Most of the checks performed by sanitizers operate at a global level, which +means they can detect issues even when they span across language boundaries. +This applies notably to: + + +@itemize * + +@item +All checks performed by the AddressSanitizer: wrong memory overlays, buffer +overflows, uses after lifetime, memory leaks. These checks apply globally, +regardless of where the objects are allocated or defined, or where they are +destroyed + +@item +Wrong alignment checks performed by the UndefinedBehaviorSanitizer. It will +check whether an object created in a given language is accessed in another +with an incompatible alignment +@end itemize + +An interesting case that highlights the benefit of global sanitization is a +buffer overflow caused by a mismatch in language bindings. Consider the +following C function, which allocates an array of 4 characters: + +@quotation + +@example +char *get_str (void) @{ + char *str = malloc (4 * sizeof (char)); +@} +@end example +@end quotation + +This function is then bound to Ada code, which incorrectly assumes the buffer +is of size 5: + +@quotation + +@example +type Buffer is array (1 .. 5) of Character; + +function Get_Str return access Buffer + with Import => True, Convention => C, External_Name => "get_str"; + +Str : access Buffer := Get_Str; +Ch : Character := S (S'Last); -- Detected by AddressSanitizer as erroneous +@end example +@end quotation + +On the Ada side, accessing @code{Str (5)} appears valid because the array type +declares five elements. However, the actual memory allocated in C only holds +four. This mismatch is not detectable by Ada run-time checks, because Ada has +no visibility into how the memory was allocated. + +However, the AddressSanitizer will detect the heap buffer overflow at runtime, +halting execution and providing a clear diagnostic: + +@quotation + +@example +... +SUMMARY: AddressSanitizer: heap-buffer-overflow buffer_overflow.adb:20 in _ada_buffer_overflow +... +@end example +@end quotation + @c -- Non-breaking space in running text @c -- E.g. Ada |nbsp| 95 @node Platform-Specific Information,Example of Binder Output File,GNAT and Program Execution,Top -@anchor{gnat_ugn/platform_specific_information doc}@anchor{1b6}@anchor{gnat_ugn/platform_specific_information id1}@anchor{1b7}@anchor{gnat_ugn/platform_specific_information platform-specific-information}@anchor{e} +@anchor{gnat_ugn/platform_specific_information doc}@anchor{1bd}@anchor{gnat_ugn/platform_specific_information id1}@anchor{1be}@anchor{gnat_ugn/platform_specific_information platform-specific-information}@anchor{e} @chapter Platform-Specific Information @@ -22853,7 +23317,7 @@ related to the GNAT implementation on specific Operating Systems. @end menu @node Run-Time Libraries,Specifying a Run-Time Library,,Platform-Specific Information -@anchor{gnat_ugn/platform_specific_information id2}@anchor{1b8}@anchor{gnat_ugn/platform_specific_information run-time-libraries}@anchor{1b9} +@anchor{gnat_ugn/platform_specific_information id2}@anchor{1bf}@anchor{gnat_ugn/platform_specific_information run-time-libraries}@anchor{1c0} @section Run-Time Libraries @@ -22914,7 +23378,7 @@ are supplied on various GNAT platforms. @end menu @node Summary of Run-Time Configurations,,,Run-Time Libraries -@anchor{gnat_ugn/platform_specific_information id3}@anchor{1ba}@anchor{gnat_ugn/platform_specific_information summary-of-run-time-configurations}@anchor{1bb} +@anchor{gnat_ugn/platform_specific_information id3}@anchor{1c1}@anchor{gnat_ugn/platform_specific_information summary-of-run-time-configurations}@anchor{1c2} @subsection Summary of Run-Time Configurations @@ -23014,7 +23478,7 @@ ZCX @node Specifying a Run-Time Library,GNU/Linux Topics,Run-Time Libraries,Platform-Specific Information -@anchor{gnat_ugn/platform_specific_information id4}@anchor{1bc}@anchor{gnat_ugn/platform_specific_information specifying-a-run-time-library}@anchor{1bd} +@anchor{gnat_ugn/platform_specific_information id4}@anchor{1c3}@anchor{gnat_ugn/platform_specific_information specifying-a-run-time-library}@anchor{1c4} @section Specifying a Run-Time Library @@ -23107,7 +23571,7 @@ by using the @code{--RTS} switch, e.g., @code{--RTS=sjlj} @geindex GNU/Linux @node GNU/Linux Topics,Microsoft Windows Topics,Specifying a Run-Time Library,Platform-Specific Information -@anchor{gnat_ugn/platform_specific_information gnu-linux-topics}@anchor{1be}@anchor{gnat_ugn/platform_specific_information id5}@anchor{1bf} +@anchor{gnat_ugn/platform_specific_information gnu-linux-topics}@anchor{1c5}@anchor{gnat_ugn/platform_specific_information id5}@anchor{1c6} @section GNU/Linux Topics @@ -23122,7 +23586,7 @@ This section describes topics that are specific to GNU/Linux platforms. @end menu @node Required Packages on GNU/Linux,Position Independent Executable PIE Enabled by Default on Linux,,GNU/Linux Topics -@anchor{gnat_ugn/platform_specific_information id6}@anchor{1c0}@anchor{gnat_ugn/platform_specific_information required-packages-on-gnu-linux}@anchor{1c1} +@anchor{gnat_ugn/platform_specific_information id6}@anchor{1c7}@anchor{gnat_ugn/platform_specific_information required-packages-on-gnu-linux}@anchor{1c8} @subsection Required Packages on GNU/Linux @@ -23159,7 +23623,7 @@ Other GNU/Linux distributions might choose different name for those packages. @node Position Independent Executable PIE Enabled by Default on Linux,Choosing the Scheduling Policy with GNU/Linux,Required Packages on GNU/Linux,GNU/Linux Topics -@anchor{gnat_ugn/platform_specific_information pie-enabled-by-default-on-linux}@anchor{1c2}@anchor{gnat_ugn/platform_specific_information position-independent-executable-pie-enabled-by-default-on-linux}@anchor{1c3} +@anchor{gnat_ugn/platform_specific_information pie-enabled-by-default-on-linux}@anchor{1c9}@anchor{gnat_ugn/platform_specific_information position-independent-executable-pie-enabled-by-default-on-linux}@anchor{1ca} @subsection Position Independent Executable (PIE) Enabled by Default on Linux @@ -23207,9 +23671,9 @@ and linked with @code{-pie}). @geindex SCHED_RR scheduling policy @geindex SCHED_OTHER scheduling policy -@anchor{gnat_ugn/platform_specific_information choosing-the-scheduling-policy-with-gnu-linux}@anchor{1c4} +@anchor{gnat_ugn/platform_specific_information choosing-the-scheduling-policy-with-gnu-linux}@anchor{1cb} @node Choosing the Scheduling Policy with GNU/Linux,A GNU/Linux Debug Quirk,Position Independent Executable PIE Enabled by Default on Linux,GNU/Linux Topics -@anchor{gnat_ugn/platform_specific_information id7}@anchor{1c5} +@anchor{gnat_ugn/platform_specific_information id7}@anchor{1cc} @subsection Choosing the Scheduling Policy with GNU/Linux @@ -23267,7 +23731,7 @@ but not on the host machine running the container, so check that you also have sufficient priviledge for running the container image. @node A GNU/Linux Debug Quirk,,Choosing the Scheduling Policy with GNU/Linux,GNU/Linux Topics -@anchor{gnat_ugn/platform_specific_information a-gnu-linux-debug-quirk}@anchor{1c6}@anchor{gnat_ugn/platform_specific_information id8}@anchor{1c7} +@anchor{gnat_ugn/platform_specific_information a-gnu-linux-debug-quirk}@anchor{1cd}@anchor{gnat_ugn/platform_specific_information id8}@anchor{1ce} @subsection A GNU/Linux Debug Quirk @@ -23287,7 +23751,7 @@ the symptoms most commonly observed. @geindex Windows @node Microsoft Windows Topics,Mac OS Topics,GNU/Linux Topics,Platform-Specific Information -@anchor{gnat_ugn/platform_specific_information id9}@anchor{1c8}@anchor{gnat_ugn/platform_specific_information microsoft-windows-topics}@anchor{1c9} +@anchor{gnat_ugn/platform_specific_information id9}@anchor{1cf}@anchor{gnat_ugn/platform_specific_information microsoft-windows-topics}@anchor{1d0} @section Microsoft Windows Topics @@ -23309,7 +23773,7 @@ platforms. @end menu @node Using GNAT on Windows,Using a network installation of GNAT,,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information id10}@anchor{1ca}@anchor{gnat_ugn/platform_specific_information using-gnat-on-windows}@anchor{1cb} +@anchor{gnat_ugn/platform_specific_information id10}@anchor{1d1}@anchor{gnat_ugn/platform_specific_information using-gnat-on-windows}@anchor{1d2} @subsection Using GNAT on Windows @@ -23388,7 +23852,7 @@ different GNAT products. @end itemize @node Using a network installation of GNAT,CONSOLE and WINDOWS subsystems,Using GNAT on Windows,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information id11}@anchor{1cc}@anchor{gnat_ugn/platform_specific_information using-a-network-installation-of-gnat}@anchor{1cd} +@anchor{gnat_ugn/platform_specific_information id11}@anchor{1d3}@anchor{gnat_ugn/platform_specific_information using-a-network-installation-of-gnat}@anchor{1d4} @subsection Using a network installation of GNAT @@ -23415,7 +23879,7 @@ transfer of large amounts of data across the network and will likely cause a serious performance penalty. @node CONSOLE and WINDOWS subsystems,Temporary Files,Using a network installation of GNAT,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information console-and-windows-subsystems}@anchor{1ce}@anchor{gnat_ugn/platform_specific_information id12}@anchor{1cf} +@anchor{gnat_ugn/platform_specific_information console-and-windows-subsystems}@anchor{1d5}@anchor{gnat_ugn/platform_specific_information id12}@anchor{1d6} @subsection CONSOLE and WINDOWS subsystems @@ -23440,7 +23904,7 @@ $ gnatmake winprog -largs -mwindows @end quotation @node Temporary Files,Disabling Command Line Argument Expansion,CONSOLE and WINDOWS subsystems,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information id13}@anchor{1d0}@anchor{gnat_ugn/platform_specific_information temporary-files}@anchor{1d1} +@anchor{gnat_ugn/platform_specific_information id13}@anchor{1d7}@anchor{gnat_ugn/platform_specific_information temporary-files}@anchor{1d8} @subsection Temporary Files @@ -23478,7 +23942,7 @@ environments where you may not have write access to some directories. @node Disabling Command Line Argument Expansion,Choosing the Scheduling Policy with Windows,Temporary Files,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information disabling-command-line-argument-expansion}@anchor{1d2} +@anchor{gnat_ugn/platform_specific_information disabling-command-line-argument-expansion}@anchor{1d9} @subsection Disabling Command Line Argument Expansion @@ -23549,7 +24013,7 @@ Ada.Command_Line.Argument (1) -> "'*.txt'" @end example @node Choosing the Scheduling Policy with Windows,Windows Socket Timeouts,Disabling Command Line Argument Expansion,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information choosing-the-scheduling-policy-with-windows}@anchor{1d3}@anchor{gnat_ugn/platform_specific_information id14}@anchor{1d4} +@anchor{gnat_ugn/platform_specific_information choosing-the-scheduling-policy-with-windows}@anchor{1da}@anchor{gnat_ugn/platform_specific_information id14}@anchor{1db} @subsection Choosing the Scheduling Policy with Windows @@ -23567,7 +24031,7 @@ in @code{system.ads}. For more information about Windows priorities, please refer to Microsoft documentation. @node Windows Socket Timeouts,Mixed-Language Programming on Windows,Choosing the Scheduling Policy with Windows,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information windows-socket-timeouts}@anchor{1d5} +@anchor{gnat_ugn/platform_specific_information windows-socket-timeouts}@anchor{1dc} @subsection Windows Socket Timeouts @@ -23615,7 +24079,7 @@ socket timeout shorter than 500 ms. If a socket timeout shorter than operations. @node Mixed-Language Programming on Windows,Windows Specific Add-Ons,Windows Socket Timeouts,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information id15}@anchor{1d6}@anchor{gnat_ugn/platform_specific_information mixed-language-programming-on-windows}@anchor{1d7} +@anchor{gnat_ugn/platform_specific_information id15}@anchor{1dd}@anchor{gnat_ugn/platform_specific_information mixed-language-programming-on-windows}@anchor{1de} @subsection Mixed-Language Programming on Windows @@ -23637,12 +24101,12 @@ to use the Microsoft tools for your C++ code, you have two choices: You can encapsulate your C++ code in a DLL to be linked with your Ada application. In this case, use the Microsoft or other environment to build the DLL and use GNAT to build your executable -(@ref{1d8,,Using DLLs with GNAT}). +(@ref{1df,,Using DLLs with GNAT}). @item You can encapsulate your Ada code in a DLL to be linked with the other part of your application. In this case, use GNAT to build the DLL -(@ref{1d9,,Building DLLs with GNAT Project files}) and use the Microsoft +(@ref{1e0,,Building DLLs with GNAT Project files}) and use the Microsoft or other environment to build your executable. @end itemize @@ -23699,7 +24163,7 @@ native SEH support is used. @end menu @node Windows Calling Conventions,Introduction to Dynamic Link Libraries DLLs,,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information id16}@anchor{1da}@anchor{gnat_ugn/platform_specific_information windows-calling-conventions}@anchor{1db} +@anchor{gnat_ugn/platform_specific_information id16}@anchor{1e1}@anchor{gnat_ugn/platform_specific_information windows-calling-conventions}@anchor{1e2} @subsubsection Windows Calling Conventions @@ -23744,7 +24208,7 @@ are available for Windows: @end menu @node C Calling Convention,Stdcall Calling Convention,,Windows Calling Conventions -@anchor{gnat_ugn/platform_specific_information c-calling-convention}@anchor{1dc}@anchor{gnat_ugn/platform_specific_information id17}@anchor{1dd} +@anchor{gnat_ugn/platform_specific_information c-calling-convention}@anchor{1e3}@anchor{gnat_ugn/platform_specific_information id17}@anchor{1e4} @subsubsection @code{C} Calling Convention @@ -23786,10 +24250,10 @@ the @code{External_Name} with a leading underscore. When importing a variable defined in C, you should always use the @code{C} calling convention unless the object containing the variable is part of a DLL (in which case you should use the @code{Stdcall} calling -convention, @ref{1de,,Stdcall Calling Convention}). +convention, @ref{1e5,,Stdcall Calling Convention}). @node Stdcall Calling Convention,Win32 Calling Convention,C Calling Convention,Windows Calling Conventions -@anchor{gnat_ugn/platform_specific_information id18}@anchor{1df}@anchor{gnat_ugn/platform_specific_information stdcall-calling-convention}@anchor{1de} +@anchor{gnat_ugn/platform_specific_information id18}@anchor{1e6}@anchor{gnat_ugn/platform_specific_information stdcall-calling-convention}@anchor{1e5} @subsubsection @code{Stdcall} Calling Convention @@ -23887,7 +24351,7 @@ Note that to ease building cross-platform bindings, this convention will be handled as a @code{C} calling convention on non-Windows platforms. @node Win32 Calling Convention,DLL Calling Convention,Stdcall Calling Convention,Windows Calling Conventions -@anchor{gnat_ugn/platform_specific_information id19}@anchor{1e0}@anchor{gnat_ugn/platform_specific_information win32-calling-convention}@anchor{1e1} +@anchor{gnat_ugn/platform_specific_information id19}@anchor{1e7}@anchor{gnat_ugn/platform_specific_information win32-calling-convention}@anchor{1e8} @subsubsection @code{Win32} Calling Convention @@ -23895,7 +24359,7 @@ This convention, which is GNAT-specific, is fully equivalent to the @code{Stdcall} calling convention described above. @node DLL Calling Convention,,Win32 Calling Convention,Windows Calling Conventions -@anchor{gnat_ugn/platform_specific_information dll-calling-convention}@anchor{1e2}@anchor{gnat_ugn/platform_specific_information id20}@anchor{1e3} +@anchor{gnat_ugn/platform_specific_information dll-calling-convention}@anchor{1e9}@anchor{gnat_ugn/platform_specific_information id20}@anchor{1ea} @subsubsection @code{DLL} Calling Convention @@ -23903,7 +24367,7 @@ This convention, which is GNAT-specific, is fully equivalent to the @code{Stdcall} calling convention described above. @node Introduction to Dynamic Link Libraries DLLs,Using DLLs with GNAT,Windows Calling Conventions,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information id21}@anchor{1e4}@anchor{gnat_ugn/platform_specific_information introduction-to-dynamic-link-libraries-dlls}@anchor{1e5} +@anchor{gnat_ugn/platform_specific_information id21}@anchor{1eb}@anchor{gnat_ugn/platform_specific_information introduction-to-dynamic-link-libraries-dlls}@anchor{1ec} @subsubsection Introduction to Dynamic Link Libraries (DLLs) @@ -23987,10 +24451,10 @@ As a side note, an interesting difference between Microsoft DLLs and Unix shared libraries is the fact that on most Unix systems all public routines are exported by default in a Unix shared library, while under Windows it is possible (but not required) to list exported routines in -a definition file (see @ref{1e6,,The Definition File}). +a definition file (see @ref{1ed,,The Definition File}). @node Using DLLs with GNAT,Building DLLs with GNAT Project files,Introduction to Dynamic Link Libraries DLLs,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information id22}@anchor{1e7}@anchor{gnat_ugn/platform_specific_information using-dlls-with-gnat}@anchor{1d8} +@anchor{gnat_ugn/platform_specific_information id22}@anchor{1ee}@anchor{gnat_ugn/platform_specific_information using-dlls-with-gnat}@anchor{1df} @subsubsection Using DLLs with GNAT @@ -24081,7 +24545,7 @@ example a fictitious DLL called @code{API.dll}. @end menu @node Creating an Ada Spec for the DLL Services,Creating an Import Library,,Using DLLs with GNAT -@anchor{gnat_ugn/platform_specific_information creating-an-ada-spec-for-the-dll-services}@anchor{1e8}@anchor{gnat_ugn/platform_specific_information id23}@anchor{1e9} +@anchor{gnat_ugn/platform_specific_information creating-an-ada-spec-for-the-dll-services}@anchor{1ef}@anchor{gnat_ugn/platform_specific_information id23}@anchor{1f0} @subsubsection Creating an Ada Spec for the DLL Services @@ -24121,7 +24585,7 @@ end API; @end quotation @node Creating an Import Library,,Creating an Ada Spec for the DLL Services,Using DLLs with GNAT -@anchor{gnat_ugn/platform_specific_information creating-an-import-library}@anchor{1ea}@anchor{gnat_ugn/platform_specific_information id24}@anchor{1eb} +@anchor{gnat_ugn/platform_specific_information creating-an-import-library}@anchor{1f1}@anchor{gnat_ugn/platform_specific_information id24}@anchor{1f2} @subsubsection Creating an Import Library @@ -24135,7 +24599,7 @@ as in this case it is possible to link directly against the DLL. Otherwise read on. @geindex Definition file -@anchor{gnat_ugn/platform_specific_information the-definition-file}@anchor{1e6} +@anchor{gnat_ugn/platform_specific_information the-definition-file}@anchor{1ed} @subsubheading The Definition File @@ -24183,17 +24647,17 @@ EXPORTS @end table Note that you must specify the correct suffix (@code{@@@var{nn}}) -(see @ref{1db,,Windows Calling Conventions}) for a Stdcall +(see @ref{1e2,,Windows Calling Conventions}) for a Stdcall calling convention function in the exported symbols list. There can actually be other sections in a definition file, but these sections are not relevant to the discussion at hand. -@anchor{gnat_ugn/platform_specific_information create-def-file-automatically}@anchor{1ec} +@anchor{gnat_ugn/platform_specific_information create-def-file-automatically}@anchor{1f3} @subsubheading Creating a Definition File Automatically You can automatically create the definition file @code{API.def} -(see @ref{1e6,,The Definition File}) from a DLL. +(see @ref{1ed,,The Definition File}) from a DLL. To do that, use the @code{dlltool} program as follows: @quotation @@ -24203,7 +24667,7 @@ $ dlltool API.dll -z API.def --export-all-symbols @end example Note that if some routines in the DLL have the @code{Stdcall} convention -(@ref{1db,,Windows Calling Conventions}) with stripped @code{@@@var{nn}} +(@ref{1e2,,Windows Calling Conventions}) with stripped @code{@@@var{nn}} suffix then you’ll have to edit @code{api.def} to add it and specify @code{-k} to @code{gnatdll} when creating the import library. @@ -24228,13 +24692,13 @@ tells you what symbol is expected. You then can go back to the definition file and add the right suffix. @end itemize @end quotation -@anchor{gnat_ugn/platform_specific_information gnat-style-import-library}@anchor{1ed} +@anchor{gnat_ugn/platform_specific_information gnat-style-import-library}@anchor{1f4} @subsubheading GNAT-Style Import Library To create a static import library from @code{API.dll} with the GNAT tools, you should create the @code{.def} file and use the @code{gnatdll} tool -(see @ref{1ee,,Using gnatdll}) as follows: +(see @ref{1f5,,Using gnatdll}) as follows: @quotation @@ -24250,15 +24714,15 @@ definition file name is @code{xyz.def}, the import library name will be @code{libxyz.a}. Note that in the previous example, the switch @code{-e} could have been removed because the name of the definition file (before the @code{.def} suffix) is the same as the name of the -DLL (@ref{1ee,,Using gnatdll} for more information about @code{gnatdll}). +DLL (@ref{1f5,,Using gnatdll} for more information about @code{gnatdll}). @end quotation -@anchor{gnat_ugn/platform_specific_information msvs-style-import-library}@anchor{1ef} +@anchor{gnat_ugn/platform_specific_information msvs-style-import-library}@anchor{1f6} @subsubheading Microsoft-Style Import Library A Microsoft import library is needed only if you plan to make an Ada DLL available to applications developed with Microsoft -tools (@ref{1d7,,Mixed-Language Programming on Windows}). +tools (@ref{1de,,Mixed-Language Programming on Windows}). To create a Microsoft-style import library for @code{API.dll} you should create the @code{.def} file, then build the actual import library using @@ -24282,7 +24746,7 @@ See the Microsoft documentation for further details about the usage of @end quotation @node Building DLLs with GNAT Project files,Building DLLs with GNAT,Using DLLs with GNAT,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnat-project-files}@anchor{1d9}@anchor{gnat_ugn/platform_specific_information id25}@anchor{1f0} +@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnat-project-files}@anchor{1e0}@anchor{gnat_ugn/platform_specific_information id25}@anchor{1f7} @subsubsection Building DLLs with GNAT Project files @@ -24298,7 +24762,7 @@ when inside the @code{DllMain} routine which is used for auto-initialization of shared libraries, so you can’t have library level tasks in SALs. @node Building DLLs with GNAT,Building DLLs with gnatdll,Building DLLs with GNAT Project files,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnat}@anchor{1f1}@anchor{gnat_ugn/platform_specific_information id26}@anchor{1f2} +@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnat}@anchor{1f8}@anchor{gnat_ugn/platform_specific_information id26}@anchor{1f9} @subsubsection Building DLLs with GNAT @@ -24329,7 +24793,7 @@ $ gcc -shared -shared-libgcc -o api.dll obj1.o obj2.o ... It’s important to note that in this case all symbols found in the object files are automatically exported. You can restrict the set of symbols to export by passing to @code{gcc} a definition -file (see @ref{1e6,,The Definition File}). +file (see @ref{1ed,,The Definition File}). For example: @example @@ -24367,7 +24831,7 @@ $ gnatmake main -Iapilib -bargs -shared -largs -Lapilib -lAPI @end quotation @node Building DLLs with gnatdll,Ada DLLs and Finalization,Building DLLs with GNAT,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnatdll}@anchor{1f3}@anchor{gnat_ugn/platform_specific_information id27}@anchor{1f4} +@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnatdll}@anchor{1fa}@anchor{gnat_ugn/platform_specific_information id27}@anchor{1fb} @subsubsection Building DLLs with gnatdll @@ -24375,8 +24839,8 @@ $ gnatmake main -Iapilib -bargs -shared -largs -Lapilib -lAPI @geindex building Note that it is preferred to use GNAT Project files -(@ref{1d9,,Building DLLs with GNAT Project files}) or the built-in GNAT -DLL support (@ref{1f1,,Building DLLs with GNAT}) to build DLLs. +(@ref{1e0,,Building DLLs with GNAT Project files}) or the built-in GNAT +DLL support (@ref{1f8,,Building DLLs with GNAT}) to build DLLs. This section explains how to build DLLs containing Ada code using @code{gnatdll}. These DLLs will be referred to as Ada DLLs in the @@ -24392,20 +24856,20 @@ non-Ada applications are as follows: You need to mark each Ada entity exported by the DLL with a @code{C} or @code{Stdcall} calling convention to avoid any Ada name mangling for the entities exported by the DLL -(see @ref{1f5,,Exporting Ada Entities}). You can +(see @ref{1fc,,Exporting Ada Entities}). You can skip this step if you plan to use the Ada DLL only from Ada applications. @item Your Ada code must export an initialization routine which calls the routine @code{adainit} (generated by @code{gnatbind}) to perform the elaboration of -the Ada code in the DLL (@ref{1f6,,Ada DLLs and Elaboration}). The initialization +the Ada code in the DLL (@ref{1fd,,Ada DLLs and Elaboration}). The initialization routine exported by the Ada DLL must be invoked by the clients of the DLL to initialize the DLL. @item When useful, the DLL should also export a finalization routine which calls routine @code{adafinal} (also generated by @code{gnatbind}) to perform the -finalization of the Ada code in the DLL (@ref{1f7,,Ada DLLs and Finalization}). +finalization of the Ada code in the DLL (@ref{1fe,,Ada DLLs and Finalization}). The finalization routine exported by the Ada DLL must be invoked by the clients of the DLL when the DLL services are no further needed. @@ -24415,11 +24879,11 @@ of the programming languages to which you plan to make the DLL available. @item You must provide a definition file listing the exported entities -(@ref{1e6,,The Definition File}). +(@ref{1ed,,The Definition File}). @item Finally, you must use @code{gnatdll} to produce the DLL and the import -library (@ref{1ee,,Using gnatdll}). +library (@ref{1f5,,Using gnatdll}). @end itemize Note that a relocatable DLL stripped using the @code{strip} @@ -24439,7 +24903,7 @@ chapter of the `GPRbuild User’s Guide'. @end menu @node Limitations When Using Ada DLLs from Ada,Exporting Ada Entities,,Building DLLs with gnatdll -@anchor{gnat_ugn/platform_specific_information limitations-when-using-ada-dlls-from-ada}@anchor{1f8} +@anchor{gnat_ugn/platform_specific_information limitations-when-using-ada-dlls-from-ada}@anchor{1ff} @subsubsection Limitations When Using Ada DLLs from Ada @@ -24460,7 +24924,7 @@ It is completely safe to exchange plain elementary, array or record types, Windows object handles, etc. @node Exporting Ada Entities,Ada DLLs and Elaboration,Limitations When Using Ada DLLs from Ada,Building DLLs with gnatdll -@anchor{gnat_ugn/platform_specific_information exporting-ada-entities}@anchor{1f5}@anchor{gnat_ugn/platform_specific_information id28}@anchor{1f9} +@anchor{gnat_ugn/platform_specific_information exporting-ada-entities}@anchor{1fc}@anchor{gnat_ugn/platform_specific_information id28}@anchor{200} @subsubsection Exporting Ada Entities @@ -24560,10 +25024,10 @@ end API; Note that if you do not export the Ada entities with a @code{C} or @code{Stdcall} convention, you will have to provide the mangled Ada names in the definition file of the Ada DLL -(@ref{1fa,,Creating the Definition File}). +(@ref{201,,Creating the Definition File}). @node Ada DLLs and Elaboration,,Exporting Ada Entities,Building DLLs with gnatdll -@anchor{gnat_ugn/platform_specific_information ada-dlls-and-elaboration}@anchor{1f6}@anchor{gnat_ugn/platform_specific_information id29}@anchor{1fb} +@anchor{gnat_ugn/platform_specific_information ada-dlls-and-elaboration}@anchor{1fd}@anchor{gnat_ugn/platform_specific_information id29}@anchor{202} @subsubsection Ada DLLs and Elaboration @@ -24581,7 +25045,7 @@ the Ada elaboration routine @code{adainit} generated by the GNAT binder (@ref{7f,,Binding with Non-Ada Main Programs}). See the body of @code{Initialize_Api} for an example. Note that the GNAT binder is automatically invoked during the DLL build process by the @code{gnatdll} -tool (@ref{1ee,,Using gnatdll}). +tool (@ref{1f5,,Using gnatdll}). When a DLL is loaded, Windows systematically invokes a routine called @code{DllMain}. It should therefore be possible to call @code{adainit} @@ -24594,7 +25058,7 @@ time), which means that the GNAT run-time will deadlock waiting for a newly created task to complete its initialization. @node Ada DLLs and Finalization,Creating a Spec for Ada DLLs,Building DLLs with gnatdll,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information ada-dlls-and-finalization}@anchor{1f7}@anchor{gnat_ugn/platform_specific_information id30}@anchor{1fc} +@anchor{gnat_ugn/platform_specific_information ada-dlls-and-finalization}@anchor{1fe}@anchor{gnat_ugn/platform_specific_information id30}@anchor{203} @subsubsection Ada DLLs and Finalization @@ -24609,10 +25073,10 @@ routine @code{adafinal} generated by the GNAT binder See the body of @code{Finalize_Api} for an example. As already pointed out the GNAT binder is automatically invoked during the DLL build process by the @code{gnatdll} tool -(@ref{1ee,,Using gnatdll}). +(@ref{1f5,,Using gnatdll}). @node Creating a Spec for Ada DLLs,GNAT and Windows Resources,Ada DLLs and Finalization,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information creating-a-spec-for-ada-dlls}@anchor{1fd}@anchor{gnat_ugn/platform_specific_information id31}@anchor{1fe} +@anchor{gnat_ugn/platform_specific_information creating-a-spec-for-ada-dlls}@anchor{204}@anchor{gnat_ugn/platform_specific_information id31}@anchor{205} @subsubsection Creating a Spec for Ada DLLs @@ -24670,7 +25134,7 @@ end API; @end menu @node Creating the Definition File,Using gnatdll,,Creating a Spec for Ada DLLs -@anchor{gnat_ugn/platform_specific_information creating-the-definition-file}@anchor{1fa}@anchor{gnat_ugn/platform_specific_information id32}@anchor{1ff} +@anchor{gnat_ugn/platform_specific_information creating-the-definition-file}@anchor{201}@anchor{gnat_ugn/platform_specific_information id32}@anchor{206} @subsubsection Creating the Definition File @@ -24706,7 +25170,7 @@ EXPORTS @end quotation @node Using gnatdll,,Creating the Definition File,Creating a Spec for Ada DLLs -@anchor{gnat_ugn/platform_specific_information id33}@anchor{200}@anchor{gnat_ugn/platform_specific_information using-gnatdll}@anchor{1ee} +@anchor{gnat_ugn/platform_specific_information id33}@anchor{207}@anchor{gnat_ugn/platform_specific_information using-gnatdll}@anchor{1f5} @subsubsection Using @code{gnatdll} @@ -24910,7 +25374,7 @@ asks @code{gnatlink} to generate the routines @code{DllMain} and is loaded into memory. @item -uses @code{dlltool} (see @ref{201,,Using dlltool}) to build the +uses @code{dlltool} (see @ref{208,,Using dlltool}) to build the export table (@code{api.exp}). The export table contains the relocation information in a form which can be used during the final link to ensure that the Windows loader is able to place the DLL anywhere in memory. @@ -24948,7 +25412,7 @@ $ gnatbind -n api $ gnatlink api api.exp -o api.dll -mdll @end example @end itemize -@anchor{gnat_ugn/platform_specific_information using-dlltool}@anchor{201} +@anchor{gnat_ugn/platform_specific_information using-dlltool}@anchor{208} @subsubheading Using @code{dlltool} @@ -25006,7 +25470,7 @@ DLL in the static import library generated by @code{dlltool} with switch @item @code{-k} Kill @code{@@@var{nn}} from exported names -(@ref{1db,,Windows Calling Conventions} +(@ref{1e2,,Windows Calling Conventions} for a discussion about @code{Stdcall}-style symbols). @end table @@ -25062,7 +25526,7 @@ Use @code{assembler-name} as the assembler. The default is @code{as}. @end table @node GNAT and Windows Resources,Using GNAT DLLs from Microsoft Visual Studio Applications,Creating a Spec for Ada DLLs,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information gnat-and-windows-resources}@anchor{202}@anchor{gnat_ugn/platform_specific_information id34}@anchor{203} +@anchor{gnat_ugn/platform_specific_information gnat-and-windows-resources}@anchor{209}@anchor{gnat_ugn/platform_specific_information id34}@anchor{20a} @subsubsection GNAT and Windows Resources @@ -25154,7 +25618,7 @@ the corresponding Microsoft documentation. @end menu @node Building Resources,Compiling Resources,,GNAT and Windows Resources -@anchor{gnat_ugn/platform_specific_information building-resources}@anchor{204}@anchor{gnat_ugn/platform_specific_information id35}@anchor{205} +@anchor{gnat_ugn/platform_specific_information building-resources}@anchor{20b}@anchor{gnat_ugn/platform_specific_information id35}@anchor{20c} @subsubsection Building Resources @@ -25174,7 +25638,7 @@ complete description of the resource script language can be found in the Microsoft documentation. @node Compiling Resources,Using Resources,Building Resources,GNAT and Windows Resources -@anchor{gnat_ugn/platform_specific_information compiling-resources}@anchor{206}@anchor{gnat_ugn/platform_specific_information id36}@anchor{207} +@anchor{gnat_ugn/platform_specific_information compiling-resources}@anchor{20d}@anchor{gnat_ugn/platform_specific_information id36}@anchor{20e} @subsubsection Compiling Resources @@ -25216,7 +25680,7 @@ $ windres -i myres.res -o myres.o @end quotation @node Using Resources,,Compiling Resources,GNAT and Windows Resources -@anchor{gnat_ugn/platform_specific_information id37}@anchor{208}@anchor{gnat_ugn/platform_specific_information using-resources}@anchor{209} +@anchor{gnat_ugn/platform_specific_information id37}@anchor{20f}@anchor{gnat_ugn/platform_specific_information using-resources}@anchor{210} @subsubsection Using Resources @@ -25236,7 +25700,7 @@ $ gnatmake myprog -largs myres.o @end quotation @node Using GNAT DLLs from Microsoft Visual Studio Applications,Debugging a DLL,GNAT and Windows Resources,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information using-gnat-dll-from-msvs}@anchor{20a}@anchor{gnat_ugn/platform_specific_information using-gnat-dlls-from-microsoft-visual-studio-applications}@anchor{20b} +@anchor{gnat_ugn/platform_specific_information using-gnat-dll-from-msvs}@anchor{211}@anchor{gnat_ugn/platform_specific_information using-gnat-dlls-from-microsoft-visual-studio-applications}@anchor{212} @subsubsection Using GNAT DLLs from Microsoft Visual Studio Applications @@ -25271,7 +25735,7 @@ $ gprbuild -p mylib.gpr @item Produce a @code{.def} file for the symbols you need to interface with, either by hand or automatically with possibly some manual -adjustments (see @ref{1ec,,Creating Definition File Automatically}): +adjustments (see @ref{1f3,,Creating Definition File Automatically}): @end enumerate @quotation @@ -25288,7 +25752,7 @@ $ dlltool libmylib.dll -z libmylib.def --export-all-symbols Make sure that MSVS command-line tools are accessible on the path. @item -Create the Microsoft-style import library (see @ref{1ef,,MSVS-Style Import Library}): +Create the Microsoft-style import library (see @ref{1f6,,MSVS-Style Import Library}): @end enumerate @quotation @@ -25331,7 +25795,7 @@ the @code{.exe}. @end enumerate @node Debugging a DLL,Setting Stack Size from gnatlink,Using GNAT DLLs from Microsoft Visual Studio Applications,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information debugging-a-dll}@anchor{20c}@anchor{gnat_ugn/platform_specific_information id38}@anchor{20d} +@anchor{gnat_ugn/platform_specific_information debugging-a-dll}@anchor{213}@anchor{gnat_ugn/platform_specific_information id38}@anchor{214} @subsubsection Debugging a DLL @@ -25368,7 +25832,7 @@ debugger compatible with the tools suite used to build the DLL. @end menu @node Program and DLL Both Built with GCC/GNAT,Program Built with Foreign Tools and DLL Built with GCC/GNAT,,Debugging a DLL -@anchor{gnat_ugn/platform_specific_information id39}@anchor{20e}@anchor{gnat_ugn/platform_specific_information program-and-dll-both-built-with-gcc-gnat}@anchor{20f} +@anchor{gnat_ugn/platform_specific_information id39}@anchor{215}@anchor{gnat_ugn/platform_specific_information program-and-dll-both-built-with-gcc-gnat}@anchor{216} @subsubsection Program and DLL Both Built with GCC/GNAT @@ -25378,7 +25842,7 @@ the process. Let’s suppose the main procedure is named @code{ada_main} and in the DLL there’s an entry point named @code{ada_dll}. -The DLL (@ref{1e5,,Introduction to Dynamic Link Libraries (DLLs)}) and +The DLL (@ref{1ec,,Introduction to Dynamic Link Libraries (DLLs)}) and program must have been built with the debugging information (see the GNAT @code{-g} switch). Here are the step-by-step instructions for debugging it: @@ -25415,10 +25879,10 @@ Set a breakpoint inside the DLL At this stage, a breakpoint is set inside the DLL. From there on you can use standard @code{GDB} commands to debug the whole program -(@ref{152,,Running and Debugging Ada Programs}). +(@ref{153,,Running and Debugging Ada Programs}). @node Program Built with Foreign Tools and DLL Built with GCC/GNAT,,Program and DLL Both Built with GCC/GNAT,Debugging a DLL -@anchor{gnat_ugn/platform_specific_information id40}@anchor{210}@anchor{gnat_ugn/platform_specific_information program-built-with-foreign-tools-and-dll-built-with-gcc-gnat}@anchor{211} +@anchor{gnat_ugn/platform_specific_information id40}@anchor{217}@anchor{gnat_ugn/platform_specific_information program-built-with-foreign-tools-and-dll-built-with-gcc-gnat}@anchor{218} @subsubsection Program Built with Foreign Tools and DLL Built with GCC/GNAT @@ -25435,7 +25899,7 @@ case, for example, for some C code built with Microsoft Visual C) and that there’s a DLL named @code{test.dll} containing an Ada entry point named @code{ada_dll}. -The DLL (see @ref{1e5,,Introduction to Dynamic Link Libraries (DLLs)}) must have +The DLL (see @ref{1ec,,Introduction to Dynamic Link Libraries (DLLs)}) must have been built with debugging information (see the GNAT @code{-g} switch). @subsubheading Debugging the DLL Directly @@ -25502,7 +25966,7 @@ Continue the program. This runs the program until it reaches the breakpoint that you’ve set. From that point, you can use standard @code{GDB} commands to debug a program as described in -(@ref{152,,Running and Debugging Ada Programs}). +(@ref{153,,Running and Debugging Ada Programs}). @end itemize You can also debug the DLL by attaching @code{GDB} to a running process. @@ -25572,21 +26036,22 @@ Continue process execution. This last step will resume the process execution and stop at the breakpoint we have set. From there you can use standard @code{GDB} commands to debug a program, as described in -@ref{152,,Running and Debugging Ada Programs}. +@ref{153,,Running and Debugging Ada Programs}. @node Setting Stack Size from gnatlink,Setting Heap Size from gnatlink,Debugging a DLL,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information id41}@anchor{212}@anchor{gnat_ugn/platform_specific_information setting-stack-size-from-gnatlink}@anchor{12b} +@anchor{gnat_ugn/platform_specific_information id41}@anchor{219}@anchor{gnat_ugn/platform_specific_information setting-stack-size-from-gnatlink}@anchor{12b} @subsubsection Setting Stack Size from @code{gnatlink} You can specify the program stack size at link time. On most versions of Windows, starting with XP, this is mostly useful to set the size of the main stack (environment task). The other task stacks are set with -pragma Storage_Size or with the `gnatbind -d' command. +pragma Storage_Size or with the `gnatbind -d' command. The specified size will +become the reserved memory size of the underlying thread. Since very old versions of Windows (2000, NT4, etc.) don’t allow setting the -reserve size of individual tasks, the link-time stack size applies to all -tasks, and pragma Storage_Size has no effect. +reserve size of individual tasks, for those versions the link-time stack size +applies to all tasks, and pragma Storage_Size has no effect. In particular, Stack Overflow checks are made against this link-time specified size. @@ -25618,7 +26083,7 @@ because the comma is a separator for this switch. @end itemize @node Setting Heap Size from gnatlink,,Setting Stack Size from gnatlink,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information id42}@anchor{213}@anchor{gnat_ugn/platform_specific_information setting-heap-size-from-gnatlink}@anchor{12c} +@anchor{gnat_ugn/platform_specific_information id42}@anchor{21a}@anchor{gnat_ugn/platform_specific_information setting-heap-size-from-gnatlink}@anchor{12c} @subsubsection Setting Heap Size from @code{gnatlink} @@ -25651,7 +26116,7 @@ because the comma is a separator for this switch. @end itemize @node Windows Specific Add-Ons,,Mixed-Language Programming on Windows,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information win32-specific-addons}@anchor{214}@anchor{gnat_ugn/platform_specific_information windows-specific-add-ons}@anchor{215} +@anchor{gnat_ugn/platform_specific_information win32-specific-addons}@anchor{21b}@anchor{gnat_ugn/platform_specific_information windows-specific-add-ons}@anchor{21c} @subsection Windows Specific Add-Ons @@ -25664,7 +26129,7 @@ This section describes the Windows specific add-ons. @end menu @node Win32Ada,wPOSIX,,Windows Specific Add-Ons -@anchor{gnat_ugn/platform_specific_information id43}@anchor{216}@anchor{gnat_ugn/platform_specific_information win32ada}@anchor{217} +@anchor{gnat_ugn/platform_specific_information id43}@anchor{21d}@anchor{gnat_ugn/platform_specific_information win32ada}@anchor{21e} @subsubsection Win32Ada @@ -25695,7 +26160,7 @@ gprbuild p.gpr @end quotation @node wPOSIX,,Win32Ada,Windows Specific Add-Ons -@anchor{gnat_ugn/platform_specific_information id44}@anchor{218}@anchor{gnat_ugn/platform_specific_information wposix}@anchor{219} +@anchor{gnat_ugn/platform_specific_information id44}@anchor{21f}@anchor{gnat_ugn/platform_specific_information wposix}@anchor{220} @subsubsection wPOSIX @@ -25728,7 +26193,7 @@ gprbuild p.gpr @end quotation @node Mac OS Topics,,Microsoft Windows Topics,Platform-Specific Information -@anchor{gnat_ugn/platform_specific_information id45}@anchor{21a}@anchor{gnat_ugn/platform_specific_information mac-os-topics}@anchor{21b} +@anchor{gnat_ugn/platform_specific_information id45}@anchor{221}@anchor{gnat_ugn/platform_specific_information mac-os-topics}@anchor{222} @section Mac OS Topics @@ -25743,7 +26208,7 @@ platform. @end menu @node Codesigning the Debugger,,,Mac OS Topics -@anchor{gnat_ugn/platform_specific_information codesigning-the-debugger}@anchor{21c} +@anchor{gnat_ugn/platform_specific_information codesigning-the-debugger}@anchor{223} @subsection Codesigning the Debugger @@ -25825,7 +26290,7 @@ installed GNAT. Also, be sure that users of @code{GDB} are in the Unix group @code{_developer}. @node Example of Binder Output File,Elaboration Order Handling in GNAT,Platform-Specific Information,Top -@anchor{gnat_ugn/example_of_binder_output doc}@anchor{21d}@anchor{gnat_ugn/example_of_binder_output example-of-binder-output-file}@anchor{f}@anchor{gnat_ugn/example_of_binder_output id1}@anchor{21e} +@anchor{gnat_ugn/example_of_binder_output doc}@anchor{224}@anchor{gnat_ugn/example_of_binder_output example-of-binder-output-file}@anchor{f}@anchor{gnat_ugn/example_of_binder_output id1}@anchor{225} @chapter Example of Binder Output File @@ -26575,7 +27040,7 @@ elaboration code in your own application). @c -- Example: A |withing| unit has a |with| clause, it |withs| a |withed| unit @node Elaboration Order Handling in GNAT,Inline Assembler,Example of Binder Output File,Top -@anchor{gnat_ugn/elaboration_order_handling_in_gnat doc}@anchor{21f}@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order-handling-in-gnat}@anchor{10}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id1}@anchor{220} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat doc}@anchor{226}@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order-handling-in-gnat}@anchor{10}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id1}@anchor{227} @chapter Elaboration Order Handling in GNAT @@ -26605,7 +27070,7 @@ GNAT, either automatically or with explicit programming features. @end menu @node Elaboration Code,Elaboration Order,,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-code}@anchor{221}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id2}@anchor{222} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-code}@anchor{228}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id2}@anchor{229} @section Elaboration Code @@ -26754,7 +27219,7 @@ elaborated. @end itemize @node Elaboration Order,Checking the Elaboration Order,Elaboration Code,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order}@anchor{223}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id3}@anchor{224} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order}@anchor{22a}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id3}@anchor{22b} @section Elaboration Order @@ -26924,7 +27389,7 @@ however a compiler may not always find such an order due to complications with respect to control and data flow. @node Checking the Elaboration Order,Controlling the Elaboration Order in Ada,Elaboration Order,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat checking-the-elaboration-order}@anchor{225}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id4}@anchor{226} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat checking-the-elaboration-order}@anchor{22c}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id4}@anchor{22d} @section Checking the Elaboration Order @@ -26985,7 +27450,7 @@ order. @end itemize @node Controlling the Elaboration Order in Ada,Controlling the Elaboration Order in GNAT,Checking the Elaboration Order,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat controlling-the-elaboration-order-in-ada}@anchor{227}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id5}@anchor{228} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat controlling-the-elaboration-order-in-ada}@anchor{22e}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id5}@anchor{22f} @section Controlling the Elaboration Order in Ada @@ -27314,7 +27779,7 @@ is that the program continues to stay in the last state (one or more correct orders exist) even if maintenance changes the bodies of targets. @node Controlling the Elaboration Order in GNAT,Mixing Elaboration Models,Controlling the Elaboration Order in Ada,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat controlling-the-elaboration-order-in-gnat}@anchor{229}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id6}@anchor{22a} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat controlling-the-elaboration-order-in-gnat}@anchor{230}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id6}@anchor{231} @section Controlling the Elaboration Order in GNAT @@ -27445,7 +27910,7 @@ that in this mode, GNAT may not diagnose certain elaboration issues or install run-time checks. @node Mixing Elaboration Models,ABE Diagnostics,Controlling the Elaboration Order in GNAT,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat id7}@anchor{22b}@anchor{gnat_ugn/elaboration_order_handling_in_gnat mixing-elaboration-models}@anchor{22c} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id7}@anchor{232}@anchor{gnat_ugn/elaboration_order_handling_in_gnat mixing-elaboration-models}@anchor{233} @section Mixing Elaboration Models @@ -27492,7 +27957,7 @@ warning: "y.ads" which has static elaboration checks You can suppress these warnings by specifying binder switch @code{-ws}. @node ABE Diagnostics,SPARK Diagnostics,Mixing Elaboration Models,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat abe-diagnostics}@anchor{22d}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id8}@anchor{22e} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat abe-diagnostics}@anchor{234}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id8}@anchor{235} @section ABE Diagnostics @@ -27599,7 +28064,7 @@ declaration @code{Safe} because the body of function @code{ABE} has already been elaborated at that point. @node SPARK Diagnostics,Elaboration Circularities,ABE Diagnostics,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat id9}@anchor{22f}@anchor{gnat_ugn/elaboration_order_handling_in_gnat spark-diagnostics}@anchor{230} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id9}@anchor{236}@anchor{gnat_ugn/elaboration_order_handling_in_gnat spark-diagnostics}@anchor{237} @section SPARK Diagnostics @@ -27625,7 +28090,7 @@ rules. @end quotation @node Elaboration Circularities,Resolving Elaboration Circularities,SPARK Diagnostics,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-circularities}@anchor{231}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id10}@anchor{232} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-circularities}@anchor{238}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id10}@anchor{239} @section Elaboration Circularities @@ -27725,7 +28190,7 @@ This section enumerates various tactics for eliminating the circularity. @end itemize @node Resolving Elaboration Circularities,Elaboration-related Compiler Switches,Elaboration Circularities,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat id11}@anchor{233}@anchor{gnat_ugn/elaboration_order_handling_in_gnat resolving-elaboration-circularities}@anchor{234} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id11}@anchor{23a}@anchor{gnat_ugn/elaboration_order_handling_in_gnat resolving-elaboration-circularities}@anchor{23b} @section Resolving Elaboration Circularities @@ -27996,7 +28461,7 @@ Use the relaxed dynamic-elaboration model, with compiler switches @end itemize @node Elaboration-related Compiler Switches,Summary of Procedures for Elaboration Control,Resolving Elaboration Circularities,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-related-compiler-switches}@anchor{235}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id12}@anchor{236} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-related-compiler-switches}@anchor{23c}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id12}@anchor{23d} @section Elaboration-related Compiler Switches @@ -28177,7 +28642,7 @@ checks. The example above will still fail at run time with an ABE. @end table @node Summary of Procedures for Elaboration Control,Inspecting the Chosen Elaboration Order,Elaboration-related Compiler Switches,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat id13}@anchor{237}@anchor{gnat_ugn/elaboration_order_handling_in_gnat summary-of-procedures-for-elaboration-control}@anchor{238} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id13}@anchor{23e}@anchor{gnat_ugn/elaboration_order_handling_in_gnat summary-of-procedures-for-elaboration-control}@anchor{23f} @section Summary of Procedures for Elaboration Control @@ -28235,7 +28700,7 @@ Use the relaxed dynamic elaboration model, with compiler switches @end itemize @node Inspecting the Chosen Elaboration Order,,Summary of Procedures for Elaboration Control,Elaboration Order Handling in GNAT -@anchor{gnat_ugn/elaboration_order_handling_in_gnat id14}@anchor{239}@anchor{gnat_ugn/elaboration_order_handling_in_gnat inspecting-the-chosen-elaboration-order}@anchor{23a} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id14}@anchor{240}@anchor{gnat_ugn/elaboration_order_handling_in_gnat inspecting-the-chosen-elaboration-order}@anchor{241} @section Inspecting the Chosen Elaboration Order @@ -28378,7 +28843,7 @@ gdbstr (body) @end quotation @node Inline Assembler,GNU Free Documentation License,Elaboration Order Handling in GNAT,Top -@anchor{gnat_ugn/inline_assembler doc}@anchor{23b}@anchor{gnat_ugn/inline_assembler id1}@anchor{23c}@anchor{gnat_ugn/inline_assembler inline-assembler}@anchor{11} +@anchor{gnat_ugn/inline_assembler doc}@anchor{242}@anchor{gnat_ugn/inline_assembler id1}@anchor{243}@anchor{gnat_ugn/inline_assembler inline-assembler}@anchor{11} @chapter Inline Assembler @@ -28437,7 +28902,7 @@ and assembly language programming. @end menu @node Basic Assembler Syntax,A Simple Example of Inline Assembler,,Inline Assembler -@anchor{gnat_ugn/inline_assembler basic-assembler-syntax}@anchor{23d}@anchor{gnat_ugn/inline_assembler id2}@anchor{23e} +@anchor{gnat_ugn/inline_assembler basic-assembler-syntax}@anchor{244}@anchor{gnat_ugn/inline_assembler id2}@anchor{245} @section Basic Assembler Syntax @@ -28553,7 +29018,7 @@ Intel: Destination first; for example @code{mov eax, 4}@w{ } @node A Simple Example of Inline Assembler,Output Variables in Inline Assembler,Basic Assembler Syntax,Inline Assembler -@anchor{gnat_ugn/inline_assembler a-simple-example-of-inline-assembler}@anchor{23f}@anchor{gnat_ugn/inline_assembler id3}@anchor{240} +@anchor{gnat_ugn/inline_assembler a-simple-example-of-inline-assembler}@anchor{246}@anchor{gnat_ugn/inline_assembler id3}@anchor{247} @section A Simple Example of Inline Assembler @@ -28702,7 +29167,7 @@ If there are no errors, @code{as} generates an object file called @code{nothing.out}. @node Output Variables in Inline Assembler,Input Variables in Inline Assembler,A Simple Example of Inline Assembler,Inline Assembler -@anchor{gnat_ugn/inline_assembler id4}@anchor{241}@anchor{gnat_ugn/inline_assembler output-variables-in-inline-assembler}@anchor{242} +@anchor{gnat_ugn/inline_assembler id4}@anchor{248}@anchor{gnat_ugn/inline_assembler output-variables-in-inline-assembler}@anchor{249} @section Output Variables in Inline Assembler @@ -29069,7 +29534,7 @@ end Get_Flags_3; @end quotation @node Input Variables in Inline Assembler,Inlining Inline Assembler Code,Output Variables in Inline Assembler,Inline Assembler -@anchor{gnat_ugn/inline_assembler id5}@anchor{243}@anchor{gnat_ugn/inline_assembler input-variables-in-inline-assembler}@anchor{244} +@anchor{gnat_ugn/inline_assembler id5}@anchor{24a}@anchor{gnat_ugn/inline_assembler input-variables-in-inline-assembler}@anchor{24b} @section Input Variables in Inline Assembler @@ -29158,7 +29623,7 @@ _increment__incr.1: @end quotation @node Inlining Inline Assembler Code,Other Asm Functionality,Input Variables in Inline Assembler,Inline Assembler -@anchor{gnat_ugn/inline_assembler id6}@anchor{245}@anchor{gnat_ugn/inline_assembler inlining-inline-assembler-code}@anchor{246} +@anchor{gnat_ugn/inline_assembler id6}@anchor{24c}@anchor{gnat_ugn/inline_assembler inlining-inline-assembler-code}@anchor{24d} @section Inlining Inline Assembler Code @@ -29229,7 +29694,7 @@ movl %esi,%eax thus saving the overhead of stack frame setup and an out-of-line call. @node Other Asm Functionality,,Inlining Inline Assembler Code,Inline Assembler -@anchor{gnat_ugn/inline_assembler id7}@anchor{247}@anchor{gnat_ugn/inline_assembler other-asm-functionality}@anchor{248} +@anchor{gnat_ugn/inline_assembler id7}@anchor{24e}@anchor{gnat_ugn/inline_assembler other-asm-functionality}@anchor{24f} @section Other @code{Asm} Functionality @@ -29244,7 +29709,7 @@ and @code{Volatile}, which inhibits unwanted optimizations. @end menu @node The Clobber Parameter,The Volatile Parameter,,Other Asm Functionality -@anchor{gnat_ugn/inline_assembler id8}@anchor{249}@anchor{gnat_ugn/inline_assembler the-clobber-parameter}@anchor{24a} +@anchor{gnat_ugn/inline_assembler id8}@anchor{250}@anchor{gnat_ugn/inline_assembler the-clobber-parameter}@anchor{251} @subsection The @code{Clobber} Parameter @@ -29308,7 +29773,7 @@ Use ‘register’ name @code{memory} if you changed a memory location @end itemize @node The Volatile Parameter,,The Clobber Parameter,Other Asm Functionality -@anchor{gnat_ugn/inline_assembler id9}@anchor{24b}@anchor{gnat_ugn/inline_assembler the-volatile-parameter}@anchor{24c} +@anchor{gnat_ugn/inline_assembler id9}@anchor{252}@anchor{gnat_ugn/inline_assembler the-volatile-parameter}@anchor{253} @subsection The @code{Volatile} Parameter @@ -29344,7 +29809,7 @@ to @code{True} only if the compiler’s optimizations have created problems. @node GNU Free Documentation License,Index,Inline Assembler,Top -@anchor{share/gnu_free_documentation_license doc}@anchor{24d}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{24e} +@anchor{share/gnu_free_documentation_license doc}@anchor{254}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{255} @chapter GNU Free Documentation License @@ -29832,8 +30297,8 @@ to permit their use in free software. @printindex ge -@anchor{d2}@w{ } @anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ } +@anchor{d2}@w{ } @c %**end of body @bye |