From: Xiaoyu Lu Date: Wed, 5 Jun 2019 05:24:55 +0000 (+0800) Subject: CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem X-Git-Tag: edk2-stable201905~2 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=98d8f194e5a646b25b3390825c92949a76689d75 CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem 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 Cc: Dandan Bi Signed-off-by: Xiaoyu Lu Reviewed-by: Liming Gao --- diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c b/CryptoPkg/Library/IntrinsicLib/CopyMem.c index e29b4918d2..7faf5a34d8 100644 --- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c +++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c @@ -10,8 +10,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include +#if defined(__clang__) && !defined(__APPLE__) + +/* Copies bytes between buffers */ +static __attribute__((__used__)) +void * __memcpy (void *dest, const void *src, unsigned int count) +{ + return CopyMem (dest, src, (UINTN)count); +} +__attribute__((__alias__("__memcpy"))) +void * memcpy (void *dest, const void *src, unsigned int count); + +#else /* Copies bytes between buffers */ void * memcpy (void *dest, const void *src, unsigned int count) { return CopyMem (dest, src, (UINTN)count); } +#endif