From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 3CB5C20955F04 for ; Tue, 27 Feb 2018 18:13:41 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 18:19:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,403,1515484800"; d="scan'208";a="23764541" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 27 Feb 2018 18:19:48 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Feb 2018 18:19:47 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Feb 2018 18:19:47 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Wed, 28 Feb 2018 10:19:44 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: Laszlo Ersek , "Kinney, Michael D" Thread-Topic: [patch v2] MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failure Thread-Index: AQHTr2zvpTfY+xfZvUq5Gj9ZF/9rN6O5FlFQ Date: Wed, 28 Feb 2018 02:19:44 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1D4550@SHSMSX104.ccr.corp.intel.com> References: <1519696035-3076-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1519696035-3076-1-git-send-email-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch v2] MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2018 02:13:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Bi, Dandan > Sent: Tuesday, February 27, 2018 9:47 AM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Gao, Liming ;= Kinney, Michael D > Subject: [patch v2] MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build fa= ilure >=20 > v2: Add [LibraryClasses] section in INF file and refine coding style. >=20 > There are VS2015 NOOPT IA32 build failure like below in BaseSafeIntLib. > XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allmul > XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allshl > XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __aullshr >=20 > This patch replaces direct shift/multiplication of 64-bit integer > with related function call to fix these failure. >=20 > Cc: Laszlo Ersek > Cc: Liming Gao > Cc: Michael Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi > --- > MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf | 3 +++ > MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 9 +++++---- > MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c | 3 ++- > 3 files changed, 10 insertions(+), 5 deletions(-) >=20 > diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Li= brary/BaseSafeIntLib/BaseSafeIntLib.inf > index 20a83ed..8fbdafe 100644 > --- a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf > +++ b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf > @@ -54,5 +54,8 @@ > [Sources.EBC] > SafeIntLibEbc.c >=20 > [Packages] > MdePkg/MdePkg.dec > + > +[LibraryClasses] > + BaseLib > diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/= BaseSafeIntLib/SafeIntLib.c > index c5f13d7..e96327d 100644 > --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c > +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c > @@ -26,10 +26,11 @@ >=20 > **/ >=20 > #include > #include > +#include >=20 >=20 > // > // Magnitude of MIN_INT64 as expressed by a UINT64 number. > // > @@ -3371,12 +3372,12 @@ SafeUint64Mult ( > // a * c must be 0 or there would be bits in the high 64-bits > // a * d must be less than 2^32 or there would be bits in the high 64-= bits > // b * c must be less than 2^32 or there would be bits in the high 64-= bits > // then there must be no overflow of the resulting values summed up. > // > - DwordA =3D (UINT32)(Multiplicand >> 32); > - DwordC =3D (UINT32)(Multiplier >> 32); > + DwordA =3D (UINT32)RShiftU64 (Multiplicand, 32); > + DwordC =3D (UINT32)RShiftU64 (Multiplier, 32); >=20 > // > // common case -- if high dwords are both zero, no chance for overflow > // > if ((DwordA =3D=3D 0) && (DwordC =3D=3D 0)) { > @@ -3407,11 +3408,11 @@ SafeUint64Mult ( > if ((ProductBC & 0xffffffff00000000) =3D=3D 0) { > // > // now sum them all up checking for overflow. > // shifting is safe because we already checked for overflow ab= ove > // > - if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD <= < 32, &UnsignedResult))) { > + if (!RETURN_ERROR (SafeUint64Add (LShiftU64 (ProductBC, 32), L= ShiftU64 (ProductAD, 32), &UnsignedResult))) { > // > // b * d > // > ProductBD =3D (((UINT64)DwordB) *(UINT64)DwordD); >=20 > @@ -4073,11 +4074,11 @@ SafeInt32Mult ( > IN INT32 Multiplicand, > IN INT32 Multiplier, > OUT INT32 *Result > ) > { > - return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), R= esult); > + return SafeInt64ToInt32 (MultS64x64 (Multiplicand, Multiplier), Result= ); > } >=20 > /** > INT64 multiplication >=20 > diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Librar= y/BaseSafeIntLib/SafeIntLib32.c > index 18bfb9e..ce66a92 100644 > --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c > +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c > @@ -26,10 +26,11 @@ >=20 > **/ >=20 > #include > #include > +#include >=20 > /** > INT32 -> UINTN conversion >=20 > Converts the value specified by Operand to a value specified by Result= type > @@ -547,8 +548,8 @@ SafeIntnMult ( > IN INTN Multiplicand, > IN INTN Multiplier, > OUT INTN *Result > ) > { > - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Re= sult); > + return SafeInt64ToIntn (MultS64x64 (Multiplicand, Multiplier), Result)= ; > } >=20 > -- > 1.9.5.msysgit.1