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: 1716255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha256 header.s=dreamhost header.b=R6gpEi2H; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NY2KX6W8yz23ym for ; Fri, 16 Dec 2022 06:26:39 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 108F13817F82 for ; Thu, 15 Dec 2022 19:26:37 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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