Skip to content

Commit

Permalink
ARM: 9022/1: Change arch/arm/lib/mem*.S to use WEAK instead of .weak
Browse files Browse the repository at this point in the history
Commit d6d51a9 ("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: d6d51a9 ("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>
  • Loading branch information
Fangrui Song authored and Russell King committed Nov 12, 2020
1 parent fc2933c commit 735e8d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions arch/arm/lib/memcpy.S
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 1 addition & 2 deletions arch/arm/lib/memmove.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
* occurring in the opposite direction.
*/

.weak memmove
ENTRY(__memmove)
ENTRY(memmove)
WEAK(memmove)
UNWIND( .fnstart )

subs ip, r0, r1
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/lib/memset.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 735e8d9

Please sign in to comment.