From patchwork Thu Dec 15 19:25:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 33799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp558580wrn; Thu, 15 Dec 2022 11:26:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXsKp+JCnAOH49RaU6MQ0yPQJem9/L1fr/ZRFQnL0odEegpbIXZwDA76iUAcg5rareRxhAls X-Received: by 2002:a17:907:20cc:b0:7c4:fb2c:7a6b with SMTP id qq12-20020a17090720cc00b007c4fb2c7a6bmr4362775ejb.58.1671132414388; Thu, 15 Dec 2022 11:26:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671132414; cv=pass; d=google.com; s=arc-20160816; b=ukONHmxma6lHuIB8N4jVQXuOxQBmj6EhsO52bO9RbHfat0MUXUNazmTBhOivdtBIfS lFkL9iAKTLwGy8kAMJvyBZL+ZdbLnfbD5szff7suPQkJFm+L3fPdAn13E0ri32AienFT sNwyXb7Z+PgvOX5B9wy0NrBEO+jwvnIG7masg/wVytuNieemESrA8oIHxerLJJryL+oV GOfmz08Qwjwm67Z0kO/qSreKjTJ8rxtgkCjJAeq6Itf/HLuNxO7crorOTTIcsskP0Q3b me04cBiGmYU5bT+oT0YueBO41WBLMiwU94wP8pNExEILHDwFpCWV8Nv63/5w2QQ/RSBt IgDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=hEy7x56POoNmd/CkOwlC30UPGCT+8AcO7lVkjK2PcF8=; b=cJ+RllgWxgAaD03xmdnxoZSyHLrpMHCYJXGHg+Z/nHlcTbbGVKUAIgj/kUemBuTr02 gm2qyX/l1Ko5lVt9CODM2H5RXH71Sk/fy0y5R3l5H5BZHxS1C/E9kcmvh86EICBdJ7w0 C0btXlGs1OBpxeEyws69YC2SAwPNKFmNucxXKc7UgzpyuAsOX8emNf9yn4BSd/iOA+nn C5aFjDX/dLFQd9Lr+q303TO2fktq8He7B3FWTF7pSMVnrb6kjJVj1s/fPw3Zv8dgDeot 5Tmd4/4/qhyB2xhTtdf+UXAZVV/iYlZ8qat9ApmYbNf6hV+zLIZRUuSRwZD0pV3k9o0+ 0nzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gotplt.org header.s=dreamhost header.b=R6gpEi2H; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g16-20020a1709065d1000b007c14f28b652si13949473ejt.851.2022.12.15.11.26.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:26:54 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gotplt.org header.s=dreamhost header.b=R6gpEi2H; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6ED353817747 for ; Thu, 15 Dec 2022 19:26:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from bumble.birch.relay.mailchannels.net (bumble.birch.relay.mailchannels.net [23.83.209.25]) by sourceware.org (Postfix) with ESMTPS id 261263898506 for ; Thu, 15 Dec 2022 19:26:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 261263898506 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 348D86C20CF for ; Thu, 15 Dec 2022 19:26:22 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 86BAD6C1FD5 for ; Thu, 15 Dec 2022 19:26:21 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1671132381; a=rsa-sha256; cv=none; b=1XGXO8uSKN8B8MODeXnARYSVgaSoWBjmbDLAcdAso7IGAv57o4dj0eyWz9u8rSoaMKvtWv /xg7SVt14jE44kuHqg939BuZlRvIkqb/y9gG1UupaeIGJbxLi5QjvnwVGYMC4I5HO1Fy/Q 5l453GbmbUOhg1pra+DprAv9bwq1tDwVDEurUQUqMTKC6TWGXDA1exUinRXtvnoZHkGeDI xGCbwrXSbUdheIZMRUUyn6BDHGDIYbjR9tq4wUCkjD3iJqLUDiq4I83mACyjwDHUZr+T48 x3mac3d8Uv4XH6h3XswScBfHwWqSHYqrzD+7uWg9oSSY7r2yYOGd+ijawWtYCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1671132381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=hEy7x56POoNmd/CkOwlC30UPGCT+8AcO7lVkjK2PcF8=; b=FWGr6OkmusoW5bC5Gb6O+IX6GxGFekxm9ylBdVeYfEOvKjGoKGsnLWK4eN5yvtgRfo7icd NB8npRrurmnC0MOL9OtnbBXthSsnJ53AQfQpKYO+XWvwDIq/uCoyoxJCJdyjTb68nyfDDE +8b+Nk0ipdGReDkgMa7CoZp/7WNPNaqzw6QvpkAus4ynMZ8GemiJJW6JeRgVlPMoqmIvZh Au2ZYs+Z7NiyCxCJtfmPyWCEPMaWs3Ow+rWuajUartEXXMHD9JHfkrJ4DCh7QzBbJx89mP 4LLD9keNpE3BJrdzea6bKbUivsTfusjx6hOI6jXzmMMGrIpvQK9np8BnnWgv9w== ARC-Authentication-Results: i=1; rspamd-d48c5ddb-nj59r; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Wiry-Decisive: 180d048014ebdbb8_1671132381789_1778118458 X-MC-Loop-Signature: 1671132381789:1814365090 X-MC-Ingress-Time: 1671132381789 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.126.30.43 (trex/6.7.1); Thu, 15 Dec 2022 19:26:21 +0000 Received: from fedora.redhat.com (bras-base-toroon4834w-grc-23-76-68-24-147.dsl.bell.ca [76.68.24.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4NY2K905KCz1l for ; Thu, 15 Dec 2022 11:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1671132381; bh=hEy7x56POoNmd/CkOwlC30UPGCT+8AcO7lVkjK2PcF8=; h=From:To:Subject:Date:Content-Transfer-Encoding; b=R6gpEi2HBtqEL++0tIXIw60sqozxd9aahv8viljm8g0TBTjTFSsEShCgrhWt4zlri mtppRAjHo1F8dYr8t0i55rAQHp24doGWR5E6VnBsZkMpoocPjQG1lC2ZRNbFP7g5S9 TsjShEtkpqGa6GiusY4BKOH2RxQgpwM2o/kH6NKqM9xkLamBdzEr9aRa0+ClQNXe4W L8nVjtAgCNw3vz4iMVdtMWj1o3ijAbnCqdvq0gz2RZJmfb7BDAsQLt5ovvVJSrKTT5 T+hw9+162BhG9pRK3T8KRMo0oRnvgJSQgbjrVBVY8F7VwfDv6gH+nAXOU2LSG9qvwU Mm49lNvNPs3gQ== From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105043: Object Size Checking docs cleanup Date: Thu, 15 Dec 2022 14:25:48 -0500 Message-Id: <20221215192548.1999425-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3037.1 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 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: , 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?1752309342463091399?= X-GMAIL-MSGID: =?utf-8?q?1752309342463091399?= Break the _FORTIFY_SOURCE-specific builtins out into a separate subsection from Object Size Checking built-ins and mention _FORTIFY_SOURCE in there so that the link between the object size checking builtins, the helper builtins (e.g. __builtin___memcpy_chk) and _FORTIFY_SOURCE is clearer. gcc/ChangeLog: PR tree-optimization/105043 * doc/extend.texi (Object Size Checking): Split out into two subsections and mention _FORTIFY_SOURCE. Signed-off-by: Siddhesh Poyarekar --- gcc/doc/extend.texi | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 608ff54f845..8cff7dd65dd 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -12796,7 +12796,9 @@ __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE); @end smallexample @node Object Size Checking -@section Object Size Checking Built-in Functions +@section Object Size Checking + +@subsection Object Size Checking Built-in Functions @findex __builtin_object_size @findex __builtin_dynamic_object_size @findex __builtin___memcpy_chk @@ -12878,11 +12880,17 @@ which objects @var{ptr} points to at compile time are the same as in the case of @code{__builtin_object_size}. @end deftypefn -There are built-in functions added for many common string operation -functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk} -built-in is provided. This built-in has an additional last argument, -which is the number of bytes remaining in the object the @var{dest} -argument points to or @code{(size_t) -1} if the size is not known. +@subsection Object Size Checking and Source Fortification + +Hardening of function calls using the @code{_FORTIFY_SOURCE} macro is +one of the key uses of the object size checking built-in functions. To +make implementation of these features more convenient and improve +optimization and diagnostics, there are built-in functions added for +many common string operation functions, e.g., for @code{memcpy} +@code{__builtin___memcpy_chk} built-in is provided. This built-in has +an additional last argument, which is the number of bytes remaining in +the object the @var{dest} argument points to or @code{(size_t) -1} if +the size is not known. The built-in functions are optimized into the normal string functions like @code{memcpy} if the last argument is @code{(size_t) -1} or if