From patchwork Tue Aug 9 15:38:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:20da:b0:2d3:3019:e567 with SMTP id n26csp2596071pxc; Tue, 9 Aug 2022 08:39:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR4PvLNFfhb09uWNUm+VLaaYfnOgU+DwyyXoVsXIwJRcIfpOqqT0uorYSducSnXVTbz6Fk/n X-Received: by 2002:a17:907:2e01:b0:730:a098:7257 with SMTP id ig1-20020a1709072e0100b00730a0987257mr17576769ejc.705.1660059553848; Tue, 09 Aug 2022 08:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660059553; cv=none; d=google.com; s=arc-20160816; b=VlCxsZ4/XhJnfabPHlHdCUeIjr44Kjvbau76xrOlJUFDsfmTo2+jvxdTanxwnd6GZv l4IHbK31/0KU0WQasqqQMlYSX8Ij2PEx3NZfaySVy5xWVuCPM3DYif222u8XsHB60fI2 5roBOeu76Dtc7XgQXRBPMpGc42erOLqg9t3tbKT9cfzDd88jqJLz6JJzobHUN9fTEcLN kf3SM6atGrq7dGlRWmHg157uKKXCphkWxJplzILsDpcIGx37VaRg84qvWUqG2uwC8qsK CDkBmyhlArb4imXJ3RmErCX13hfjUrfW/3kASejUYprOcnsy22uCy6ac/53hyoY+YwMS Vm9A== 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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=17/DXzMyHBIgP2zcu5NKNX/zz7nPVpHJ28oOOnDf5tA=; b=tfhRHwKe1B+zMiEJorFbBqu6Tq48tzQzVp6J1ekRSRPxFU3seSmREPp25APmMRdG28 FU0IpbItfFRyK+JlYPTRHLZ6Wwshq9uVFIPRg1qidH+jmd0Ez8PWJ1Ttmh5YmlLmqAFc cFurK6JaCot657kvkJNp3lUbC7P7fLHgjmj++87W3dwlKvQ1eqNdwaZUyKXHC9m9XVO8 NoYDDLmRRpZLvrxfkoLy4vwRCWRM0T7tgjhxa/HO8V/dY11G7EPGpO3rgZfklZaag9Ex foXF0JWciLPVI14QWfc3u24iFupHtr4Q4L5Y/G1RoG33LKhdpCzX+VVIay/HOJLKChbs PMhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MIi9TkFg; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id us3-20020a170906bfc300b0072f0356abc7si1947147ejb.109.2022.08.09.08.39.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 08:39:13 -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=MIi9TkFg; 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 AF5DA3856247 for ; Tue, 9 Aug 2022 15:39:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF5DA3856247 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660059552; bh=17/DXzMyHBIgP2zcu5NKNX/zz7nPVpHJ28oOOnDf5tA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MIi9TkFgy+/Ay8dD4QXrDYyX+/kEO19G1eYyQtxKMxfhRRptFjsGEcH+cLjWj3S7W auZY/e6gCSXcrQq6tZm/dHTCiXYmbWYZIMCURNUzZsP9321Qnskeb95ImtF7c5JAbD o6Phm8WKvHY+d4RnDudbbmm5HNIVV+oCul+cYM9g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 46B7F3856DCA for ; Tue, 9 Aug 2022 15:38:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 46B7F3856DCA Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-327-f2qIGo7zMceBY0m1Vkfscg-1; Tue, 09 Aug 2022 11:38:29 -0400 X-MC-Unique: f2qIGo7zMceBY0m1Vkfscg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12B5529AA2EB for ; Tue, 9 Aug 2022 15:38:28 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.16.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id E161BC15BA1; Tue, 9 Aug 2022 15:38:27 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] docs: add notes on which functions -fanalyzer has hardcoded knowledge of Date: Tue, 9 Aug 2022 11:38:25 -0400 Message-Id: <20220809153825.3031775-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm 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?1740698606997585271?= X-GMAIL-MSGID: =?utf-8?q?1740698606997585271?= Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2003-g16877cc2006ede. gcc/ChangeLog: * doc/invoke.texi (Static Analyzer Options): Add notes on which functions the analyzer has hardcoded knowledge of. Signed-off-by: David Malcolm --- gcc/doc/invoke.texi | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 92f7aaead74..a17c059d515 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10281,6 +10281,87 @@ See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Unini @end table +The analyzer has hardcoded knowledge about the behavior of the following +memory-management functions: + +@itemize @bullet +@item @code{alloca} +@item The built-in functions @code{__builtin_alloc}, +@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, +@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, +@code{__builtin_memcpy_chk}, @code{__builtin_memset}, +@code{__builtin_memset_chk}, @code{__builtin_realloc}, +@code{__builtin_stack_restore}, and @code{__builtin_stack_save} +@item @code{calloc} +@item @code{free} +@item @code{malloc} +@item @code{memset} +@item @code{operator delete} +@item @code{operator delete []} +@item @code{operator new} +@item @code{operator new []} +@item @code{realloc} +@item @code{strdup} +@item @code{strndup} +@end itemize + +of the following functions for working with file descriptors: + +@itemize @bullet +@item @code{open} +@item @code{close} +@item @code{creat} +@item @code{dup}, @code{dup2} and @code{dup3} +@item @code{read} +@item @code{write} +@end itemize + +of the following functions for working with @code{} streams: +@itemize @bullet +@item The built-in functions @code{__builtin_fprintf}, +@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, +@code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, +@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, +@code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, +@code{__builtin_printf_unlocked}, @code{__builtin_putc}, +@code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, +@code{__builtin_putc_unlocked}, @code{__builtin_puts}, +@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and +@code{__builtin_vprintf} +@item @code{fopen} +@item @code{fclose} +@item @code{fgets} +@item @code{fgets_unlocked} +@item @code{fread} +@item @code{getchar} +@item @code{fprintf} +@item @code{printf} +@item @code{fwrite} +@end itemize + +and of the following functions: + +@itemize @bullet +@item The built-in functions @code{__builtin_expect}, +@code{__builtin_expect_with_probability}, @code{__builtin_strchr}, +@code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, +@code{__builtin_strlen}, @code{__builtin_va_copy}, and +@code{__builtin_va_start} +@item The GNU extensions @code{error} and @code{error_at_line} +@item @code{getpass} +@item @code{longjmp} +@item @code{putenv} +@item @code{setjmp} +@item @code{siglongjmp} +@item @code{signal} +@item @code{sigsetjmp} +@item @code{strchr} +@item @code{strlen} +@end itemize + +In addition, various functions with an @code{__analyzer_} prefix have +special meaning to the analyzer, described in the GCC Internals manual. + Pertinent parameters for controlling the exploration are: @option{--param analyzer-bb-explosion-factor=@var{value}}, @option{--param analyzer-max-enodes-per-program-point=@var{value}},