From nobody Mon Apr 29 05:59:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1519696053704959.0903059611534; Mon, 26 Feb 2018 17:47:33 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D04DE2034D8F7; Mon, 26 Feb 2018 17:41:26 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 1395A209574ED for ; Mon, 26 Feb 2018 17:41:24 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2018 17:47:30 -0800 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga004.jf.intel.com with ESMTP; 26 Feb 2018 17:47:29 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,398,1515484800"; d="scan'208";a="178305570" From: Dandan Bi To: edk2-devel@lists.01.org Date: Tue, 27 Feb 2018 09:47:15 +0800 Message-Id: <1519696035-3076-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [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: , Cc: Michael Kinney , Laszlo Ersek , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" v2: Add [LibraryClasses] section in INF file and refine coding style. 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 This patch replaces direct shift/multiplication of 64-bit integer with related function call to fix these failure. Cc: Laszlo Ersek Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Laszlo Ersek Reviewed-by: Liming Gao --- 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(-) diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Libr= ary/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/Ba= seSafeIntLib/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-bi= ts // b * c must be less than 2^32 or there would be bits in the high 64-bi= ts // 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 above // - if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD << = 32, &UnsignedResult))) { + if (!RETURN_ERROR (SafeUint64Add (LShiftU64 (ProductBC, 32), LSh= iftU64 (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), Res= ult); + return SafeInt64ToInt32 (MultS64x64 (Multiplicand, Multiplier), Result); } =20 /** INT64 multiplication =20 diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Library/= 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 t= ype @@ -547,8 +548,8 @@ SafeIntnMult ( IN INTN Multiplicand, IN INTN Multiplier, OUT INTN *Result ) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Resu= lt); + return SafeInt64ToIntn (MultS64x64 (Multiplicand, Multiplier), Result); } =20 --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel