Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 9022/1: 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.

Link: https://github.com/ClangBuiltLinux/linux/issues/1190
--

Fixes: d6d51a96c7d6 ("ARM: 9014/2: Replace string mem* functions for KASan")
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Fangrui Song <maskray@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

authored by

Fangrui Song and committed by
Russell King
735e8d93 fc2933c1

+3 -6
+1 -2
arch/arm/lib/memcpy.S
··· 58 58 59 59 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ 60 60 61 - .weak memcpy 62 61 ENTRY(__memcpy) 63 62 ENTRY(mmiocpy) 64 - ENTRY(memcpy) 63 + WEAK(memcpy) 65 64 66 65 #include "copy_template.S" 67 66
+1 -2
arch/arm/lib/memmove.S
··· 24 24 * occurring in the opposite direction. 25 25 */ 26 26 27 - .weak memmove 28 27 ENTRY(__memmove) 29 - ENTRY(memmove) 28 + WEAK(memmove) 30 29 UNWIND( .fnstart ) 31 30 32 31 subs ip, r0, r1
+1 -2
arch/arm/lib/memset.S
··· 13 13 .text 14 14 .align 5 15 15 16 - .weak memset 17 16 ENTRY(__memset) 18 17 ENTRY(mmioset) 19 - ENTRY(memset) 18 + WEAK(memset) 20 19 UNWIND( .fnstart ) 21 20 ands r3, r0, #3 @ 1 unaligned? 22 21 mov ip, r0 @ preserve r0 as return value