]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg: Fix possible unresolved external symbol issue.
authorQin Long <qin.long@intel.com>
Sat, 1 Apr 2017 03:30:55 +0000 (11:30 +0800)
committerQin Long <qin.long@intel.com>
Thu, 6 Apr 2017 16:27:34 +0000 (00:27 +0800)
The compiler (visual studio) may optimize some explicit strcmp call
in openssl source to use the intrinsic memcmp call.
In CrtLibSupport.h, we just use #define to mapping memcmp to
CompareMem API. So in Link phase, this kind of intrinsic optimization
will cause the "unresolved external symbol" error. For example:
    OpensslLib.lib(v3_utl.obj) : error LNK2001:
                               unresolved external symbol _memcmp

This patch will keep the memcmp mapping, and provide extra Intrinsic
memcmp wrapper to satisfy the symbol link.

Cc: Ting Ye <ting.ye@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
CryptoPkg/Library/Include/CrtLibSupport.h
CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c

index ddf7784a37be9d2a3a3fd6baf115df11cbbe3496..7f1ec1230206a8e887c20bfe9de17ba8b690b71a 100644 (file)
@@ -133,6 +133,7 @@ void           *malloc     (size_t);
 void           *realloc    (void *, size_t);\r
 void           free        (void *);\r
 void           *memset     (void *, int, size_t);\r
 void           *realloc    (void *, size_t);\r
 void           free        (void *);\r
 void           *memset     (void *, int, size_t);\r
+int            memcmp      (const void *, const void *, size_t);\r
 int            isdigit     (int);\r
 int            isspace     (int);\r
 int            isxdigit    (int);\r
 int            isdigit     (int);\r
 int            isspace     (int);\r
 int            isxdigit    (int);\r
index e8a76d07ff4dc4f0f804e4011578e45b70acbbbc..bf485d680def90ba7a6c6cd6a6a9d37fa960a3bc 100644 (file)
@@ -17,12 +17,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/BaseLib.h>\r
 \r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/BaseLib.h>\r
 \r
+typedef UINTN  size_t;\r
+\r
 /* OpenSSL will use floating point support, and C compiler produces the _fltused\r
    symbol by default. Simply define this symbol here to satisfy the linker. */\r
 int _fltused = 1;\r
 \r
 /* Sets buffers to a specified character */\r
 /* OpenSSL will use floating point support, and C compiler produces the _fltused\r
    symbol by default. Simply define this symbol here to satisfy the linker. */\r
 int _fltused = 1;\r
 \r
 /* Sets buffers to a specified character */\r
-void * memset (void *dest, char ch, unsigned int count)\r
+void * memset (void *dest, char ch, size_t count)\r
 {\r
   //\r
   // NOTE: Here we use one base implementation for memset, instead of the direct\r
 {\r
   //\r
   // NOTE: Here we use one base implementation for memset, instead of the direct\r
@@ -46,6 +48,12 @@ void * memset (void *dest, char ch, unsigned int count)
   return dest;\r
 }\r
 \r
   return dest;\r
 }\r
 \r
+/* Compare bytes in two buffers. */\r
+int memcmp (const void *buf1, const void *buf2, size_t count)\r
+{\r
+  return (int)CompareMem(buf1, buf2, count);\r
+}\r
+\r
 int strcmp (const char *s1, const char *s2)\r
 {\r
   return (int)AsciiStrCmp(s1, s2);\r
 int strcmp (const char *s1, const char *s2)\r
 {\r
   return (int)AsciiStrCmp(s1, s2);\r