From nobody Fri May 3 12:37:47 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+62129+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+62129+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1594111112; cv=none; d=zohomail.com; s=zohoarc; b=CJHs6k5IfDFOGIXfr5U8WMx7Uu3djU6R16BEMs5c3+RBmGa4PzZV740EYnktzxM+YciN1ZnugM1ccqzyapDyd8L86Y5n0O9ERCE1FUzndaj4PPrComU/QGVFkn2HGCnBMDeY3tqjTZ/KKBr31z/T69PKjjc6n0V/AEtXEPnGsNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594111112; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=nd9Pt6CWzflbFApJEQF5nC5MfvboL0Gx8QIIY6CDznQ=; b=bcVNRgudf3CA1bGq7kw4xnCtkqZJxKOWS4vFsm/W5gmGOG+UXIN+WlnaeBu9xw18tk1979VkC9v8KKHPyvfSjWNRMEY1wzLK3bnqWRrxrrIjaJRcYqcayM6HBAPhKnNVSKn42RQJ+oeHRXla310NNCb8hYxjGi5eT+ekOnfpS/U= 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+62129+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594111112698377.8534966352594; Tue, 7 Jul 2020 01:38:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id T8s3YY1788612xgpBZfqPDyi; Tue, 07 Jul 2020 01:38:32 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.51]) by mx.groups.io with SMTP id smtpd.web10.12290.1594110930891752424 for ; Tue, 07 Jul 2020 01:35:31 -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 0678ZS5u018182; Tue, 7 Jul 2020 09:35:28 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , bob.c.feng@intel.com, liming.gao@intel.com, tomas.pilar@arm.com, nd@arm.com Subject: [edk2-devel] [PATCH V2 1/2] BaseTools: Add gcc flag to warn on void* pointer arithmetic Date: Tue, 7 Jul 2020 09:35:21 +0100 Message-Id: <20200707083522.138944-2-pierre.gondois@arm.com> In-Reply-To: <20200707083522.138944-1-pierre.gondois@arm.com> References: <20200707083522.138944-1-pierre.gondois@arm.com> MIME-Version: 1.0 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: jdlAxEqvCiRYHI3ckaVHsmfax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594111112; bh=gQYRIOM6/mD+YtCtD7g2zgNGN5f7J0nN/zgCEd9XINM=; h=Cc:Date:From:Reply-To:Subject:To; b=spvd0LgrOSjFriO7Zf3HABi60kMQexip4c58Ytrtm9oUrqErqHDrnp7Gep5zloNvdMt o+NjSMseWafeQhDv9bv8k9nMrXan7jvbE5nMqcPHQjTIb2SWZMJ4LQc3TPrgDaDe/Uuhx N3ve1MxRKZUnJmxHY0oAXMXpcjts8JrAfME= X-ZohoMail-DKIM: pass (identity @groups.io) 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: Bob Feng Reviewed-by: Yuwei Chen --- The changes can be seen at: https://github.com/PierreARM/edk2/commits/831_A= dd_gcc_flag_warning_v2 Notes: v1: - Add "-Wpointer-arith" gcc flag. [Pierre] v2: - Only add the flag for ARM and AARCH64. [Tomas] BaseTools/Conf/tools_def.template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..397b011ba38f97f81f314f8641a= c8bb95d5a2197 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 @@ -1921,9 +1921,9 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =3D --add-gnu-debu= glink=3D$(DEBUG_DIR)/$(MODULE_N 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_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 +DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -Wpointer-ari= th -mlittle-endian -mabi=3Daapcs -fno-short-enums -funsigned-char -ffunctio= n-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloa= t-abi=3Dsoft -fno-pic -fno-pie DEFINE GCC_ARM_CC_XIPFLAGS =3D -mno-unaligned-access -DEFINE GCC_AARCH64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-endi= an -fno-short-enums -fverbose-asm -funsigned-char -ffunction-sections -fda= ta-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables= -fno-pic -fno-pie -ffixed-x18 +DEFINE GCC_AARCH64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -Wpointer-ari= th -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char -ffunctio= n-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fn= o-unwind-tables -fno-pic -fno-pie -ffixed-x18 DEFINE GCC_AARCH64_CC_XIPFLAGS =3D -mstrict-align -mgeneral-regs-only DEFINE GCC_DLINK_FLAGS_COMMON =3D -nostdlib --pie DEFINE GCC_DLINK2_FLAGS_COMMON =3D -Wl,--script=3D$(EDK_TOOLS_PATH)/Sc= ripts/GccBase.lds --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' From nobody Fri May 3 12:37:47 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+62127+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+62127+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1594110940; cv=none; d=zohomail.com; s=zohoarc; b=Iibdvycw/LESrB2flrtB8Go8SNcBO4rfDgY5cG7yylVT54oOOS/WUn+1pfMeNzqqZvbmmISNvtXd1GmoeT3sIvi0BICqWnFISSdelbtvGTLiEYa3Y5mbWVViAQubuCloOwcpzjaYhhBYOjB1Sdync6PZ/BTHF3ChohZuP5FRdqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594110940; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=RoY0LyB5nKqwAGAgrmPoXAuwfASm0/RKb/YWIHw0BgY=; b=fEWd8osoVtYTQF/3ahAgnrNGSJbGnrnJ42L78bOAHwmSBjqBMe0ILOj0RZAPhcI0Zd8zwpxuWQPIrHgg2DF+3K1kTce8BZbfKQFkCjyah4BGahI2Xp5d9rOVBQhe+6pjNdhwiijqX+zy7h/XZAbzPTJRw9BEhUdJWRyFkRMgOKU= 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+62127+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594110940005563.5712949395378; Tue, 7 Jul 2020 01:35:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vis4YY1788612x6wwGf3vulx; Tue, 07 Jul 2020 01:35:36 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.51]) by mx.groups.io with SMTP id smtpd.web11.12129.1594110930889704088 for ; Tue, 07 Jul 2020 01:35:31 -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 0678ZS5v018182; Tue, 7 Jul 2020 09:35:28 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , bob.c.feng@intel.com, liming.gao@intel.com, tomas.pilar@arm.com, nd@arm.com Subject: [edk2-devel] [PATCH V2 2/2] BaseTools: Factorize GCC flags Date: Tue, 7 Jul 2020 09:35:22 +0100 Message-Id: <20200707083522.138944-3-pierre.gondois@arm.com> In-Reply-To: <20200707083522.138944-1-pierre.gondois@arm.com> References: <20200707083522.138944-1-pierre.gondois@arm.com> MIME-Version: 1.0 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: wsnJp1Z7ZCevU85TZlF72YJPx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594110936; bh=1abyNvYnBbgiOoeStLwV2DUN3+gO2vWbBq5aro6rAQc=; h=Cc:Date:From:Reply-To:Subject:To; b=xXAe4dh2tmNQfUyCQJN+6x/ZHDuYuF/GTO/UgB9aucqA9jqDgOmp/FrAyMFNACTwaFl Ug1j1LeJvZ4glN8PCicruvSVVwTsXe0hTtnH1cQdsfYm/pVPq+g5vv5hyBzCUcZZKOGTq D7HwvbDAzAnQEyuH4nK1HGkXwpFrAEYSyOc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Pierre Gondois GCC48_ALL_CC_FLAGS has no dependency on GCC_ALL_CC_FLAGS. By definition, there should be such dependency. The outcomes of this patch is that GCC48_ALL_CC_FLAGS and other dependent configurations will inherit from the additional "-Os" flag. The "-Os" flag optimizes a build in size, not breaking any build. In a gcc command line, the last optimization flag has precedence. This means that this "-Os" flag will be overriden by a more specific optimization configuration, provided that this more specific flag is appended at the end of the CC_FLAGS. Signed-off-by: Pierre Gondois Suggested-by: Tomas Pilar Reviewed-by: Bob Feng --- The changes can be seen at: https://github.com/PierreARM/edk2/commits/831_A= dd_gcc_flag_warning_v2 Notes: v2: - Make GCC48_ALL_CC_FLAGS dependent on GCC_ALL_CC_FLAGS. [Tomas] BaseTools/Conf/tools_def.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index 397b011ba38f97f81f314f8641ac8bb95d5a2197..a1fd27b1adba8769949b7d628d7= fbed49fe24267 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -1952,7 +1952,7 @@ DEFINE GCC_RISCV64_RC_FLAGS =3D -I binary -O e= lf64-littleriscv -B riscv # GCC Build Flag for included header file list generation DEFINE GCC_DEPS_FLAGS =3D -MMD -MF $@.deps =20 -DEFINE GCC48_ALL_CC_FLAGS =3D -g -fshort-wchar -fno-builtin -fn= o-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdat= a-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=3D$(BASE_NAME= )Strings +DEFINE GCC48_ALL_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -ffunction-= sections -fdata-sections -DSTRING_ARRAY_NAME=3D$(BASE_NAME)Strings DEFINE GCC48_IA32_X64_DLINK_COMMON =3D -nostdlib -Wl,-n,-q,--gc-sections= -z common-page-size=3D0x20 DEFINE GCC48_IA32_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) -m32 -mar= ch=3Di586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-un= wind-tables -Wno-address DEFINE GCC48_X64_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) -m64 -fno= -stack-protector "-DEFIAPI=3D__attribute__((ms_abi))" -maccumulate-outgoing= -args -mno-red-zone -Wno-address -mcmodel=3Dsmall -fpie -fno-asynchronous-u= nwind-tables -Wno-address --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' =1A=EF=BF=BD.=EF=BF=BD=C8=A8.)=E4=B1=8A.=EF=BF=BD=EF=BF=BD=1E=EF=BF=BD=EF= =BF=BD=EF=BF=BD=EF=BF=BDY=EF=BF=BD=EF=BF=BD=C6=A0z=EF=BF=BD=1E=EF=BF=BD=EF= =BF=BDh=EF=BF=BD=18=EF=BF=BD=EF=BF=BD=EF=BF=BD.=EF=BF=BDX=EF=BF=BD=EF=BF=BD= =EF=BF=BD^=EF=BF=BD\=EF=BF=BD=EF=BF=BDX=EF=BF=BD{=EF=BF=BD=EF=BF=BD=DB=B8m= =EF=BF=BD=EF=BF=BD?=EF=BF=BD=EF=BF=BDd=EF=BF=BD =E8=BA=9B"=EF=BF=BD=EF=BF=BD?u=EF=BF=BD=DE=97=EF=BF=BD=EF=BF=BD=EF=BF=BD=C6= =A0{=EF=BF=BD=EF=BF=BD=EF=BF=BDn=CC=BA=D7=93=EF=BF=BD+=13=EF=BF=BD=EF=BF=BD= =EF=BF=BD=EF=BF=BD=EF=BF=BDi=EF=BF=BD=EF=BF=BD=E0=AE=8B=EF=BF=BD=EF=BF=BD*?= =EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD~u=EF=BF=BD}=EF=BF=BD=D7=BF;=DB=BE=C6= =AE=EF=BF=BD=EF=BF=BD; =DE=AD=D7=AFz_=EF=BF=BD=EF=BF=BDw=EF=BF=BDy=EF=BF=BD= 6=EF=BF=BD=EF=BF=BD.=EF=BF=BD=C8=A8R{.n=EF=BF=BD+=EF=BF=BD=EF=BF=BD=EF=BF= =BD=EF=BF=BD=EF=BF=BDl=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BDh+=EF=BF=BD=EF=BF= =BDl=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=D7=AFz_=EF=BF=BD=CB=9B=EF=BF=BDjh= =EF=BF=BD=D7=AB=EF=BF=BD=EF=BF=BD\=EF=BF=BD=EF=BF=BD(=EF=BF=BD