From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 321D281F6F for ; Thu, 8 Dec 2016 16:40:24 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP; 08 Dec 2016 16:40:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,322,1477983600"; d="scan'208,217";a="40657947" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 08 Dec 2016 16:40:23 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 8 Dec 2016 16:40:23 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 8 Dec 2016 16:40:22 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.11]) by shsmsx102.ccr.corp.intel.com ([169.254.2.37]) with mapi id 14.03.0248.002; Fri, 9 Dec 2016 08:40:19 +0800 From: "Yao, Jiewen" To: "afish@apple.com" , Kurt Kennett CC: "Bi, Dandan" , "edk2-devel@lists.01.org" , "Ni, Ruiyu" Thread-Topic: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration Thread-Index: AQHSUUGEv7dYXu5p+0mZLsjiSWUaf6D+TfQwgABqC0CAAArK4P//fUuAgACGoAA= Date: Fri, 9 Dec 2016 00:40:18 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C50386F44DD@SHSMSX104.ccr.corp.intel.com> References: <1481194467-75920-1-git-send-email-dandan.bi@intel.com> <1481194467-75920-3-git-send-email-dandan.bi@intel.com> <74D8A39837DF1E4DA445A8C0B3885C50386F23F1@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2016 00:40:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi I found it is using "STATIC" not "CONST". Does a compiler put "STATIC" data to READ-ONLY section? Thank you Yao Jiewen From: afish@apple.com [mailto:afish@apple.com] Sent: Friday, December 9, 2016 8:37 AM To: Kurt Kennett Cc: Yao, Jiewen ; Bi, Dandan ; e= dk2-devel@lists.01.org; Ni, Ruiyu Subject: Re: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable = after declaration > On Dec 8, 2016, at 4:26 PM, Kurt Kennett > wrote: > > Is the data 'variable'? i.e does it ever change? > > A normal compiler should put this data into a section marked read-only if= it is marked as const, and a loader could read-protect the region after lo= ad. > K2, Did you mean write-protoect? FYI in my example in this thread from a macOS clang compiler the constant d= ate ends up in a const TEXT section, as the text section in general is cons= t. That is why the compiler emitted a PC relative access. This only ever be= comes an issue when hand writing assemble code for X64. Thanks, Andrew Fish > K2 > > -----Original Message----- > From: Yao, Jiewen [mailto:jiewen.yao@intel.com] > Sent: Thursday, December 8, 2016 3:47 PM > To: Kurt Kennett >; Bi, Dandan >; edk2= -devel@lists.01.org > Cc: Ni, Ruiyu > > Subject: RE: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variabl= e after declaration > > Agree. Maybe we can move it to be a global variable ? > > Thank you > Yao Jiewen > >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >> Kurt Kennett >> Sent: Friday, December 9, 2016 1:28 AM >> To: Bi, Dandan >; edk2-d= evel@lists.01.org >> Cc: Ni, Ruiyu > >> Subject: Re: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize >> variable after declaration >> >> This seems kind of silly. >> Why isn't this just const data? This adds code and memory accesses >> that are worthless and happen on every call to the function. >> >> K2 >> >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >> Dandan Bi >> Sent: Thursday, December 8, 2016 2:54 AM >> To: edk2-devel@lists.01.org >> Cc: Ruiyu Ni > >> Subject: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable >> after declaration >> >> Cc: Ruiyu Ni > >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Dandan Bi > >> --- >> FatPkg/EnhancedFatDxe/Misc.c | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/FatPkg/EnhancedFatDxe/Misc.c >> b/FatPkg/EnhancedFatDxe/Misc.c index f91759c..6ad688c 100644 >> --- a/FatPkg/EnhancedFatDxe/Misc.c >> +++ b/FatPkg/EnhancedFatDxe/Misc.c >> @@ -696,15 +696,27 @@ Returns: >> TRUE - The time is valid. >> FALSE - The time is not valid. >> >> --*/ >> { >> - static UINT8 MonthDays[] =3D { 31, 28, 31, 30, 31, 30, 31, 31, 30, >> 31, 30, 31 }; >> + STATIC UINT8 MonthDays[12]; >> UINTN Day; >> BOOLEAN ValidTime; >> >> ValidTime =3D TRUE; >> + MonthDays[0] =3D 31; >> + MonthDays[1] =3D 28; >> + MonthDays[2] =3D 31; >> + MonthDays[3] =3D 30; >> + MonthDays[4] =3D 31; >> + MonthDays[5] =3D 30; >> + MonthDays[6] =3D 31; >> + MonthDays[7] =3D 31; >> + MonthDays[8] =3D 30; >> + MonthDays[9] =3D 31; >> + MonthDays[10] =3D 30; >> + MonthDays[11] =3D 31; >> >> // >> // Check the fields for range problems >> // Fat can only support from 1980 >> // >> -- >> 1.9.5.msysgit.1 >> >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel