This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 7e25ec5eed92792974dfaf609f12b081e8dbb37d Author: ligd <[email protected]> AuthorDate: Thu May 7 15:14:12 2026 +0800 libc/machine/x86_64: Use ARCH_LIBCFUN() for the assembly symbol names. With CONFIG_MM_KASAN, arch_libc.c defines memset(), strcmp() and the other functions as wrappers that check the access and then call arch_memset(), arch_strcmp() and so on. The x86_64 assembly always used the plain names, so the wrappers were never linked in, or the link failed with multiple definitions once one of them was pulled in. Name the assembly functions with ARCH_LIBCFUN() from libc.h, as ARM and RISC-V do. Signed-off-by: ligd <[email protected]> Signed-off-by: ganjing <[email protected]> --- libs/libc/machine/x86_64/arch_memcmp.S | 3 ++- libs/libc/machine/x86_64/arch_memmove.S | 5 +++-- libs/libc/machine/x86_64/arch_memset_avx2.S | 9 +++++++-- libs/libc/machine/x86_64/arch_memset_sse2.S | 9 +++++++-- libs/libc/machine/x86_64/arch_strcmp.S | 4 +++- libs/libc/machine/x86_64/arch_strcpy.S | 4 +++- libs/libc/machine/x86_64/arch_strlen.S | 4 +++- libs/libc/machine/x86_64/arch_strncmp.S | 4 +++- libs/libc/machine/x86_64/arch_strncpy.S | 4 +++- 9 files changed, 34 insertions(+), 12 deletions(-) diff --git a/libs/libc/machine/x86_64/arch_memcmp.S b/libs/libc/machine/x86_64/arch_memcmp.S index d2cfc05b32b..47ba14a10fb 100644 --- a/libs/libc/machine/x86_64/arch_memcmp.S +++ b/libs/libc/machine/x86_64/arch_memcmp.S @@ -36,13 +36,14 @@ *********************************************************************************/ #include "cache.h" +#include "libc.h" /********************************************************************************* * Pre-processor Definitions *********************************************************************************/ #ifndef MEMCMP -# define MEMCMP memcmp +# define MEMCMP ARCH_LIBCFUN(memcmp) #endif #ifndef L diff --git a/libs/libc/machine/x86_64/arch_memmove.S b/libs/libc/machine/x86_64/arch_memmove.S index c1e95446c48..cdad8bca806 100644 --- a/libs/libc/machine/x86_64/arch_memmove.S +++ b/libs/libc/machine/x86_64/arch_memmove.S @@ -36,13 +36,14 @@ *********************************************************************************/ #include "cache.h" +#include "libc.h" /********************************************************************************* * Pre-processor Definitions *********************************************************************************/ #ifndef MEMMOVE -# define MEMMOVE memmove +# define MEMMOVE ARCH_LIBCFUN(memmove) #endif #ifndef L @@ -530,4 +531,4 @@ L(mm_large_page_loop_backward): END (MEMMOVE) -ALIAS_SYMBOL(memcpy, MEMMOVE) +ALIAS_SYMBOL(ARCH_LIBCFUN(memcpy), MEMMOVE) diff --git a/libs/libc/machine/x86_64/arch_memset_avx2.S b/libs/libc/machine/x86_64/arch_memset_avx2.S index 1d2fbbcf458..cafef011840 100644 --- a/libs/libc/machine/x86_64/arch_memset_avx2.S +++ b/libs/libc/machine/x86_64/arch_memset_avx2.S @@ -36,6 +36,7 @@ *********************************************************************************/ #include "cache.h" +#include "libc.h" /********************************************************************************* * Pre-processor Definitions @@ -49,6 +50,10 @@ # define ALIGN(n) .p2align n #endif +#ifndef MEMSET +# define MEMSET ARCH_LIBCFUN(memset) +#endif + #define ENTRY(__f) \ .text; \ .global __f; \ @@ -67,7 +72,7 @@ __f: \ .section .text.avx2,"ax",@progbits -ENTRY(memset) +ENTRY(MEMSET) movq %rdi, %rax and $0xff, %rsi mov $0x0101010101010101, %rcx @@ -176,4 +181,4 @@ L(done): vzeroupper ret -END(memset) +END(MEMSET) diff --git a/libs/libc/machine/x86_64/arch_memset_sse2.S b/libs/libc/machine/x86_64/arch_memset_sse2.S index 597f3ed03f6..febdb8dfe2a 100644 --- a/libs/libc/machine/x86_64/arch_memset_sse2.S +++ b/libs/libc/machine/x86_64/arch_memset_sse2.S @@ -36,6 +36,7 @@ *********************************************************************************/ #include "cache.h" +#include "libc.h" /********************************************************************************* * Pre-processor Definitions @@ -49,6 +50,10 @@ # define ALIGN(n) .p2align n #endif +#ifndef MEMSET +# define MEMSET ARCH_LIBCFUN(memset) +#endif + #define ENTRY(__f) \ .text; \ .global __f; \ @@ -67,7 +72,7 @@ __f: \ .section .text.sse2,"ax",@progbits -ENTRY(memset) +ENTRY(MEMSET) movq %rdi, %rax and $0xff, %rsi mov $0x0101010101010101, %rcx @@ -163,4 +168,4 @@ L(128bytesmore_nt): sfence ret -END(memset) +END(MEMSET) diff --git a/libs/libc/machine/x86_64/arch_strcmp.S b/libs/libc/machine/x86_64/arch_strcmp.S index 75722639d61..02b4cafd03c 100644 --- a/libs/libc/machine/x86_64/arch_strcmp.S +++ b/libs/libc/machine/x86_64/arch_strcmp.S @@ -35,6 +35,8 @@ * Pre-processor Definitions *********************************************************************************/ +#include "libc.h" + #ifdef USE_AS_STRNCMP /* Since the counter, %r11, is unsigned, we branch to strcmp_exitz if the new counter > the old one or is 0. */ @@ -50,7 +52,7 @@ #else #define UPDATE_STRNCMP_COUNTER #ifndef STRCMP -#define STRCMP strcmp +# define STRCMP ARCH_LIBCFUN(strcmp) #endif #endif diff --git a/libs/libc/machine/x86_64/arch_strcpy.S b/libs/libc/machine/x86_64/arch_strcpy.S index 3768b8f0d3e..556a6d14a6b 100644 --- a/libs/libc/machine/x86_64/arch_strcpy.S +++ b/libs/libc/machine/x86_64/arch_strcpy.S @@ -35,10 +35,12 @@ * Pre-processor Definitions *********************************************************************************/ +#include "libc.h" + #ifndef USE_AS_STRCAT # ifndef STRCPY -# define STRCPY strcpy +# define STRCPY ARCH_LIBCFUN(strcpy) # endif # ifndef L diff --git a/libs/libc/machine/x86_64/arch_strlen.S b/libs/libc/machine/x86_64/arch_strlen.S index 1a88c17adf0..5472f8927f6 100644 --- a/libs/libc/machine/x86_64/arch_strlen.S +++ b/libs/libc/machine/x86_64/arch_strlen.S @@ -35,10 +35,12 @@ * Pre-processor Definitions *********************************************************************************/ +#include "libc.h" + #ifndef USE_AS_STRCAT #ifndef STRLEN -# define STRLEN strlen +# define STRLEN ARCH_LIBCFUN(strlen) #endif #ifndef L diff --git a/libs/libc/machine/x86_64/arch_strncmp.S b/libs/libc/machine/x86_64/arch_strncmp.S index 6ea2803f929..a78c0fe1004 100644 --- a/libs/libc/machine/x86_64/arch_strncmp.S +++ b/libs/libc/machine/x86_64/arch_strncmp.S @@ -35,6 +35,8 @@ * Included Files *********************************************************************************/ +#include "libc.h" + #define USE_AS_STRNCMP -#define STRCMP strncmp +#define STRCMP ARCH_LIBCFUN(strncmp) #include "arch_strcmp.S" diff --git a/libs/libc/machine/x86_64/arch_strncpy.S b/libs/libc/machine/x86_64/arch_strncpy.S index 4cbcc038595..2e79e0c0c83 100644 --- a/libs/libc/machine/x86_64/arch_strncpy.S +++ b/libs/libc/machine/x86_64/arch_strncpy.S @@ -35,6 +35,8 @@ * Included Files *********************************************************************************/ +#include "libc.h" + #define USE_AS_STRNCPY -#define STRCPY strncpy +#define STRCPY ARCH_LIBCFUN(strncpy) #include "arch_strcpy.S"
