CryptoPkg/IntrinsicLib: Fix possible unresolved external symbol issue
authorXiaoyu Lu <xiaoyux.lu@intel.com>
Wed, 29 May 2019 18:40:32 +0000 (18:40 +0000)
committerJian J Wang <jian.j.wang@intel.com>
Mon, 3 Jun 2019 00:28:01 +0000 (08:28 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1089

This is for the upcoming upgrade to OpenSSL_1_1_1b

Compiler optimization(Visual Studio) may automatically use _ftol2
instead of some type conversion. For example:

 OpensslLib.lib(drbg_lib.obj) : error LNK2001:
    unresolved external symbol __ftol2

This patch add _ftol2 function for the compiler intrinsic.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
Tested-by: Gary Lin <glin@suse.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
CryptoPkg/Library/IntrinsicLib/Ia32/MathFtol.c [new file with mode: 0644]
CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathFtol.c b/CryptoPkg/Library/IntrinsicLib/Ia32/MathFtol.c
new file mode 100644 (file)
index 0000000..147a19a
--- /dev/null
@@ -0,0 +1,22 @@
+/** @file\r
+  64-bit Math Worker Function.\r
+  The 32-bit versions of C compiler generate calls to library routines\r
+  to handle 64-bit math. These functions use non-standard calling conventions.\r
+\r
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+/*\r
+ * Floating point to integer conversion.\r
+ */\r
+__declspec(naked) void _ftol2 (void)\r
+{\r
+  _asm {\r
+    fistp qword ptr [esp-8]\r
+    mov   edx, [esp-4]\r
+    mov   eax, [esp-8]\r
+    ret\r
+  }\r
+}\r
index 5a20967..fcbb933 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Intrinsic Routines Wrapper Library Instance.\r
 #\r
-#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
 \r
   Ia32/MathLShiftS64.c      | MSFT\r
   Ia32/MathRShiftU64.c      | MSFT\r
+  Ia32/MathFtol.c           | MSFT\r
 \r
   Ia32/MathLShiftS64.c      | INTEL\r
   Ia32/MathRShiftU64.c      | INTEL\r
+  Ia32/MathFtol.c           | INTEL\r
 \r
   Ia32/MathLShiftS64.nasm   | GCC\r
   Ia32/MathRShiftU64.nasm   | GCC\r