]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
authorXiaoyu Lu <xiaoyux.lu@intel.com>
Wed, 5 Jun 2019 05:24:55 +0000 (13:24 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 6 Jun 2019 03:01:50 +0000 (11:01 +0800)
When use clang-3.8 to build the NetworkPkg, compiler optimization
may use memcpy for memory copy. For example:

 CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_rsa.c:918: undefined
 reference to `memcpy'`

Compiler optimization is sophisticated, but we can work around it
use __attribute__((__used__)) to informs the compiler that symbol
should be retained in the object file, even if it may be
unreferenced.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
CryptoPkg/Library/IntrinsicLib/CopyMem.c

index e29b4918d2005f1c2ba4322b453d6c121df4b5c4..7faf5a34d8c179f63b9121a2dd07e234a31ed59c 100644 (file)
@@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Base.h>\r
 #include <Library/BaseMemoryLib.h>\r
 \r
+#if defined(__clang__) && !defined(__APPLE__)\r
+\r
+/* Copies bytes between buffers */\r
+static __attribute__((__used__))\r
+void * __memcpy (void *dest, const void *src, unsigned int count)\r
+{\r
+  return CopyMem (dest, src, (UINTN)count);\r
+}\r
+__attribute__((__alias__("__memcpy")))\r
+void * memcpy (void *dest, const void *src, unsigned int count);\r
+\r
+#else\r
 /* Copies bytes between buffers */\r
 void * memcpy (void *dest, const void *src, unsigned int count)\r
 {\r
   return CopyMem (dest, src, (UINTN)count);\r
 }\r
+#endif\r