From patchwork Mon May 15 09:42:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 94024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6791054vqo; Mon, 15 May 2023 02:45:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62nUNFtXLDL33+ZXULlocfkQt/Seop7YJM14YTaWr3jKI6uYwckkFZV682Bz96TJSDAx5I X-Received: by 2002:aa7:c2d2:0:b0:50b:c377:e7fd with SMTP id m18-20020aa7c2d2000000b0050bc377e7fdmr27619502edp.15.1684143926628; Mon, 15 May 2023 02:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684143926; cv=none; d=google.com; s=arc-20160816; b=gIeptxw93g9vmlY53Tq7A6mE7pk4aMZ2sLQl9aDBZ2ayOijyUwPNeVKHUJUoQi6/x/ 6vvpDi3Uf4BtvHITtXn1Ug8w6kIs5brZUEkVwU6jTYXkWnZzG1nKO4EIraSu/bD7le96 Al2NXtQsk4QrUr9M/L6uo8Mw4kjZfpe3ovJrKI2apVejEXFsFUuCuQ4HClDyKF/8exu3 487ilAv7r+wcyRgRAnqXjkLRZ3lzs4u7fuylnIPW8AWRO023KBf6DmPSAzjPcTEGahHR N1I0hm6KbVhxRXIBeIayr6GjO4I1jfBQ+VC90C8FJhYn7z09hT0EknBtfX3s6+62Dxql ERKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=d+LrUXFp6wLNz5pK93PrxGJS0ypHluwJnsfsSL8eJjU=; b=mq4P/DcLfWeCDKs26V5k9SfxMgzQPxK3+Kx8SlqE1W73Iy5lCPntCpvTSal8bR3QN5 ptEZy04epU8huLcNnpp+vu69Ks/3PenDteOLD+GGSc50HehOLo/nHPRTwqEdvQ7cWLis di7noTaN2tMOPPXWj1BrctNPxgVhI60JlQyeuBt4eiMTFyl6vnte+8zu4EDzbRRC/ZPJ 44z5muGqN9cKt9FkpMZOHRCZpsDNiTo4/LRAolhhIqb98032Mv4wbgVhOzRYuaGGlNfQ pV41rg59iC/dcKoL2rntcJXvWuONPlrkidr9pJssCFsQTnwhu/i72Ohw5WEFQvUhTJnF lsEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Dkj7GSUf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t25-20020aa7d719000000b00506af2220dfsi11639595edq.74.2023.05.15.02.45.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Dkj7GSUf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6781E387090B for ; Mon, 15 May 2023 09:44:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6781E387090B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684143843; bh=d+LrUXFp6wLNz5pK93PrxGJS0ypHluwJnsfsSL8eJjU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Dkj7GSUf8qPEjWyDNBuWbKmFoArqmqPff9ct4iD9BoacvNvFL4v++7E25vHc1c0gh QqVn6IFG/vWRRloxp/NNSDUkon1V9Mu49mPEYOJZUCC4GstuD6ii9vWXVGeb36oe7T Fh/pesCpG8MQwCITSOE5bQsKTzCvw+H1wOsrbPu4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 5B5A3385414E for ; Mon, 15 May 2023 09:42:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B5A3385414E Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f41d087b24so65927025e9.1 for ; Mon, 15 May 2023 02:42:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143739; x=1686735739; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d+LrUXFp6wLNz5pK93PrxGJS0ypHluwJnsfsSL8eJjU=; b=ThxIv+aXmy0neV4LFxwN2dZIMWBqsug4XOdUu2RbDFIc5OJxm/8aRX2syh4crSeG0R nSBO4GYRh/bC5DDhD1nzUvUZuwjl4NJksSbTTjguOxgSPdc5XFLq9KEwC9uPdh3As1+o OGnfwciROu8TGXybs4SRzuNCg5meVgB5MvwoqiBo+BI3/r3mZH3k6rUuPcSItThZ/dS2 FWJDPxUK6W6mUehYaCMi9XKMNnxa/5lL5jOICMVEmx5EwBPper/nz3fnBnaWWw7gXHGO z/3rB0OzzB2EdPcvp23XWgtzBTxwVWrvrCOmZTx4h5DyQuzgCB9d//NPT9qa3SiwOQaB g/uw== X-Gm-Message-State: AC+VfDwxxtPWQrtcZQYooptWKsBQsUDGwU5cPVDJ1eNUJdycR2TWwkWn LCW1wshhcK7mBhTJsDnfOCMwaChnM7UspUbgoLCuZg== X-Received: by 2002:a7b:c014:0:b0:3f5:f52:beb1 with SMTP id c20-20020a7bc014000000b003f50f52beb1mr631644wmb.12.1684143738271; Mon, 15 May 2023 02:42:18 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id m21-20020a7bca55000000b003f4285629casm20988015wml.42.2023.05.15.02.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:42:17 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Joel Brobecker Subject: [COMMITTED] ada: GNAT UGN: Add section documenting PIE being enabled by default on Linux Date: Mon, 15 May 2023 11:42:15 +0200 Message-Id: <20230515094215.1407504-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ADVERT2, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765952901803051621?= X-GMAIL-MSGID: =?utf-8?q?1765952901803051621?= From: Joel Brobecker This commit updates the Linux-specific chapter to add a new section documenting the fact that PIE is enabled by default, and provides some information about the impact that this might have on some projects, as well as recommendations on how to handle issues. gcc/ada/ * doc/gnat_ugn/platform_specific_information.rst (_PIE_Enabled_By_Default_On_Linux): New section. * gnat-style.texi: Regenerate. * gnat_ugn.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- .../platform_specific_information.rst | 42 +++ gcc/ada/gnat-style.texi | 6 +- gcc/ada/gnat_ugn.texi | 252 +++++++++++------- 3 files changed, 194 insertions(+), 106 deletions(-) diff --git a/gcc/ada/doc/gnat_ugn/platform_specific_information.rst b/gcc/ada/doc/gnat_ugn/platform_specific_information.rst index a136a5a0f75..3744b742f8e 100644 --- a/gcc/ada/doc/gnat_ugn/platform_specific_information.rst +++ b/gcc/ada/doc/gnat_ugn/platform_specific_information.rst @@ -254,6 +254,48 @@ Other GNU/Linux distributions might be choosing a different name for those packages. +.. _PIE_Enabled_By_Default_On_Linux: + +Position Independent Executable (PIE) Enabled by Default on Linux +----------------------------------------------------------------- + +GNAT generates Position Independent Executable (PIE) code by default. +PIE binaries are loaded into random memory locations, introducing +an additional layer of protection against attacks. + +Building PIE binaries requires that all of their dependencies also be +built as Position Independent. If the link of your project fails with +an error like:: + + /[...]/ld: /path/to/object/file: relocation R_X86_64_32S against symbol + `symbol name' can not be used when making a PIE object; + recompile with -fPIE + +it means the identified object file has not been built as Position +Independent. + +If you are not interested in building PIE binaries, you can simply +turn this feature off by first compiling your code with :samp:`-fno-pie` +and then by linking with :samp:`-no-pie` (note the subtle but important +difference in the names of the options -- the linker option does **not** +have an `f` after the dash!). When using gprbuild, this is +achieved by updating the *Required_Switches* attribute in package `Compiler` +and, depending on your type of project, either attribute *Switches* +or attribute *Library_Options* in package `Linker`. + +On the other hand, if you would like to build PIE binaries and you are +getting the error above, a quick and easy workaround to allow linking +to succeed again is to disable PIE during the link, thus temporarily +lifting the requirement that all dependencies also be Position +Independent code. To do so, you simply need to add :samp:`-no-pie` to +the list of switches passed to the linker. As part of this workaround, +there is no need to adjust the compiler switches. + +From there, to be able to link your binaries with PIE and therefore +drop the :samp:`-no-pie` workaround, you'll need to get the identified +dependencies rebuilt with PIE enabled (compiled with :samp:`-fPIE` +and linked with :samp:`-pie`). + .. _A_GNU_Linux_debug_quirk: A GNU/Linux Debug Quirk diff --git a/gcc/ada/gnat-style.texi b/gcc/ada/gnat-style.texi index f3b1c29a24f..5555bcdc160 100644 --- a/gcc/ada/gnat-style.texi +++ b/gcc/ada/gnat-style.texi @@ -3,7 +3,7 @@ @setfilename gnat-style.info @documentencoding UTF-8 @ifinfo -@*Generated by Sphinx 5.1.1.@* +@*Generated by Sphinx 5.2.3.@* @end ifinfo @settitle GNAT Coding Style A Guide for GNAT Developers @defindex ge @@ -19,11 +19,11 @@ @copying @quotation -GNAT Coding Style: A Guide for GNAT Developers , Aug 25, 2022 +GNAT Coding Style: A Guide for GNAT Developers , May 09, 2023 AdaCore -Copyright @copyright{} 2008-2022, Free Software Foundation +Copyright @copyright{} 2008-2023, Free Software Foundation @end quotation @end copying diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index a1daff92fbe..e8512cb0471 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT User's Guide for Native Platforms , Jan 03, 2023 +GNAT User's Guide for Native Platforms , May 09, 2023 AdaCore @@ -431,6 +431,7 @@ Specifying a Run-Time Library GNU/Linux Topics * Required Packages on GNU/Linux:: +* Position Independent Executable (PIE) Enabled by Default on Linux: Position Independent Executable PIE Enabled by Default on Linux. * A GNU/Linux Debug Quirk:: Microsoft Windows Topics @@ -22796,11 +22797,12 @@ This section describes topics that are specific to GNU/Linux platforms. @menu * Required Packages on GNU/Linux:: +* Position Independent Executable (PIE) Enabled by Default on Linux: Position Independent Executable PIE Enabled by Default on Linux. * A GNU/Linux Debug Quirk:: @end menu -@node Required Packages on GNU/Linux,A GNU/Linux Debug Quirk,,GNU/Linux Topics +@node Required Packages on GNU/Linux,Position Independent Executable PIE Enabled by Default on Linux,,GNU/Linux Topics @anchor{gnat_ugn/platform_specific_information id7}@anchor{1bd}@anchor{gnat_ugn/platform_specific_information required-packages-on-gnu-linux}@anchor{1be} @subsection Required Packages on GNU/Linux @@ -22837,8 +22839,52 @@ Debian, Ubuntu: @code{libc6:i386}, @code{libc6-dev:i386}, @code{lib32ncursesw5} Other GNU/Linux distributions might be choosing a different name for those packages. -@node A GNU/Linux Debug Quirk,,Required Packages on GNU/Linux,GNU/Linux Topics -@anchor{gnat_ugn/platform_specific_information a-gnu-linux-debug-quirk}@anchor{1bf}@anchor{gnat_ugn/platform_specific_information id8}@anchor{1c0} +@node Position Independent Executable PIE Enabled by Default on Linux,A GNU/Linux Debug Quirk,Required Packages on GNU/Linux,GNU/Linux Topics +@anchor{gnat_ugn/platform_specific_information pie-enabled-by-default-on-linux}@anchor{1bf}@anchor{gnat_ugn/platform_specific_information position-independent-executable-pie-enabled-by-default-on-linux}@anchor{1c0} +@subsection Position Independent Executable (PIE) Enabled by Default on Linux + + +GNAT generates Position Independent Executable (PIE) code by default. +PIE binaries are loaded into random memory locations, introducing +an additional layer of protection against attacks. + +Building PIE binaries requires that all of their dependencies also be +built as Position Independent. If the link of your project fails with +an error like: + +@example +/[...]/ld: /path/to/object/file: relocation R_X86_64_32S against symbol +`symbol name' can not be used when making a PIE object; +recompile with -fPIE +@end example + +it means the identified object file has not been built as Position +Independent. + +If you are not interested in building PIE binaries, you can simply +turn this feature off by first compiling your code with @code{-fno-pie} +and then by linking with @code{-no-pie} (note the subtle but important +difference in the names of the options – the linker option does `not' +have an @cite{f} after the dash!). When using gprbuild, this is +achieved by updating the `Required_Switches' attribute in package @cite{Compiler} +and, depending on your type of project, either attribute `Switches' +or attribute `Library_Options' in package @cite{Linker}. + +On the other hand, if you would like to build PIE binaries and you are +getting the error above, a quick and easy workaround to allow linking +to succeed again is to disable PIE during the link, thus temporarily +lifting the requirement that all dependencies also be Position +Independent code. To do so, you simply need to add @code{-no-pie} to +the list of switches passed to the linker. As part of this workaround, +there is no need to adjust the compiler switches. + +From there, to be able to link your binaries with PIE and therefore +drop the @code{-no-pie} workaround, you’ll need to get the identified +dependencies rebuilt with PIE enabled (compiled with @code{-fPIE} +and linked with @code{-pie}). + +@node A GNU/Linux Debug Quirk,,Position Independent Executable PIE Enabled by Default on Linux,GNU/Linux Topics +@anchor{gnat_ugn/platform_specific_information a-gnu-linux-debug-quirk}@anchor{1c1}@anchor{gnat_ugn/platform_specific_information id8}@anchor{1c2} @subsection A GNU/Linux Debug Quirk @@ -22858,7 +22904,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{1c1}@anchor{gnat_ugn/platform_specific_information microsoft-windows-topics}@anchor{1c2} +@anchor{gnat_ugn/platform_specific_information id9}@anchor{1c3}@anchor{gnat_ugn/platform_specific_information microsoft-windows-topics}@anchor{1c4} @section Microsoft Windows Topics @@ -22879,7 +22925,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{1c3}@anchor{gnat_ugn/platform_specific_information using-gnat-on-windows}@anchor{1c4} +@anchor{gnat_ugn/platform_specific_information id10}@anchor{1c5}@anchor{gnat_ugn/platform_specific_information using-gnat-on-windows}@anchor{1c6} @subsection Using GNAT on Windows @@ -22956,7 +23002,7 @@ uninstall or integrate 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{1c5}@anchor{gnat_ugn/platform_specific_information using-a-network-installation-of-gnat}@anchor{1c6} +@anchor{gnat_ugn/platform_specific_information id11}@anchor{1c7}@anchor{gnat_ugn/platform_specific_information using-a-network-installation-of-gnat}@anchor{1c8} @subsection Using a network installation of GNAT @@ -22983,7 +23029,7 @@ transfer of large amounts of data across the network and will likely cause 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{1c7}@anchor{gnat_ugn/platform_specific_information id12}@anchor{1c8} +@anchor{gnat_ugn/platform_specific_information console-and-windows-subsystems}@anchor{1c9}@anchor{gnat_ugn/platform_specific_information id12}@anchor{1ca} @subsection CONSOLE and WINDOWS subsystems @@ -23008,7 +23054,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{1c9}@anchor{gnat_ugn/platform_specific_information temporary-files}@anchor{1ca} +@anchor{gnat_ugn/platform_specific_information id13}@anchor{1cb}@anchor{gnat_ugn/platform_specific_information temporary-files}@anchor{1cc} @subsection Temporary Files @@ -23047,7 +23093,7 @@ environments where you may not have write access to some directories. @node Disabling Command Line Argument Expansion,Windows Socket Timeouts,Temporary Files,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information disabling-command-line-argument-expansion}@anchor{1cb} +@anchor{gnat_ugn/platform_specific_information disabling-command-line-argument-expansion}@anchor{1cd} @subsection Disabling Command Line Argument Expansion @@ -23118,7 +23164,7 @@ Ada.Command_Line.Argument (1) -> "'*.txt'" @end example @node Windows Socket Timeouts,Mixed-Language Programming on Windows,Disabling Command Line Argument Expansion,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information windows-socket-timeouts}@anchor{1cc} +@anchor{gnat_ugn/platform_specific_information windows-socket-timeouts}@anchor{1ce} @subsection Windows Socket Timeouts @@ -23164,7 +23210,7 @@ shorter than 500 ms is needed on these Windows versions, a call to Check_Selector should be added before any socket read or write operations. @node Mixed-Language Programming on Windows,Windows Specific Add-Ons,Windows Socket Timeouts,Microsoft Windows Topics -@anchor{gnat_ugn/platform_specific_information id14}@anchor{1cd}@anchor{gnat_ugn/platform_specific_information mixed-language-programming-on-windows}@anchor{1ce} +@anchor{gnat_ugn/platform_specific_information id14}@anchor{1cf}@anchor{gnat_ugn/platform_specific_information mixed-language-programming-on-windows}@anchor{1d0} @subsection Mixed-Language Programming on Windows @@ -23186,12 +23232,12 @@ to use the Microsoft tools for your C++ code, you have two choices: Encapsulate your C++ code in a DLL to be linked with your Ada application. In this case, use the Microsoft or whatever environment to build the DLL and use GNAT to build your executable -(@ref{1cf,,Using DLLs with GNAT}). +(@ref{1d1,,Using DLLs with GNAT}). @item Or 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{1d0,,Building DLLs with GNAT Project files}) and use the Microsoft +(@ref{1d2,,Building DLLs with GNAT Project files}) and use the Microsoft or whatever environment to build your executable. @end itemize @@ -23248,7 +23294,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 id15}@anchor{1d1}@anchor{gnat_ugn/platform_specific_information windows-calling-conventions}@anchor{1d2} +@anchor{gnat_ugn/platform_specific_information id15}@anchor{1d3}@anchor{gnat_ugn/platform_specific_information windows-calling-conventions}@anchor{1d4} @subsubsection Windows Calling Conventions @@ -23293,7 +23339,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{1d3}@anchor{gnat_ugn/platform_specific_information id16}@anchor{1d4} +@anchor{gnat_ugn/platform_specific_information c-calling-convention}@anchor{1d5}@anchor{gnat_ugn/platform_specific_information id16}@anchor{1d6} @subsubsection @code{C} Calling Convention @@ -23335,10 +23381,10 @@ is missing, as in the above example, this parameter is set to be the 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{1d5,,Stdcall Calling Convention}). +convention, @ref{1d7,,Stdcall Calling Convention}). @node Stdcall Calling Convention,Win32 Calling Convention,C Calling Convention,Windows Calling Conventions -@anchor{gnat_ugn/platform_specific_information id17}@anchor{1d6}@anchor{gnat_ugn/platform_specific_information stdcall-calling-convention}@anchor{1d5} +@anchor{gnat_ugn/platform_specific_information id17}@anchor{1d8}@anchor{gnat_ugn/platform_specific_information stdcall-calling-convention}@anchor{1d7} @subsubsection @code{Stdcall} Calling Convention @@ -23435,7 +23481,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 id18}@anchor{1d7}@anchor{gnat_ugn/platform_specific_information win32-calling-convention}@anchor{1d8} +@anchor{gnat_ugn/platform_specific_information id18}@anchor{1d9}@anchor{gnat_ugn/platform_specific_information win32-calling-convention}@anchor{1da} @subsubsection @code{Win32} Calling Convention @@ -23443,7 +23489,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{1d9}@anchor{gnat_ugn/platform_specific_information id19}@anchor{1da} +@anchor{gnat_ugn/platform_specific_information dll-calling-convention}@anchor{1db}@anchor{gnat_ugn/platform_specific_information id19}@anchor{1dc} @subsubsection @code{DLL} Calling Convention @@ -23451,7 +23497,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 id20}@anchor{1db}@anchor{gnat_ugn/platform_specific_information introduction-to-dynamic-link-libraries-dlls}@anchor{1dc} +@anchor{gnat_ugn/platform_specific_information id20}@anchor{1dd}@anchor{gnat_ugn/platform_specific_information introduction-to-dynamic-link-libraries-dlls}@anchor{1de} @subsubsection Introduction to Dynamic Link Libraries (DLLs) @@ -23535,10 +23581,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{1dd,,The Definition File}). +a definition file (see @ref{1df,,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 id21}@anchor{1de}@anchor{gnat_ugn/platform_specific_information using-dlls-with-gnat}@anchor{1cf} +@anchor{gnat_ugn/platform_specific_information id21}@anchor{1e0}@anchor{gnat_ugn/platform_specific_information using-dlls-with-gnat}@anchor{1d1} @subsubsection Using DLLs with GNAT @@ -23629,7 +23675,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{1df}@anchor{gnat_ugn/platform_specific_information id22}@anchor{1e0} +@anchor{gnat_ugn/platform_specific_information creating-an-ada-spec-for-the-dll-services}@anchor{1e1}@anchor{gnat_ugn/platform_specific_information id22}@anchor{1e2} @subsubsection Creating an Ada Spec for the DLL Services @@ -23669,7 +23715,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{1e1}@anchor{gnat_ugn/platform_specific_information id23}@anchor{1e2} +@anchor{gnat_ugn/platform_specific_information creating-an-import-library}@anchor{1e3}@anchor{gnat_ugn/platform_specific_information id23}@anchor{1e4} @subsubsection Creating an Import Library @@ -23683,7 +23729,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{1dd} +@anchor{gnat_ugn/platform_specific_information the-definition-file}@anchor{1df} @subsubheading The Definition File @@ -23731,17 +23777,17 @@ EXPORTS @end table Note that you must specify the correct suffix (@code{@@@var{nn}}) -(see @ref{1d2,,Windows Calling Conventions}) for a Stdcall +(see @ref{1d4,,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{1e3} +@anchor{gnat_ugn/platform_specific_information create-def-file-automatically}@anchor{1e5} @subsubheading Creating a Definition File Automatically You can automatically create the definition file @code{API.def} -(see @ref{1dd,,The Definition File}) from a DLL. +(see @ref{1df,,The Definition File}) from a DLL. For that use the @code{dlltool} program as follows: @quotation @@ -23751,7 +23797,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{1d2,,Windows Calling Conventions}) with stripped @code{@@@var{nn}} +(@ref{1d4,,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. @@ -23775,13 +23821,13 @@ tells you what symbol is expected. You just have to 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{1e4} +@anchor{gnat_ugn/platform_specific_information gnat-style-import-library}@anchor{1e6} @subsubheading GNAT-Style Import Library To create a static import library from @code{API.dll} with the GNAT tools you should create the .def file, then use @code{gnatdll} tool -(see @ref{1e5,,Using gnatdll}) as follows: +(see @ref{1e7,,Using gnatdll}) as follows: @quotation @@ -23797,15 +23843,15 @@ definition file name is @code{xyz.def}, the import library name will be @code{libxyz.a}. Note that in the previous example option @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{1e5,,Using gnatdll} for more information about @code{gnatdll}). +DLL (@ref{1e7,,Using gnatdll} for more information about @code{gnatdll}). @end quotation -@anchor{gnat_ugn/platform_specific_information msvs-style-import-library}@anchor{1e6} +@anchor{gnat_ugn/platform_specific_information msvs-style-import-library}@anchor{1e8} @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{1ce,,Mixed-Language Programming on Windows}). +tools (@ref{1d0,,Mixed-Language Programming on Windows}). To create a Microsoft-style import library for @code{API.dll} you should create the .def file, then build the actual import library using @@ -23829,7 +23875,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{1d0}@anchor{gnat_ugn/platform_specific_information id24}@anchor{1e7} +@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnat-project-files}@anchor{1d2}@anchor{gnat_ugn/platform_specific_information id24}@anchor{1e9} @subsubsection Building DLLs with GNAT Project files @@ -23845,7 +23891,7 @@ when inside the @code{DllMain} routine which is used for auto-initialization of shared libraries, so it is not possible to 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{1e8}@anchor{gnat_ugn/platform_specific_information id25}@anchor{1e9} +@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnat}@anchor{1ea}@anchor{gnat_ugn/platform_specific_information id25}@anchor{1eb} @subsubsection Building DLLs with GNAT @@ -23876,7 +23922,7 @@ $ gcc -shared -shared-libgcc -o api.dll obj1.o obj2.o ... It is important to note that in this case all symbols found in the object files are automatically exported. It is possible to restrict the set of symbols to export by passing to @code{gcc} a definition -file (see @ref{1dd,,The Definition File}). +file (see @ref{1df,,The Definition File}). For example: @example @@ -23914,7 +23960,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{1ea}@anchor{gnat_ugn/platform_specific_information id26}@anchor{1eb} +@anchor{gnat_ugn/platform_specific_information building-dlls-with-gnatdll}@anchor{1ec}@anchor{gnat_ugn/platform_specific_information id26}@anchor{1ed} @subsubsection Building DLLs with gnatdll @@ -23922,8 +23968,8 @@ $ gnatmake main -Iapilib -bargs -shared -largs -Lapilib -lAPI @geindex building Note that it is preferred to use GNAT Project files -(@ref{1d0,,Building DLLs with GNAT Project files}) or the built-in GNAT -DLL support (@ref{1e8,,Building DLLs with GNAT}) or to build DLLs. +(@ref{1d2,,Building DLLs with GNAT Project files}) or the built-in GNAT +DLL support (@ref{1ea,,Building DLLs with GNAT}) or 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 @@ -23939,20 +23985,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{1ec,,Exporting Ada Entities}). You can +(see @ref{1ee,,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{1ed,,Ada DLLs and Elaboration}). The initialization +the Ada code in the DLL (@ref{1ef,,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} generated by @code{gnatbind} to perform the -finalization of the Ada code in the DLL (@ref{1ee,,Ada DLLs and Finalization}). +finalization of the Ada code in the DLL (@ref{1f0,,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. @@ -23962,11 +24008,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{1dd,,The Definition File}). +(@ref{1df,,The Definition File}). @item Finally you must use @code{gnatdll} to produce the DLL and the import -library (@ref{1e5,,Using gnatdll}). +library (@ref{1e7,,Using gnatdll}). @end itemize Note that a relocatable DLL stripped using the @code{strip} @@ -23986,7 +24032,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{1ef} +@anchor{gnat_ugn/platform_specific_information limitations-when-using-ada-dlls-from-ada}@anchor{1f1} @subsubsection Limitations When Using Ada DLLs from Ada @@ -24007,7 +24053,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{1ec}@anchor{gnat_ugn/platform_specific_information id27}@anchor{1f0} +@anchor{gnat_ugn/platform_specific_information exporting-ada-entities}@anchor{1ee}@anchor{gnat_ugn/platform_specific_information id27}@anchor{1f2} @subsubsection Exporting Ada Entities @@ -24107,10 +24153,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{1f1,,Creating the Definition File}). +(@ref{1f3,,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{1ed}@anchor{gnat_ugn/platform_specific_information id28}@anchor{1f2} +@anchor{gnat_ugn/platform_specific_information ada-dlls-and-elaboration}@anchor{1ef}@anchor{gnat_ugn/platform_specific_information id28}@anchor{1f4} @subsubsection Ada DLLs and Elaboration @@ -24128,7 +24174,7 @@ the Ada elaboration routine @code{adainit} generated by the GNAT binder (@ref{a0,,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{1e5,,Using gnatdll}). +tool (@ref{1e7,,Using gnatdll}). When a DLL is loaded, Windows systematically invokes a routine called @code{DllMain}. It would therefore be possible to call @code{adainit} @@ -24141,7 +24187,7 @@ time), which means that the GNAT run-time will deadlock waiting for the 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{1ee}@anchor{gnat_ugn/platform_specific_information id29}@anchor{1f3} +@anchor{gnat_ugn/platform_specific_information ada-dlls-and-finalization}@anchor{1f0}@anchor{gnat_ugn/platform_specific_information id29}@anchor{1f5} @subsubsection Ada DLLs and Finalization @@ -24156,10 +24202,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{1e5,,Using gnatdll}). +(@ref{1e7,,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{1f4}@anchor{gnat_ugn/platform_specific_information id30}@anchor{1f5} +@anchor{gnat_ugn/platform_specific_information creating-a-spec-for-ada-dlls}@anchor{1f6}@anchor{gnat_ugn/platform_specific_information id30}@anchor{1f7} @subsubsection Creating a Spec for Ada DLLs @@ -24217,7 +24263,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{1f1}@anchor{gnat_ugn/platform_specific_information id31}@anchor{1f6} +@anchor{gnat_ugn/platform_specific_information creating-the-definition-file}@anchor{1f3}@anchor{gnat_ugn/platform_specific_information id31}@anchor{1f8} @subsubsection Creating the Definition File @@ -24253,7 +24299,7 @@ EXPORTS @end quotation @node Using gnatdll,,Creating the Definition File,Creating a Spec for Ada DLLs -@anchor{gnat_ugn/platform_specific_information id32}@anchor{1f7}@anchor{gnat_ugn/platform_specific_information using-gnatdll}@anchor{1e5} +@anchor{gnat_ugn/platform_specific_information id32}@anchor{1f9}@anchor{gnat_ugn/platform_specific_information using-gnatdll}@anchor{1e7} @subsubsection Using @code{gnatdll} @@ -24464,7 +24510,7 @@ asks @code{gnatlink} to generate the routines @code{DllMain} and is loaded into memory. @item -@code{gnatdll} uses @code{dlltool} (see @ref{1f8,,Using dlltool}) to build the +@code{gnatdll} uses @code{dlltool} (see @ref{1fa,,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. @@ -24503,7 +24549,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{1f8} +@anchor{gnat_ugn/platform_specific_information using-dlltool}@anchor{1fa} @subsubheading Using @code{dlltool} @@ -24562,7 +24608,7 @@ DLL in the static import library generated by @code{dlltool} with switch @item @code{-k} Kill @code{@@@var{nn}} from exported names -(@ref{1d2,,Windows Calling Conventions} +(@ref{1d4,,Windows Calling Conventions} for a discussion about @code{Stdcall}-style symbols). @end table @@ -24618,7 +24664,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{1f9}@anchor{gnat_ugn/platform_specific_information id33}@anchor{1fa} +@anchor{gnat_ugn/platform_specific_information gnat-and-windows-resources}@anchor{1fb}@anchor{gnat_ugn/platform_specific_information id33}@anchor{1fc} @subsubsection GNAT and Windows Resources @@ -24713,7 +24759,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{1fb}@anchor{gnat_ugn/platform_specific_information id34}@anchor{1fc} +@anchor{gnat_ugn/platform_specific_information building-resources}@anchor{1fd}@anchor{gnat_ugn/platform_specific_information id34}@anchor{1fe} @subsubsection Building Resources @@ -24733,7 +24779,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{1fd}@anchor{gnat_ugn/platform_specific_information id35}@anchor{1fe} +@anchor{gnat_ugn/platform_specific_information compiling-resources}@anchor{1ff}@anchor{gnat_ugn/platform_specific_information id35}@anchor{200} @subsubsection Compiling Resources @@ -24775,7 +24821,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 id36}@anchor{1ff}@anchor{gnat_ugn/platform_specific_information using-resources}@anchor{200} +@anchor{gnat_ugn/platform_specific_information id36}@anchor{201}@anchor{gnat_ugn/platform_specific_information using-resources}@anchor{202} @subsubsection Using Resources @@ -24795,7 +24841,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{201}@anchor{gnat_ugn/platform_specific_information using-gnat-dlls-from-microsoft-visual-studio-applications}@anchor{202} +@anchor{gnat_ugn/platform_specific_information using-gnat-dll-from-msvs}@anchor{203}@anchor{gnat_ugn/platform_specific_information using-gnat-dlls-from-microsoft-visual-studio-applications}@anchor{204} @subsubsection Using GNAT DLLs from Microsoft Visual Studio Applications @@ -24829,7 +24875,7 @@ $ gprbuild -p mylib.gpr @item Produce a .def file for the symbols you need to interface with, either by hand or automatically with possibly some manual adjustments -(see @ref{1e3,,Creating Definition File Automatically}): +(see @ref{1e5,,Creating Definition File Automatically}): @end enumerate @quotation @@ -24846,7 +24892,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{1e6,,MSVS-Style Import Library}): +Create the Microsoft-style import library (see @ref{1e8,,MSVS-Style Import Library}): @end enumerate @quotation @@ -24888,7 +24934,7 @@ or copy the DLL into into the directory containing the .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{203}@anchor{gnat_ugn/platform_specific_information id37}@anchor{204} +@anchor{gnat_ugn/platform_specific_information debugging-a-dll}@anchor{205}@anchor{gnat_ugn/platform_specific_information id37}@anchor{206} @subsubsection Debugging a DLL @@ -24926,7 +24972,7 @@ 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 id38}@anchor{205}@anchor{gnat_ugn/platform_specific_information program-and-dll-both-built-with-gcc-gnat}@anchor{206} +@anchor{gnat_ugn/platform_specific_information id38}@anchor{207}@anchor{gnat_ugn/platform_specific_information program-and-dll-both-built-with-gcc-gnat}@anchor{208} @subsubsection Program and DLL Both Built with GCC/GNAT @@ -24936,7 +24982,7 @@ the process. Let’s suppose here that the main procedure is named @code{ada_main} and that in the DLL there is an entry point named @code{ada_dll}. -The DLL (@ref{1dc,,Introduction to Dynamic Link Libraries (DLLs)}) and +The DLL (@ref{1de,,Introduction to Dynamic Link Libraries (DLLs)}) and program must have been built with the debugging information (see GNAT -g switch). Here are the step-by-step instructions for debugging it: @@ -24976,7 +25022,7 @@ you can use the standard approach to debug the whole program (@ref{14d,,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 id39}@anchor{207}@anchor{gnat_ugn/platform_specific_information program-built-with-foreign-tools-and-dll-built-with-gcc-gnat}@anchor{208} +@anchor{gnat_ugn/platform_specific_information id39}@anchor{209}@anchor{gnat_ugn/platform_specific_information program-built-with-foreign-tools-and-dll-built-with-gcc-gnat}@anchor{20a} @subsubsection Program Built with Foreign Tools and DLL Built with GCC/GNAT @@ -24993,7 +25039,7 @@ example some C code built with Microsoft Visual C) and that there is a DLL named @code{test.dll} containing an Ada entry point named @code{ada_dll}. -The DLL (see @ref{1dc,,Introduction to Dynamic Link Libraries (DLLs)}) must have +The DLL (see @ref{1de,,Introduction to Dynamic Link Libraries (DLLs)}) must have been built with debugging information (see the GNAT @code{-g} option). @subsubheading Debugging the DLL Directly @@ -25132,7 +25178,7 @@ approach to debug a program as described in @ref{14d,,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 id40}@anchor{209}@anchor{gnat_ugn/platform_specific_information setting-stack-size-from-gnatlink}@anchor{127} +@anchor{gnat_ugn/platform_specific_information id40}@anchor{20b}@anchor{gnat_ugn/platform_specific_information setting-stack-size-from-gnatlink}@anchor{127} @subsubsection Setting Stack Size from @code{gnatlink} @@ -25175,7 +25221,7 @@ because the comma is a separator for this option. @end itemize @node Setting Heap Size from gnatlink,,Setting Stack Size from gnatlink,Mixed-Language Programming on Windows -@anchor{gnat_ugn/platform_specific_information id41}@anchor{20a}@anchor{gnat_ugn/platform_specific_information setting-heap-size-from-gnatlink}@anchor{128} +@anchor{gnat_ugn/platform_specific_information id41}@anchor{20c}@anchor{gnat_ugn/platform_specific_information setting-heap-size-from-gnatlink}@anchor{128} @subsubsection Setting Heap Size from @code{gnatlink} @@ -25208,7 +25254,7 @@ because the comma is a separator for this option. @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{20b}@anchor{gnat_ugn/platform_specific_information windows-specific-add-ons}@anchor{20c} +@anchor{gnat_ugn/platform_specific_information win32-specific-addons}@anchor{20d}@anchor{gnat_ugn/platform_specific_information windows-specific-add-ons}@anchor{20e} @subsection Windows Specific Add-Ons @@ -25221,7 +25267,7 @@ This section describes the Windows specific add-ons. @end menu @node Win32Ada,wPOSIX,,Windows Specific Add-Ons -@anchor{gnat_ugn/platform_specific_information id42}@anchor{20d}@anchor{gnat_ugn/platform_specific_information win32ada}@anchor{20e} +@anchor{gnat_ugn/platform_specific_information id42}@anchor{20f}@anchor{gnat_ugn/platform_specific_information win32ada}@anchor{210} @subsubsection Win32Ada @@ -25252,7 +25298,7 @@ gprbuild p.gpr @end quotation @node wPOSIX,,Win32Ada,Windows Specific Add-Ons -@anchor{gnat_ugn/platform_specific_information id43}@anchor{20f}@anchor{gnat_ugn/platform_specific_information wposix}@anchor{210} +@anchor{gnat_ugn/platform_specific_information id43}@anchor{211}@anchor{gnat_ugn/platform_specific_information wposix}@anchor{212} @subsubsection wPOSIX @@ -25285,7 +25331,7 @@ gprbuild p.gpr @end quotation @node Mac OS Topics,,Microsoft Windows Topics,Platform-Specific Information -@anchor{gnat_ugn/platform_specific_information id44}@anchor{211}@anchor{gnat_ugn/platform_specific_information mac-os-topics}@anchor{212} +@anchor{gnat_ugn/platform_specific_information id44}@anchor{213}@anchor{gnat_ugn/platform_specific_information mac-os-topics}@anchor{214} @section Mac OS Topics @@ -25300,7 +25346,7 @@ platform. @end menu @node Codesigning the Debugger,,,Mac OS Topics -@anchor{gnat_ugn/platform_specific_information codesigning-the-debugger}@anchor{213} +@anchor{gnat_ugn/platform_specific_information codesigning-the-debugger}@anchor{215} @subsection Codesigning the Debugger @@ -25381,7 +25427,7 @@ the location where you installed GNAT. Also, be sure that users 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{214}@anchor{gnat_ugn/example_of_binder_output example-of-binder-output-file}@anchor{e}@anchor{gnat_ugn/example_of_binder_output id1}@anchor{215} +@anchor{gnat_ugn/example_of_binder_output doc}@anchor{216}@anchor{gnat_ugn/example_of_binder_output example-of-binder-output-file}@anchor{e}@anchor{gnat_ugn/example_of_binder_output id1}@anchor{217} @chapter Example of Binder Output File @@ -26133,7 +26179,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{216}@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order-handling-in-gnat}@anchor{f}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id1}@anchor{217} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat doc}@anchor{218}@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order-handling-in-gnat}@anchor{f}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id1}@anchor{219} @chapter Elaboration Order Handling in GNAT @@ -26163,7 +26209,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{218}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id2}@anchor{219} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-code}@anchor{21a}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id2}@anchor{21b} @section Elaboration Code @@ -26311,7 +26357,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{21a}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id3}@anchor{21b} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-order}@anchor{21c}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id3}@anchor{21d} @section Elaboration Order @@ -26480,7 +26526,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{21c}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id4}@anchor{21d} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat checking-the-elaboration-order}@anchor{21e}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id4}@anchor{21f} @section Checking the Elaboration Order @@ -26541,7 +26587,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{21e}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id5}@anchor{21f} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat controlling-the-elaboration-order-in-ada}@anchor{220}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id5}@anchor{221} @section Controlling the Elaboration Order in Ada @@ -26869,7 +26915,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{220}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id6}@anchor{221} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat controlling-the-elaboration-order-in-gnat}@anchor{222}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id6}@anchor{223} @section Controlling the Elaboration Order in GNAT @@ -26999,7 +27045,7 @@ The dynamic, legacy, and static models can be relaxed using compiler switch 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{222}@anchor{gnat_ugn/elaboration_order_handling_in_gnat mixing-elaboration-models}@anchor{223} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id7}@anchor{224}@anchor{gnat_ugn/elaboration_order_handling_in_gnat mixing-elaboration-models}@anchor{225} @section Mixing Elaboration Models @@ -27046,7 +27092,7 @@ warning: "y.ads" which has static elaboration checks The warnings can be suppressed by 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{224}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id8}@anchor{225} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat abe-diagnostics}@anchor{226}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id8}@anchor{227} @section ABE Diagnostics @@ -27153,7 +27199,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{226}@anchor{gnat_ugn/elaboration_order_handling_in_gnat spark-diagnostics}@anchor{227} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id9}@anchor{228}@anchor{gnat_ugn/elaboration_order_handling_in_gnat spark-diagnostics}@anchor{229} @section SPARK Diagnostics @@ -27179,7 +27225,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{228}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id10}@anchor{229} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-circularities}@anchor{22a}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id10}@anchor{22b} @section Elaboration Circularities @@ -27279,7 +27325,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{22a}@anchor{gnat_ugn/elaboration_order_handling_in_gnat resolving-elaboration-circularities}@anchor{22b} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id11}@anchor{22c}@anchor{gnat_ugn/elaboration_order_handling_in_gnat resolving-elaboration-circularities}@anchor{22d} @section Resolving Elaboration Circularities @@ -27551,7 +27597,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{22c}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id12}@anchor{22d} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat elaboration-related-compiler-switches}@anchor{22e}@anchor{gnat_ugn/elaboration_order_handling_in_gnat id12}@anchor{22f} @section Elaboration-related Compiler Switches @@ -27732,7 +27778,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{22e}@anchor{gnat_ugn/elaboration_order_handling_in_gnat summary-of-procedures-for-elaboration-control}@anchor{22f} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id13}@anchor{230}@anchor{gnat_ugn/elaboration_order_handling_in_gnat summary-of-procedures-for-elaboration-control}@anchor{231} @section Summary of Procedures for Elaboration Control @@ -27790,7 +27836,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{230}@anchor{gnat_ugn/elaboration_order_handling_in_gnat inspecting-the-chosen-elaboration-order}@anchor{231} +@anchor{gnat_ugn/elaboration_order_handling_in_gnat id14}@anchor{232}@anchor{gnat_ugn/elaboration_order_handling_in_gnat inspecting-the-chosen-elaboration-order}@anchor{233} @section Inspecting the Chosen Elaboration Order @@ -27933,7 +27979,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{232}@anchor{gnat_ugn/inline_assembler id1}@anchor{233}@anchor{gnat_ugn/inline_assembler inline-assembler}@anchor{10} +@anchor{gnat_ugn/inline_assembler doc}@anchor{234}@anchor{gnat_ugn/inline_assembler id1}@anchor{235}@anchor{gnat_ugn/inline_assembler inline-assembler}@anchor{10} @chapter Inline Assembler @@ -27992,7 +28038,7 @@ and with 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{234}@anchor{gnat_ugn/inline_assembler id2}@anchor{235} +@anchor{gnat_ugn/inline_assembler basic-assembler-syntax}@anchor{236}@anchor{gnat_ugn/inline_assembler id2}@anchor{237} @section Basic Assembler Syntax @@ -28108,7 +28154,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{236}@anchor{gnat_ugn/inline_assembler id3}@anchor{237} +@anchor{gnat_ugn/inline_assembler a-simple-example-of-inline-assembler}@anchor{238}@anchor{gnat_ugn/inline_assembler id3}@anchor{239} @section A Simple Example of Inline Assembler @@ -28257,7 +28303,7 @@ If there are no errors, @code{as} will generate an object file @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{238}@anchor{gnat_ugn/inline_assembler output-variables-in-inline-assembler}@anchor{239} +@anchor{gnat_ugn/inline_assembler id4}@anchor{23a}@anchor{gnat_ugn/inline_assembler output-variables-in-inline-assembler}@anchor{23b} @section Output Variables in Inline Assembler @@ -28624,7 +28670,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{23a}@anchor{gnat_ugn/inline_assembler input-variables-in-inline-assembler}@anchor{23b} +@anchor{gnat_ugn/inline_assembler id5}@anchor{23c}@anchor{gnat_ugn/inline_assembler input-variables-in-inline-assembler}@anchor{23d} @section Input Variables in Inline Assembler @@ -28713,7 +28759,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{23c}@anchor{gnat_ugn/inline_assembler inlining-inline-assembler-code}@anchor{23d} +@anchor{gnat_ugn/inline_assembler id6}@anchor{23e}@anchor{gnat_ugn/inline_assembler inlining-inline-assembler-code}@anchor{23f} @section Inlining Inline Assembler Code @@ -28784,7 +28830,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{23e}@anchor{gnat_ugn/inline_assembler other-asm-functionality}@anchor{23f} +@anchor{gnat_ugn/inline_assembler id7}@anchor{240}@anchor{gnat_ugn/inline_assembler other-asm-functionality}@anchor{241} @section Other @code{Asm} Functionality @@ -28799,7 +28845,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{240}@anchor{gnat_ugn/inline_assembler the-clobber-parameter}@anchor{241} +@anchor{gnat_ugn/inline_assembler id8}@anchor{242}@anchor{gnat_ugn/inline_assembler the-clobber-parameter}@anchor{243} @subsection The @code{Clobber} Parameter @@ -28863,7 +28909,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{242}@anchor{gnat_ugn/inline_assembler the-volatile-parameter}@anchor{243} +@anchor{gnat_ugn/inline_assembler id9}@anchor{244}@anchor{gnat_ugn/inline_assembler the-volatile-parameter}@anchor{245} @subsection The @code{Volatile} Parameter @@ -28899,7 +28945,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{244}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{245} +@anchor{share/gnu_free_documentation_license doc}@anchor{246}@anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{247} @chapter GNU Free Documentation License