libc/machine:Add prefixes to libc functions implemented by arch

kasan does not instrument the assembly function,
so it is checked in advance before calling.
If Kasan is not turned on, the speed and space will
be almost unchanged under compiler optimization.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao
2024-01-04 20:11:02 +08:00
committed by Xiang Xiao
parent 6ee73bc199
commit 603c87977f
53 changed files with 468 additions and 184 deletions
@@ -140,10 +140,10 @@
.thumb_func
.align 4
.p2align 4,,15
.global memchr
.type memchr,%function
.global ARCH_LIBCFUN(memchr)
.type ARCH_LIBCFUN(memchr),%function
memchr:
ARCH_LIBCFUN(memchr):
.cfi_sections .debug_frame
.cfi_startproc
/* Use a simple loop if there are less than 8 bytes to search. */
@@ -272,7 +272,7 @@ memchr:
bx lr
.cfi_endproc
.size memchr, . - memchr
.size ARCH_LIBCFUN(memchr), . - ARCH_LIBCFUN(memchr)
#elif __ARM_ARCH_ISA_THUMB >= 2 && defined (__ARM_FEATURE_DSP)
@@ -295,9 +295,9 @@ memchr:
.thumb_func
.align 2
.p2align 4,,15
.global memchr
.type memchr,%function
memchr:
.global ARCH_LIBCFUN(memchr)
.type ARCH_LIBCFUN(memchr),%function
ARCH_LIBCFUN(memchr):
@ r0 = start of memory to scan
@ r1 = character to look for
@ r2 = length
@@ -96,11 +96,11 @@
.text
.section .text.memcpy
.align 2
.global memcpy
.global ARCH_LIBCFUN(memcpy)
.thumb
.thumb_func
.type memcpy, %function
memcpy:
.type ARCH_LIBCFUN(memcpy), %function
ARCH_LIBCFUN(memcpy):
@ r0: dst
@ r1: src
@ r2: len
@@ -355,6 +355,6 @@ memcpy:
#endif
bx lr
.size memcpy, .-memcpy
.size ARCH_LIBCFUN(memcpy), .-ARCH_LIBCFUN(memcpy)
#endif
@@ -35,11 +35,9 @@
.thumb
.syntax unified
.text
.section .text.memmove
.global memmove
.type memmove, %function
memmove:
.global ARCH_LIBCFUN(memmove)
.type ARCH_LIBCFUN(memmove), %function
ARCH_LIBCFUN(memmove):
cmp r0, r1
push {r4}
bls 3f
@@ -69,6 +67,6 @@ memmove:
bne 4b
pop {r4}
bx lr
.size memmove, . - memmove
.size ARCH_LIBCFUN(memmove), . - ARCH_LIBCFUN(memmove)
#endif
@@ -35,11 +35,9 @@
.thumb
.syntax unified
.text
.section .text.memset
.global memset
.type memset, %function
memset:
.global ARCH_LIBCFUN(memset)
.type ARCH_LIBCFUN(memset), %function
ARCH_LIBCFUN(memset):
stmfd sp!, {r0, r4-r7, lr}
rsb r3, r0, #0
ands r3, r3, #3
@@ -106,6 +104,6 @@ memset:
movs r2, r2, lsl #2
strbcs r1, [r0]
ldmfd sp!, {r0, r4-r7, pc}
.size memset, . - memset
.size ARCH_LIBCFUN(memset), . - ARCH_LIBCFUN(memset)
#endif
@@ -81,7 +81,7 @@
.thumb
.syntax unified
def_fn strcmp
def_fn ARCH_LIBCFUN(strcmp)
.cfi_sections .debug_frame
.cfi_startproc
eor tmp1, src1, src2
@@ -413,6 +413,6 @@ def_fn strcmp
.cfi_def_cfa_offset 0
bx lr
.cfi_endproc
.size strcmp, . - strcmp
.size ARCH_LIBCFUN(strcmp), . - ARCH_LIBCFUN(strcmp)
#endif
@@ -62,11 +62,11 @@
.text
.section .text.strcpy
.align 2
.global strcpy
.global ARCH_LIBCFUN(strcpy)
.thumb
.type strcpy, %function
.type ARCH_LIBCFUN(strcpy), %function
strcpy:
ARCH_LIBCFUN(strcpy):
push {result, tmp1, tmp2, tmp3, src_offset}
eor tmp1, dst, src
tst tmp1, #3
@@ -108,7 +108,7 @@
#define tmp1 r4 /* Overlaps const_0 */
#define tmp2 r5
def_fn strlen p2align=6
def_fn ARCH_LIBCFUN(strlen) p2align=6
pld [srcin, #0]
strd r4, r5, [sp, #-8]!
bic src, srcin, #7
@@ -186,6 +186,6 @@ def_fn strlen p2align=6
movne data1a, const_m1
mov const_0, #0
b .Lstart_realigned
.size strlen, . - strlen
.size ARCH_LIBCFUN(strlen), . - ARCH_LIBCFUN(strlen)
#endif