From patchwork Mon Jul 10 12:43:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 117888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4996590vqx; Mon, 10 Jul 2023 05:44:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFdtJT7Rss2OH9WAPahtK1NvX+j0HevkesU0dQwDjf+JtcQBrl2yAvagtChJIXqgdVR0mAr X-Received: by 2002:a2e:a312:0:b0:2b6:ccd6:3eae with SMTP id l18-20020a2ea312000000b002b6ccd63eaemr9004305lje.17.1688993071781; Mon, 10 Jul 2023 05:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688993071; cv=none; d=google.com; s=arc-20160816; b=EMVomjccFDz1P058xHAZ/glO+blhSET2hpurPpxUsB10AFJaCEBcbUJg+UX94oNRyD UKzdLopbpql7Qecbjt1KNBRpWhcs97qfeD62CllcanKTAKb/ggROz6/Kj5zWQ2N7PAXY S8uhsWqnngW7Z234kaAmaTzxZ+VXIUEPlLnQVUEQsxC/ubbUWu2Ec+Iv+0S0N6iTecTH rxR5/GNsHopT4654tMBmleq7+odbjIKyrsfDq90E9e9nSdL/vR2PeTwT9On+/IuZIJjg Do5nTKU/6sbw5ff0vX3+On7LpRTKJjdot27IZS3yAoVSEnJsIQ4j4x1DERoNM+UIYXYo XeVw== 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=hGWPI/1ZrpNcuGZni/n2jwpH76K6s0U7aE/UlVTuzrM=; fh=3I5BNKWyYtN8OAcHgwE9DP+SPMWTdvCyaas7z1IN2Vo=; b=rh4jZep5gXYXjZoswZFasOapnpbsMl0lYyloL/ze8z1coDaZ5sTbuOiSTIvBT5F8OO dGv4dH+zDnWrnxNPiaMfVV3NYGYgv3wTPKb6+JarTzXZLIEhh8xbA69itdzymrrki3cH bKWSYmLSMXpMSfgDu0aScjo7ef8qvCAarQlyktfMhXq7HWZJG4JcmLHDlUXb+iZ0PY+T kxkF4OR9v++pCGWdeot8leZqiJvzyyf+FvL5tHl/1sJeDsxTZCWUmfPZ5kSP3e2fQsjU LzPpm0LBYu+l/Kq7z4PDGvWeIx3lCxYoxl1/XFoERbRNammIqvE8Q0weBe9+fB4e2YYQ GeNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=otNEnv1+; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g11-20020a1709064e4b00b0098e31cd141dsi8424802ejw.744.2023.07.10.05.44.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 05:44:31 -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=otNEnv1+; 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 ABD323857C44 for ; Mon, 10 Jul 2023 12:44:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABD323857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688993070; bh=hGWPI/1ZrpNcuGZni/n2jwpH76K6s0U7aE/UlVTuzrM=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=otNEnv1+IgZ0suzYgtrXMcXkSbqsY/Jy3wxpws6xxrHMnmv8z6udapPjYHKoKXI3U d3O+ybaJ//X/WtXgT+g061Jy/+9/b5sKecl7PP6hywxLkpi2Z2o3CzmyZYvfp3GSfJ mUw2GC/2ZEu9bYF/JFZSPltoCkLPivUVkx+MmXBU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 9E3823858CDA for ; Mon, 10 Jul 2023 12:43:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E3823858CDA Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so44332505e9.1 for ; Mon, 10 Jul 2023 05:43:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688993027; x=1691585027; 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=hGWPI/1ZrpNcuGZni/n2jwpH76K6s0U7aE/UlVTuzrM=; b=OHN8yctVGju6jKfX6yAuBp57z1VtOiTdOwOfh+9fwpodAvYKv9g3xSfTbVprMRyfWF TuQUXL5cf1NrUZtuykRp/XlrAlRqb91e73CKhU0d2r4Ohb49PoDsuzKwQNVmaloIHXw3 G8e2nQuIQmJq2ENh8JUrFA5MWtaTvAbatsH7cfDajGLi1b2du0m705B+Fp/vM6LQ66kF OfjUupkbEXAs+TlCG3T4uMnQErtsrN8lTGsEvdTbcsuK2APVyhvWux4hW+Po8Ygl8YVK p1L4WaIrjHhu8y7T9x7d9oospaP9YpWT1HFfR5q92BBz5X4ZBIqKsWBBUXl9yfIbyMQT G/Sw== X-Gm-Message-State: ABy/qLYsHrLYe5WjsJQtxFRlGCatadtcvvQne106nR8SIuBYQfjOOLIH wFvWWb8jVz18Z6wu7NMTmOvfjskJ2pzySK+J+jfalg== X-Received: by 2002:a05:600c:257:b0:3fb:a102:6d7a with SMTP id 23-20020a05600c025700b003fba1026d7amr10399993wmj.28.1688993027341; Mon, 10 Jul 2023 05:43:47 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:a197:d20:e621:dddf]) by smtp.gmail.com with ESMTPSA id z13-20020a7bc7cd000000b003fc0062f0f8sm9208062wmk.9.2023.07.10.05.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 05:43:46 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Alexandre Oliva Subject: [COMMITTED] ada: Add leafy mode for zero-call-used-regs Date: Mon, 10 Jul 2023 14:43:37 +0200 Message-Id: <20230710124337.2262944-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: INBOX X-GMAIL-THRID: 1771037599450200138 X-GMAIL-MSGID: 1771037599450200138 From: Alexandre Oliva Document leafy mode. gcc/ada/ * doc/gnat_rm/security_hardening_features.rst (Register Scrubbing): Document leafy mode. * gnat_rm.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/doc/gnat_rm/security_hardening_features.rst | 6 ++++++ gcc/ada/gnat_rm.texi | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/ada/doc/gnat_rm/security_hardening_features.rst b/gcc/ada/doc/gnat_rm/security_hardening_features.rst index ad165cd6849..14328598c33 100644 --- a/gcc/ada/doc/gnat_rm/security_hardening_features.rst +++ b/gcc/ada/doc/gnat_rm/security_hardening_features.rst @@ -34,6 +34,12 @@ subprograms. pragma Machine_Attribute (Bar, "zero_call_used_regs", "all"); -- Before returning, Bar scrubs all call-clobbered registers. + function Baz return Integer; + pragma Machine_Attribute (Bar, "zero_call_used_regs", "leafy"); + -- Before returning, Bar scrubs call-clobbered registers, either + -- those it uses itself, if it can be identified as a leaf + -- function, or all of them otherwise. + For usage and more details on the command-line option, on the ``zero_call_used_regs`` attribute, and on their use with other diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index b28e6ebfffa..817ba0b9108 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT Reference Manual , Jul 04, 2023 +GNAT Reference Manual , Jul 10, 2023 AdaCore @@ -29191,6 +29191,12 @@ pragma Machine_Attribute (Foo, "zero_call_used_regs", "used"); function Bar return Integer; pragma Machine_Attribute (Bar, "zero_call_used_regs", "all"); -- Before returning, Bar scrubs all call-clobbered registers. + +function Baz return Integer; +pragma Machine_Attribute (Bar, "zero_call_used_regs", "leafy"); +-- Before returning, Bar scrubs call-clobbered registers, either +-- those it uses itself, if it can be identified as a leaf +-- function, or all of them otherwise. @end example For usage and more details on the command-line option, on the