diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc --- a/lib/libc/aarch64/string/Makefile.inc +++ b/lib/libc/aarch64/string/Makefile.inc @@ -10,16 +10,16 @@ memmove \ memrchr \ memset \ - stpcpy \ strchr \ strchrnul \ strcmp \ strcpy \ - strlen \ strncmp \ strnlen \ strrchr +MDSRCS+= strcat.S + # # Add the above functions. Generate an asm file that includes the needed # Arm Optimized Routines file defining the function name to the libc name. diff --git a/lib/libc/aarch64/string/strcat.S b/lib/libc/aarch64/string/strcat.S new file mode 100644 --- /dev/null +++ b/lib/libc/aarch64/string/strcat.S @@ -0,0 +1,29 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Getz Mikalsen +*/ + +#include + + .weak strcat + .set strcat, __strcat + .text + +ENTRY(__strcat) + stp x29, x30, [sp, #-16]! + str x19, [sp, #-16]! // store preserved registers + + mov x19, x0 // stash dest for later + bl strlen // strlen(dest) + + add x0, x19, x0 // dest + (strlen(dest)) + bl stpcpy // stpcpy(dest + strlen(dest), src) + + mov x0, x19 // return dest + + ldr x19, [sp], #16 // load preserved registers + ldp x29, x30, [sp], #16 + ret + +END(__strcat)