[edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
Liming Gao
liming.gao at intel.com
Thu Jun 6 03:50:51 UTC 2019
Fish:
From: afish at apple.com [mailto:afish at apple.com]
Sent: Thursday, June 6, 2019 11:39 AM
To: devel at edk2.groups.io; Lu, XiaoyuX <xiaoyux.lu at intel.com>
Cc: Gao, Liming <liming.gao at intel.com>; Bi, Dandan <dandan.bi at intel.com>; Wang, Jian J <jian.j.wang at intel.com>
Subject: Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix CLANG38 IA32 build problem
On Jun 4, 2019, at 11:33 PM, Xiaoyu Lu <xiaoyux.lu at intel.com<mailto:xiaoyux.lu at intel.com>> wrote:
Hi Liming,
-----Original Message-----
From: Gao, Liming
Sent: Wednesday, June 5, 2019 1:57 PM
To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>; Lu, XiaoyuX <xiaoyux.lu at intel.com<mailto:xiaoyux.lu at intel.com>>
Cc: Bi, Dandan <dandan.bi at intel.com<mailto:dandan.bi at intel.com>>; Wang, Jian J <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>
Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg/IntrinsicLib: Fix
CLANG38 IA32 build problem
Xiaoyu:
-----Original Message-----
From: devel at edk2.groups.io<mailto:devel at edk2.groups.io> [mailto:devel at edk2.groups.io] On Behalf Of
Xiaoyu Lu
Sent: Wednesday, June 05, 2019 1:25 PM
To: devel at edk2.groups.io<mailto:devel at edk2.groups.io>
Cc: Lu, XiaoyuX <xiaoyux.lu at intel.com<mailto:xiaoyux.lu at intel.com>>; Bi, Dandan
<dandan.bi at intel.com<mailto:dandan.bi at intel.com>>;
Wang, Jian J <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>
Subject: [edk2-devel] [PATCH v1 1/1] 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 <jian.j.wang at intel.com<mailto:jian.j.wang at intel.com>>
Cc: Dandan Bi <dandan.bi at intel.com<mailto:dandan.bi at intel.com>>
Signed-off-by: Xiaoyu Lu <xiaoyux.lu at intel.com<mailto:xiaoyux.lu at intel.com>>
---
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 <Base.h>
#include <Library/BaseMemoryLib.h>
+#if defined(__clang__) && !defined(__APPLE__)
So, this change is only for CLANG tool chain.
+
+/* Copies bytes between buffers */
+static __attribute__((__used__))
What purpose for static?
Because I want __memcpy only use in this file scope.
+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);
__memcpy is IA32 Intrinsic API, memcpy is X64 Intrinsic API, right?
__memcpy isn't IA32 Intrinsic API, only memcpy is intrinsic API for both IA32 and X64.
The reason I alias memcpy and use __attribute__((__used__)) is let compiler retain symbol in object file,
So it can link correct.
Is this correct?
I think this is a bug in clang that requires the __used__, we hit something like this with Xcode too. If the compiler emits the intrinsic it should tell the linker and some how that was getting missed. Thus the __used__ is a work around.
OK. It is for CLANG 3.8. I will check whether the latest CLANG8.0 fixes it.
Thanks,
Andrew Fish
Thanks
Liming
+
+#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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#41975): https://edk2.groups.io/g/devel/message/41975
Mute This Topic: https://groups.io/mt/31934411/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20190606/5748fd2c/attachment.htm>
More information about the edk2-devel-archive
mailing list