memset_chk into assembly file

Writing an assembly file can reduce several
assembly instructions, and compare it through
the disassembly of this file

Test: make libc
Change-Id: Ifdcc9c76742cc95b2ad9e3c14fac4796c36e12e6
Signed-off-by: caowencheng <caowencheng@eswincomputing.com>
This commit is contained in:
caowencheng 2023-03-06 14:57:55 +08:00 committed by wencheng cao
parent c920ac5695
commit ab457f9022
3 changed files with 15 additions and 10 deletions

View file

@ -672,7 +672,6 @@ cc_library_static {
},
riscv64: {
srcs: [
"arch-riscv64/string/memset_chk.c",
"upstream-freebsd/lib/libc/string/memcmp.c",
"upstream-freebsd/lib/libc/string/memcpy.c",
"upstream-freebsd/lib/libc/string/memmove.c",
@ -825,6 +824,11 @@ cc_library_static {
"arch-arm64/string/__memset_chk.S",
],
},
riscv64: {
srcs: [
"arch-riscv64/string/__memset_chk.S",
],
},
},
}

View file

@ -0,0 +1,10 @@
#include <private/bionic_asm.h>
ENTRY(__memset_chk)
bleu a2, a3, 1f
call __memset_chk_fail
1:
tail memset
END(__memset_chk)

View file

@ -1,9 +0,0 @@
#include <stdint.h>
extern void* memset(void*, int, size_t);
extern void* __memset_chk_fail(void*, int, size_t, size_t);
void* __memset_chk(void* dst, int c, size_t n, size_t dst_len) {
if (dst_len < n) __memset_chk_fail(dst, c, n, dst_len);
return memset(dst, c, n);
}