Skip to contentSkip to conversation

ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak

PATCH In review Fangrui Song 3 participants 3 messages Nov 5, 2020 – Nov 10, 2020 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Change arch/arm/lib/mem*.S to use WEAK instead of .weak

Commit d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan") add .weak directives to memcpy/memmove/memset to avoid collision with KASAN interceptors.

This does not work with LLVM's integrated assembler (the assembly snippet .weak memcpy ... .globl memcpy produces a STB_GLOBAL memcpy while GNU as produces a STB_WEAK memcpy). LLVM 12 (since https://reviews.llvm.org/D90108)
will error on such an overridden symbol binding.

Use the appropriate WEAK macro instead.

Fixes d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
---
 arch/arm/lib/memcpy.S  | 3 +--
 arch/arm/lib/memmove.S | 3 +--
 arch/arm/lib/memset.S  | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/lib/memcpy.S +1 -2
index ad4625d16e11..e4caf48c089f 100644
@@ -58,10 +58,9 @@
 
 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
 
-.weak memcpy
 ENTRY(__memcpy)
 ENTRY(mmiocpy)
-ENTRY(memcpy)
+WEAK(memcpy)
 
 #include "copy_template.S"
 
arch/arm/lib/memmove.S +1 -2
index fd123ea5a5a4..6fecc12a1f51 100644
@@ -24,9 +24,8 @@
  * occurring in the opposite direction.
  */
 
-.weak memmove
 ENTRY(__memmove)
-ENTRY(memmove)
+WEAK(memmove)
 	UNWIND(	.fnstart			)
 
 		subs	ip, r0, r1
arch/arm/lib/memset.S +1 -2
index 0e7ff0423f50..9817cb258c1a 100644
@@ -13,10 +13,9 @@
 	.text
 	.align	5
 
-.weak memset
 ENTRY(__memset)
 ENTRY(mmioset)
-ENTRY(memset)
+WEAK(memset)
 UNWIND( .fnstart         )
 	ands	r3, r0, #3		@ 1 unaligned?
 	mov	ip, r0			@ preserve r0 as return value
Signature · 7 lines
2.29.1.341.ge80a0c044ae-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Fangrui Song

Commit d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan") add .weak directives to memcpy/memmove/memset to avoid collision with KASAN interceptors.

This does not work with LLVM's integrated assembler (the assembly snippet .weak memcpy ... .globl memcpy produces a STB_GLOBAL memcpy while GNU as produces a STB_WEAK memcpy). LLVM 12 (since https://reviews.llvm.org/D90108)
will error on such an overridden symbol binding.

Quoted 6 lines

Use the appropriate WEAK macro instead.

Fixes d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")

Thank you, this fixes a recent regression for me using LLVM_IAS=1 with ToT LLVM.

Quoted 56 lines
---
 arch/arm/lib/memcpy.S  | 3 +--
 arch/arm/lib/memmove.S | 3 +--
 arch/arm/lib/memset.S  | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/lib/memcpy.S +1 -2
index ad4625d16e11..e4caf48c089f 100644
@@ -58,10 +58,9 @@
 
 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
 
-.weak memcpy
 ENTRY(__memcpy)
 ENTRY(mmiocpy)
-ENTRY(memcpy)
+WEAK(memcpy)
 
 #include "copy_template.S"
 
arch/arm/lib/memmove.S +1 -2
index fd123ea5a5a4..6fecc12a1f51 100644
@@ -24,9 +24,8 @@
  * occurring in the opposite direction.
  */
 
-.weak memmove
 ENTRY(__memmove)
-ENTRY(memmove)
+WEAK(memmove)
        UNWIND( .fnstart                        )
 
                subs    ip, r0, r1
arch/arm/lib/memset.S +1 -3
index 0e7ff0423f50..9817cb258c1a 100644
@@ -13,10 +13,9 @@
        .text
        .align  5
 
-.weak memset
 ENTRY(__memset)
 ENTRY(mmioset)
-ENTRY(memset)
+WEAK(memset)
 UNWIND( .fnstart         )
        ands    r3, r0, #3              @ 1 unaligned?
        mov     ip, r0                  @ preserve r0 as return value
--

2.29.1.341.ge80a0c044ae-goog

Signature · 7 lines
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 1/1
#2 lore raw
In reply to Fangrui Song
Quoted 9 lines · Fangrui Song

Commit d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan") add .weak directives to memcpy/memmove/memset to avoid collision with KASAN interceptors.

This does not work with LLVM's integrated assembler (the assembly snippet .weak memcpy ... .globl memcpy produces a STB_GLOBAL memcpy while GNU as produces a STB_WEAK memcpy). LLVM 12 (since https://reviews.llvm.org/D90108)
will error on such an overridden symbol binding.

Quoted 6 lines

Use the appropriate WEAK macro instead.

Fixes d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")

When you have consensus that this is working, please put the patch into Russell's patch tracker.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel