[PATCH 2/3] ArmPkg/CompilerIntrinsicsLib: make the default memset() weak


Ard Biesheuvel
 

The ARM compiler intrinsics library defines __aeabi_memset() and
memset() in the same object, which means that both will be pulled
in if either is referenced.

The IntrinsicLib in CryptoPkg defines its own, preferred memset(),
which may clash with our memset(). So make our version weak.

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

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
index bb75d7a70b80..65f6289b410b 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memset.S
@@ -40,6 +40,14 @@ ASM_PFX(__aeabi_memset):
# IN UINT32 Character,
# IN UINT32 Size
# );
+ //
+ // This object may be pulled in to satisfy an undefined reference to
+ // __aeabi_memset above, but in some cases, memset() is already provided
+ // by another library (i.e., CryptoPkg/IntrinsicLib), in which case we
+ // prefer the other version. So allow this one to be overridden by
+ // giving it weak linkage.
+ //
+ .weak memset
ASM_PFX(memset):
subs ip, r2, #0
bxeq lr
--
2.7.4