CLANG for ARM may emit calls to __aeabi_memset(), which is subtly different
from the default memset() [arguments 2 and 3 are reversed]

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
 ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S 
b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
index 0c7789eb5816..bb75d7a70b80 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
@@ -15,8 +15,23 @@
 
 
   .text
+  .syntax unified
   .align 2
   GCC_ASM_EXPORT (memset)
+  GCC_ASM_EXPORT (__aeabi_memset)
+
+# VOID
+# EFIAPI
+# __aeabi_memset (
+#  IN  VOID    *Destination,
+#  IN  UINT32  Size
+#  IN  UINT32  Character,
+#  );
+ASM_PFX(__aeabi_memset):
+  subs  ip, r1, #0
+  bxeq  lr
+  mov   r1, r2
+  b     L10
 
 # VOID
 # EFIAPI
@@ -26,13 +41,13 @@
 #  IN  UINT32  Size
 #  );
 ASM_PFX(memset):
-  cmp  r2, #0
+  subs ip, r2, #0
   bxeq lr
   @ args = 0, pretend = 0, frame = 0
   @ frame_needed = 1, uses_anonymous_args = 0
 L10:
   strb  r1, [r0], #1
-  subs  r2, r2, #1
+  subs  ip, ip, #1
   @ While size is not 0
   bne  L10
   bx   lr
-- 
2.5.0

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

Reply via email to