This is an automated email from the ASF dual-hosted git repository.

anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ae43935fdd arch/sim: rename nuttx libc memchr to avoid host glibc 
collision
1ae43935fdd is described below

commit 1ae43935fdd01e0daefd25d04e5f0c0f27994036
Author: CuiJinji <[email protected]>
AuthorDate: Sat May 16 20:27:40 2026 +0800

    arch/sim: rename nuttx libc memchr to avoid host glibc collision
    
    The sim/src/nuttx-names.in symbol-rename list is the mechanism that
    keeps every nuttx libc function used inside nuttx.rel from clashing
    with the same-named function in host glibc when the sim executable
    is finally linked.  The list already covers ~200 symbols (memcpy,
    strlen, strcat, strchr, ...) but memchr was missing.
    
    On x86_64 Linux hosts the omission has no visible effect because
    host glibc dispatches memchr through an IFUNC resolver
    (__memchr_ifunc) that the static libc.a path does not eagerly pull
    in for typical sim links.  On HOST_ARM64 (Ubuntu 20.04 aarch64,
    glibc 2.31 .. 2.41), however, the final cc/ld invocation in the
    sim Makefile drags libc.a(memchr.o) into the link, which then
    collides with nuttx libc's lib_memchr.o that has already been
    folded into nuttx.rel:
    
        /usr/bin/ld: 
/usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libc.a(memchr.o):
            in function `__memchr_ifunc':
            (.text+0x0): multiple definition of `memchr';
            nuttx.rel:libs/libc/string/lib_memchr.c:55: first defined here
    
    Add memchr to the rename list (placed in alphabetical position
    between malloc_usable_size and memcpy).  After this fix sim:nsh
    builds cleanly on aarch64 Linux hosts (verified on NVIDIA Jetson
    Orin L4T Ubuntu 20.04 + Raspberry Pi 4B Debian 13 trixie).  The
    behaviour on x86_64 / macOS / Cygwin hosts is unchanged because
    those targets either never hit the collision or use the
    underscore-prefixed variant gated by NXSYMBOLS macro definition
    in the same file (lines 26-31).
    
    Signed-off-by: Jinji Cui <[email protected]>
---
 arch/sim/src/nuttx-names.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sim/src/nuttx-names.in b/arch/sim/src/nuttx-names.in
index 38694ede2e0..9a47af018a8 100644
--- a/arch/sim/src/nuttx-names.in
+++ b/arch/sim/src/nuttx-names.in
@@ -81,6 +81,7 @@ NXSYMBOLS(lseek)
 NXSYMBOLS(malloc)
 NXSYMBOLS(malloc_size)
 NXSYMBOLS(malloc_usable_size)
+NXSYMBOLS(memchr)  
 NXSYMBOLS(memcpy)
 NXSYMBOLS(memfd_create)
 NXSYMBOLS(mkdir)

Reply via email to