From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 8428C3857C6C for ; Fri, 9 Jul 2021 23:11:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8428C3857C6C Received: by mail-ot1-x334.google.com with SMTP id f93-20020a9d03e60000b02904b1f1d7c5f4so10315413otf.9 for ; Fri, 09 Jul 2021 16:11:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=cM9pdDqp0l5vXWE0lpPtXaWUbCINOtRaYnuC3ZEXzNc=; b=LkXMdz4jmwcXkkWCv7k1cKoTb7TdQrCNtrj/7paRAw8gBEKYQFs4NRerXG48JqyueW KtP2kENsjVcFp/UFPBoOig5t4oRKiJoW2fM79PbbQZNe7NGeyM+yH/JCmEoNMJVRFYtS 19QaWP+hcdfAK7eCwQ/V2E7grmSHtmnrbAv7zi60qCpTtvcygWxYWR63or44M+brziiE Va9LBb5cLfGbVX7O9uJRpV1Fy8XRFi61pNXesNmpt24zDE1DUFeDAKaUKl9A3yGjmgv8 gK9K/5FaAcWHQg3GYJypPJuyNcdLXnzrx9EnUQ0LomC9EAkLMYj/NeoYIiRt6n0JogTS NNIg== X-Gm-Message-State: AOAM531xqw1l335J2Q3u7k/z6ehouKU3pSz7FdKb6En3CfWvuEgxx06+ gWmIU97XL5cTuHgYHodlYLs= X-Google-Smtp-Source: ABdhPJynwLi6mhKZUMSVQumi+D3CoVrmFOGmIBj92qutULhCyxYK9lwFgcsPdmy8TMYXRn79vM7hbQ== X-Received: by 2002:a9d:57cc:: with SMTP id q12mr32051255oti.286.1625872286958; Fri, 09 Jul 2021 16:11:26 -0700 (PDT) Received: from [192.168.0.41] (75-166-102-22.hlrn.qwest.net. [75.166.102.22]) by smtp.gmail.com with ESMTPSA id 186sm1306569ooe.28.2021.07.09.16.11.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jul 2021 16:11:26 -0700 (PDT) To: gcc-patches , Christophe Lyon From: Martin Sebor Subject: [PATCH libatomic/arm] avoid warning on constant addresses (PR 101379) Message-ID: <816ce216-bf6a-75ca-4241-4861ec43ab27@gmail.com> Date: Fri, 9 Jul 2021 17:11:25 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------AA21CC9072E094FD13FF4DB9" Content-Language: en-US X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Fri, 09 Jul 2021 23:11:28 -0000 This is a multi-part message in MIME format. --------------AA21CC9072E094FD13FF4DB9 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit The attached tweak avoids the new -Warray-bounds instances when building libatomic for arm. Christophe confirms it resolves the problem (thank you!) As we have discussed, the main goal of this class of warnings is to detect accesses at addresses derived from null pointers (e.g., to struct members or array elements at a nonzero offset). Diagnosing accesses at hardcoded addresses is incidental because at the stage they are detected the two are not distinguishable from each another. I'm planning (hoping) to implement detection of invalid pointer arithmetic involving null for GCC 12, so this patch is a stopgap solution to unblock the arm libatomic build without compromising the warning. Once the new detection is in place these workarounds can be removed or replaced with something more appropriate (e.g., declaring the objects at the hardwired addresses with an attribute like AVR's address or io; that would enable bounds checking at those addresses as well). Martin --------------AA21CC9072E094FD13FF4DB9 Content-Type: text/x-patch; charset=UTF-8; name="gcc-101379.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-101379.diff" PR bootstrap/101379 - libatomic arm build failure after r12-2132 due to -Warray-bounds on a constant address libatomic/ChangeLog: * /config/linux/arm/host-config.h (__kernel_helper_version): New function. Adjust shadow macro. diff --git a/libatomic/config/linux/arm/host-config.h b/libatomic/config/linux/arm/host-config.h index 1520f237d73..777d08a2b85 100644 --- a/libatomic/config/linux/arm/host-config.h +++ b/libatomic/config/linux/arm/host-config.h @@ -39,8 +39,14 @@ typedef void (__kernel_dmb_t) (void); #define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0) /* Kernel helper page version number. */ -#define __kernel_helper_version (*(unsigned int *)0xffff0ffc) +static inline unsigned* +__kernel_helper_version () +{ + unsigned *volatile addr = (unsigned int *)0xffff0ffc; + return addr; +} +#define __kernel_helper_version (*__kernel_helper_version()) #ifndef HAVE_STREX static inline bool --------------AA21CC9072E094FD13FF4DB9--