From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.103]) by mx.groups.io with SMTP id smtpd.web12.17726.1593531362661558758 for ; Tue, 30 Jun 2020 08:36:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=jrRVYzlD; spf=pass (domain: microsoft.com, ip: 40.107.236.103, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NOgBwDyz93kC2V/v6XLQfFdrlZmRfBfoeHZcoPsa5mABFBls4OQa57w1rYcsUOp/eFrtyUzlAkHjvEWEexCg5rn3SuvtVfO7k1iLAsYgsL3cNjihaR82VnMO2tJOHdrK0GuyGRXmW/z2FspEaKzoDiPTU2UxL/2GpB3DOnpIQOeDo4tv8ojbsB37YJD6I21f6THeMiIHnXYRPydMWvfpFQ9dbwP6/8PGvy5MWS/9yqrtCCktprvWFs8Nq72akOOxYt/t/YYhjGYGtuDYt2T81rpFtShUNzyoxhGjaSIvgGSO1pgXVHd9feW8Nu0dtfqKoX7SyYNPc6gpC8zBvOy/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WySSXhqTNLFk9Ewvt/01+hh1vAYl1kHggNaqHvykWrc=; b=InD+nWzbh7ZZ6zUpGWUm+QitXuUf7ty6BoXOhkXwtQge4HnHC5Q7WJ14F2nPtRonw2vUDd2+MV296KQS3s33YVh7IRh00PhowX2Zy7TAKJeI7XowFfzeThKD+mL0eQsR9c70hM9+zqc6w9KHFr7448bvfM6lkwD59qBmIm0fO9Y5ixbkjXFPI/1AjR9rzp77KXyqE7IYt0Fdj5/4JruEp7/gBf0leVjWNAtnXhWnse7ZPYqIfqohu5tkYTMnwhNtr+VhybyF902gKC62Fq9t6jUXc1JMoYzAR6uiZ1Uk4zaPnOYl8CEx/BTgRE24+RCFcVwX87AinP410MFLWmHl8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WySSXhqTNLFk9Ewvt/01+hh1vAYl1kHggNaqHvykWrc=; b=jrRVYzlDAvrwWuHJ+RQ1fvq+W06PUVVqkxpY2aSVPhC0HV3OeNL8Tmef2pu8PL8VYcBRLSC/JlyZ8st7KhKXmxZ82kZ1s3y+1ovjCsSTvUeJ/oRyGxKX7AQ1GbLI+q7gO5b/rKnFnkvmXDZfVntSoXYYrMRMBnkScbsx/tBnncU= Received: from CY4PR21MB0743.namprd21.prod.outlook.com (2603:10b6:903:b2::9) by CY4PR21MB0503.namprd21.prod.outlook.com (2603:10b6:903:dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.1; Tue, 30 Jun 2020 15:36:00 +0000 Received: from CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::f112:82fb:d4fd:f7dd]) by CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::f112:82fb:d4fd:f7dd%12]) with mapi id 15.20.3174.005; Tue, 30 Jun 2020 15:36:00 +0000 From: "Bret Barkelew" To: "devel@edk2.groups.io" , "pierre.gondois@arm.com" CC: Pierre Gondois , "Feng, Bob C" , liming.gao , "nd@arm.com" Subject: Re: [EXTERNAL] [edk2-devel] [PATCH v1] BaseTools: Add gcc flag to warn on void* pointer arithmetic Thread-Topic: [EXTERNAL] [edk2-devel] [PATCH v1] BaseTools: Add gcc flag to warn on void* pointer arithmetic Thread-Index: AQHWTvKMEH/HAkfES0CgR/Z5vRvEGajxSj1K Date: Tue, 30 Jun 2020 15:36:00 +0000 Message-ID: References: <20200630152416.28240-1-pierre.gondois@arm.com> In-Reply-To: <20200630152416.28240-1-pierre.gondois@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-06-30T15:35:22.0508973Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Privileged authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [174.21.80.75] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 3ac774de-1967-4795-c3c4-08d81d0b4ab9 x-ms-traffictypediagnostic: CY4PR21MB0503: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YYA9A9TbkwlZ//6glXqUhmIAGlyq4KloBmK2zgBtfYG0cJ3yAzhw4t9c1WXdbdQQ+7JWHIvea5zPztznpa5fVFELCB0EuSnHobkJ/MRt3eBegczZIuRfetMPRKxOtcS7A0S5VUcFlWjb9SpasLpMbIfbVHK5e1E/XrCrUL3NfUSththMXk9IdtVkOCj/bJJQIRGXERqLck3gNmFNqGu+/rC3fnKRyVvi/IjbjqgJk2aBCVlZhPSJfbUcV2Y7Uh1pQ7HXKGb7G1EdVdQEMA0F6uSzcqbGzdxGmbRqyje1jASp01H9eF7KS+7N8uKNU6fPS6WTz3vGrgG++/rDZ7cULo/rMbZkGhu6lsCdMgRSk0pSkiYyMMffilK3aHCrZfUx+R7gaWueCHsSuq3D2fi7Pw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR21MB0743.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(376002)(346002)(39860400002)(366004)(396003)(6506007)(83380400001)(60390400001)(8676002)(53546011)(71200400001)(7696005)(8990500004)(966005)(82950400001)(82960400001)(4326008)(166002)(76116006)(91956017)(2906002)(26005)(8936002)(186003)(110136005)(33656002)(478600001)(316002)(10290500003)(54906003)(66556008)(52536014)(66446008)(66946007)(64756008)(66476007)(86362001)(5660300002)(9686003)(55016002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: EX+jpMz+AER2Kx3qVgSo+aKAU4jJbPB5bAEpiDTvkv6QgwPWcluvWZNOpV0DyGvLiIduEYSUANL9WHBftbCxr4mxkmclIJEhU9ek86LwfBtqHFb7qkgmayEzz2DPufDxM2X8peFMmS/inTBHdF+FS+7hr7fTJEaFUQ6KUoU1oj0CslL5IiKqyqemrMYqC/z4afpWNvS3xAU12p3KnlZQ0B6bd3SMfRcO0CcjNvsyBh23X7ulIhlQ5/rd3lL2nv05oTssItwDVZQ4y90jKK30w57NlHCm5jOmCpNS6Md7pfuF5a0kvVcwE/Jg+KAgDYcWTQZP5ZNztzkw2TeUpJQYWQFbPJqiyLS4VC+LtqzqrplwWWXmeRh+v2HyZoVscF6L2oHj8uPI27rYSlA0SUQ9ITsL19VH5zVU0Pux2oeZnh1MAgQHiKX9WMOtmehb+GgKskE2z3eceiy+75NCvccqjeZNshQVHbdG4cVirDXZkAs= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR21MB0743.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ac774de-1967-4795-c3c4-08d81d0b4ab9 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2020 15:36:00.7209 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VDVAdA9vg8y4cBLBPSSTbGL29/hVbMiFPCjac4foWWhIY0VJBe9dG9kg9ipin2fWvnk3I4ussTzIr3gWxiJIew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0503 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR21MB07434B36AE1FC9D20789B18AEF6F0CY4PR21MB0743namp_" --_000_CY4PR21MB07434B36AE1FC9D20789B18AEF6F0CY4PR21MB0743namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bret Barkelew - Bret From: PierreGondois via groups.io Sent: Tuesday, June 30, 2020 8:24 AM To: devel@edk2.groups.io Cc: Pierre Gondois; Feng, Bob C; liming.gao; nd@arm.com Subject: [EXTERNAL] [edk2-devel] [PATCH v1] BaseTools: Add gcc flag to war= n on void* pointer arithmetic 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 --- The changes can be seen at: https://nam06.safelinks.protection.outlook.co= m/?url=3Dhttps%3A%2F%2Fgithub.com%2FPierreARM%2Fedk2%2Fcommits%2F831_Add_gc= c_flag_warning_v1&data=3D02%7C01%7CBret.Barkelew%40microsoft.com%7C7e43= c07c149c49217d2808d81d09ade0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6= 37291274698461218&sdata=3DJRmRWVRS%2FHi6vsYBguNI0SfVZHuEKOVkX5wL0h1J2Ho= %3D&reserved=3D0 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.= template index 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..fba71665d6ade4dad08a5a0c34= 3f357fd413a8a4 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-deb= uglink=3D$(DEBUG_DIR)/$(MODULE_N *_*_*_DTCPP_PATH =3D DEF(DTCPP_BIN) *_*_*_DTC_PATH =3D DEF(DTC_BIN) -DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builtin = -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h -fn= o-common +DEFINE GCC_ALL_CC_FLAGS =3D -g -Os -fshort-wchar -fno-builtin = -fno-strict-aliasing -Wall -Werror -Wpointer-arith -Wno-array-bounds -inclu= de 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-= probe DEFINE GCC_X64_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mno-red-zon= e -Wno-address -mno-stack-arg-probe DEFINE GCC_ARM_CC_FLAGS =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-end= ian -mabi=3Daapcs -fno-short-enums -funsigned-char -ffunction-sections -fda= ta-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=3Dsoft -f= no-pic -fno-pie -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' --_000_CY4PR21MB07434B36AE1FC9D20789B18AEF6F0CY4PR21MB0743namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Reviewed-by: Bret Barkelew <bret.barkelew@micros= oft.com>

 

- Bret

 

From: PierreGondois via groups.= io
Sent: Tuesday, June 30, 2020 8:24 AM
To: devel@edk2.groups.io
Cc:
Pierre Gondois; <= a href=3D"mailto:bob.c.feng@intel.com"> Feng, Bob C; liming.gao; <= a href=3D"mailto:nd@arm.com"> nd@arm.com
Subject: [EXTERNAL] [edk2-devel] [PATCH v1] BaseTools: Add gcc flag= to warn on void* pointer arithmetic

 

From: Pierre Gondois= <pierre.gondois@arm.com>

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 <pierre.gondois@arm.com>
---

 The changes can be seen at: https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgithub= .com%2FPierreARM%2Fedk2%2Fcommits%2F831_Add_gcc_flag_warning_v1&amp;dat= a=3D02%7C01%7CBret.Barkelew%40microsoft.com%7C7e43c07c149c49217d2808d81d09a= de0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637291274698461218&amp= ;sdata=3DJRmRWVRS%2FHi6vsYBguNI0SfVZHuEKOVkX5wL0h1J2Ho%3D&amp;reserved= =3D0
Notes:
    v1:
     - Add "-Wpointer-arith" gcc flag. [Pier= re]

 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.= template
index 8aeb8a2a6417e41c5660cda5066f52adc8cc3089..fba71665d6ade4dad08a5a0c34= 3f357fd413a8a4 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 res= erved.<BR>
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights re= served.<BR>
-#  Portions copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.= <BR>
+#  Portions copyright (c) 2011 - 2020, ARM Ltd. All rights reser= ved.<BR>
 #  Copyright (c) 2015, Hewlett-Packard Development Company, L.P= .<BR>
 #  (C) Copyright 2020, Hewlett Packard Enterprise Development L= P<BR>
 #  Copyright (c) Microsoft Corporation
@@ -1918,7 +1918,7 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG   =   =3D --add-gnu-debuglink=3D$(DEBUG_DIR)/$(MODULE_N
 *_*_*_DTCPP_PATH        &nbs= p;          =3D DEF(DTCPP_BIN)=
 *_*_*_DTC_PATH         =             =3D DEF(= DTC_BIN)
 
-DEFINE GCC_ALL_CC_FLAGS        &n= bsp;   =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       &nbs= p;    =3D -g -Os -fshort-wchar -fno-builtin -fno-strict-alia= sing -Wall -Werror -Wpointer-arith -Wno-array-bounds -include AutoGen.h -fn= o-common
 DEFINE GCC_IA32_CC_FLAGS       &n= bsp;   =3D DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-bl= ocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
 DEFINE GCC_X64_CC_FLAGS       &nb= sp;    =3D DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address = -mno-stack-arg-probe
 DEFINE GCC_ARM_CC_FLAGS       &nb= sp;    =3D DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=3Daap= cs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fo= mit-frame-pointer -Wno-address -mthumb -mfloat-abi=3Dsoft -fno-pic -fno-pie=
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


 

--_000_CY4PR21MB07434B36AE1FC9D20789B18AEF6F0CY4PR21MB0743namp_--