From nobody Fri Apr 26 22:01:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61858+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61858+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1593530668; cv=none; d=zohomail.com; s=zohoarc; b=l1Hx4OubqXln9Yo096JBNg1C+DeoW7CWCcNfGLlmobFErWYfoSvsS+WSktLemOwhG12B/DJcz7XqpUDKA+Fc18xO6jOeMPfeuUhq2sYTUVDd/zTeGGNMxFdW/4R4ZRaHb7AuyJeNIMXbTjLuey3GIxfSvZBM1wa18k6sHC3jqfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593530668; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=b8QJozlBoVO55zKmmfmVqrvZHPljsrkGjpVxWzD5QQ0=; b=WiBbCzMGw3KQjUyKc7xcs/c5acb2SbQRgRNrt6ov+em20PdPt75d+XEhwSoTDDMsa0UBNKls703Ac46/BRwvRvBbSVuyEhsKPc7vZV1amkqgbeGCVtQu+lI54x8aoHBARiUV5Q+krXDpjkijz3mZwPnxTOyKmaxdF+jX8BBUdYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61858+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1593530668691378.5773373645212; Tue, 30 Jun 2020 08:24:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Cv1uYY1788612x5JqAnUDlr6; Tue, 30 Jun 2020 08:24:26 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.52]) by mx.groups.io with SMTP id smtpd.web11.17804.1593530664944548464 for ; Tue, 30 Jun 2020 08:24:25 -0700 X-Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 05UFOLWH029343; Tue, 30 Jun 2020 16:24:21 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , bob.c.feng@intel.com, liming.gao@intel.com, nd@arm.com Subject: [edk2-devel] [PATCH v1] BaseTools: Add gcc flag to warn on void* pointer arithmetic Date: Tue, 30 Jun 2020 16:24:16 +0100 Message-Id: <20200630152416.28240-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: ttv7RBDeSZx6RSjZbNm05qerx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1593530666; bh=ZTL4+E8mBTdwx1sA75gnL6A9Lfq8u7gY4XzBljMIhBY=; h=Cc:Date:From:Reply-To:Subject:To; b=SYRinlCBvxhq8RNsmhA4Xh/ffwVoHtyKWRvgPF2yIX9NxC35V7enCx+scZQhXPCHluF hUnYy9/i6hJSeC9jecuS59vFsHaLbnD9LGLi6D3SMOHbRzWSYOS35nGUIHHMp1Kfdv/+U rxXTrkj2R3cH8EFJYZm4TUPjFXw3YBvy4Qc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois By default, gcc allows void* pointer arithmetic. This is a GCC extension. However: - the C reference manual states that void* pointer "cannot be operands of addition or subtraction operators". Cf s5.3.1 "Generic Pointers"; - Visual studio compiler treat such operation as an error. To prevent such pointer arithmetic, the "-Wpointer-arith" flag should be set for all GCC versions. The "-Wpointer-arith" allows to: "Warn about anything that depends on the "size of" a function type or of void. GNU C assigns these types a size of 1, for convenience in calculations with void * pointers and pointers to functions." This flag is available since GCC2.95.3 which came out in 2001. Signed-off-by: Pierre Gondois Reviewed-by: Bret Barkelew --- The changes can be seen at: https://github.com/PierreARM/edk2/commits/831_= Add_gcc_flag_warning_v1 Notes: v1: - Add "-Wpointer-arith" gcc flag. [Pierre] BaseTools/Conf/tools_def.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..fba71665d6ade4dad08a5a0c343= f357fd413a8a4 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -1,7 +1,7 @@ # # Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
-# Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
+# Portions copyright (c) 2011 - 2020, ARM Ltd. All rights reserved.
# Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
# (C) Copyright 2020, Hewlett Packard Enterprise Development LP
# Copyright (c) Microsoft Corporation @@ -1918,7 +1918,7 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =3D --add-gnu-debu= glink=3D$(DEBUG_DIR)/$(MODULE_N *_*_*_DTCPP_PATH =3D DEF(DTCPP_BIN) *_*_*_DTC_PATH =3D DEF(DTC_BIN) =20 -DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builtin -= fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fno= -common +DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builtin -= fno-strict-aliasing -Wall -Werror -Wpointer-arith -Wno-array-bounds -includ= e AutoGen.h -fno-common DEFINE GCC_IA32_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -m32 -malign-= double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-p= robe DEFINE GCC_X64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mno-red-zone= -Wno-address -mno-stack-arg-probe DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-endi= an -mabi=3Daapcs -fno-short-enums -funsigned-char -ffunction-sections -fdat= a-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=3Dsoft -fn= o-pic -fno-pie --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61858): https://edk2.groups.io/g/devel/message/61858 Mute This Topic: https://groups.io/mt/75215666/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-