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>
		
			
				
	
	
		
			31 lines
		
	
	
		
			798 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			798 B
		
	
	
	
		
			C
		
	
	
	
	
	
/** @file
 | 
						|
  Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based
 | 
						|
  Cryptographic Library.
 | 
						|
 | 
						|
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
 | 
						|
SPDX-License-Identifier: BSD-2-Clause-Patent
 | 
						|
 | 
						|
**/
 | 
						|
 | 
						|
#include <Base.h>
 | 
						|
#include <Library/BaseMemoryLib.h>
 | 
						|
 | 
						|
#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
 |