diff mbox

[edk2,2/2] StdLib/LibC ARM AARCH64: do not redefine compiler intrinsics

Message ID 1470654741-24203-2-git-send-email-ard.biesheuvel@linaro.org
State Accepted
Commit 1fbd0ca16a997b68ed320340aef18645e71e8a73
Headers show

Commit Message

Ard Biesheuvel Aug. 8, 2016, 11:12 a.m. UTC
The memset() function is a compiler intrinsics on AARCH64 and ARM, and
so is memmove() on ARM. Usually, redefining them as LibC currently does
is not a problem since only one version will be selected at link time
from the various static libraries that provide implementations. However,
under LTO, this is slightly different, since explicit references (in the
C code) and implicit references (emitted by the compiler backend) may
resolve to different versions (LTO vs non-LTO), causing conflicts.

So simply omit them for ARM/AARCH64 resp. ARM.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 StdLib/LibC/String/Copying.c | 2 ++
 StdLib/LibC/String/Misc.c    | 2 ++
 2 files changed, 4 insertions(+)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/StdLib/LibC/String/Copying.c b/StdLib/LibC/String/Copying.c
index 96be24b9a9bd..3234eccf0808 100644
--- a/StdLib/LibC/String/Copying.c
+++ b/StdLib/LibC/String/Copying.c
@@ -39,6 +39,7 @@  memcpy(void * __restrict s1, const void * __restrict s2, size_t n)
 }
 #endif  /* !(defined(MDE_CPU_IPF) && defined(__GCC)) */
 
+#if !(defined(MDE_CPU_ARM) && defined(__GNUC__))
 /** The memmove function copies n characters from the object pointed to by s2
     into the object pointed to by s1. Copying takes place as if the n
     characters from the object pointed to by s2 are first copied into a
@@ -57,6 +58,7 @@  memmove(void *s1, const void *s2, size_t n)
 {
   return CopyMem( s1, s2, n);
 }
+#endif
 
 /** The strcpy function copies the string pointed to by s2 (including the
     terminating null character) into the array pointed to by s1. If copying
diff --git a/StdLib/LibC/String/Misc.c b/StdLib/LibC/String/Misc.c
index 99328252ed50..f024136446e7 100644
--- a/StdLib/LibC/String/Misc.c
+++ b/StdLib/LibC/String/Misc.c
@@ -26,6 +26,7 @@ 
 
 extern char *sys_errlist[];
 
+#if !((defined(MDE_CPU_ARM) || defined(MDE_CPU_AARCH64)) && defined(__GNUC__))
 /** The memset function copies the value of c (converted to an unsigned char)
     into each of the first n characters of the object pointed to by s.
 
@@ -36,6 +37,7 @@  memset(void *s, int c, size_t n)
 {
   return SetMem( s, (UINTN)n, (UINT8)c);
 }
+#endif
 
 int
 strerror_r(int errnum, char *buf, size_t buflen)