From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: xiaoyux.lu@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Tue, 04 Jun 2019 22:26:56 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 22:26:55 -0700 X-ExtLoop1: 1 Received: from xiaoyu-dev.sh.intel.com ([10.239.47.11]) by fmsmga004.fm.intel.com with ESMTP; 04 Jun 2019 22:26:55 -0700 From: "Xiaoyu Lu" To: devel@edk2.groups.io Cc: Xiaoyu Lu , Dandan Bi , Jian J Wang Subject: [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem Date: Wed, 5 Jun 2019 01:24:55 -0400 Message-Id: <1559712295-891-1-git-send-email-xiaoyux.lu@intel.com> X-Mailer: git-send-email 2.7.4 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 --- CryptoPkg/Library/IntrinsicLib/CopyMem.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CryptoPkg/Library/IntrinsicLib/CopyMem.c b/CryptoPkg/Library/IntrinsicLib/CopyMem.c index e29b4918d200..7faf5a34d8c1 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 -- 2.7.4