nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

libc machine code update

Open GUIDINGLI opened this issue 2 weeks ago • 2 comments

Summary

This PR updates various machine-dependent and libc source files within NuttX, primarily enhancing support and correctness for RISC-V and simulator architectures. The changes include:

Modifications to machine code and assembly-level utility functions, improving compatibility and behavior for simulator and RISC-V targets. Updates to libc implementations to refine platform-dependent operations, fix bugs, and ensure consistency across supported architectures. Minor cleanups and refactoring of platform conditionals and structure definitions to support wider hardware variety.

Impact

Improves reliability and maintainability of libc and machine-dependent functionality, especially for RISC-V and simulator platforms. Enhances compatibility for future developments on simulator and real hardware. No user-facing API changes. May benefit developers working with board:simulator configurations, and those targeting RISC-V systems.

Testing

Automated and manual testing was performed: system boot, task creation, and basic libc function calls were verified.

RISC-V qemu, arm qemu

Host: x86_64 Linux

GUIDINGLI avatar Dec 08 '25 13:12 GUIDINGLI

@GUIDINGLI please fix:

../nuttx/tools/checkpatch.sh -c -u -m -g fc0647491b8bfaf90419ac7cb66ac6858a6cd76c..HEAD
❌ Missing git commit message
❌ Missing git commit message

xiaoxiang781216 avatar Dec 08 '25 18:12 xiaoxiang781216

@GUIDINGLI please fix:

../nuttx/tools/checkpatch.sh -c -u -m -g fc0647491b8bfaf90419ac7cb66ac6858a6cd76c..HEAD
❌ Missing git commit message
❌ Missing git commit message

done

GUIDINGLI avatar Dec 09 '25 03:12 GUIDINGLI

These three patch are will test and described on commit msg.

libs/risc-v:add cfi for optimized compilation func

(gdb) bt
    at /home/mi/ssd/dev-system/nuttx/include/string.h:321
    ppcmd=<synthetic pointer>, vtbl=0x80069498) at nsh_parse.c:1909
    param=0x800692b8) at nsh_parse.c:2593
    cmdline=cmdline@entry=0x80069750 "hello") at nsh_parse.c:3028
    argc=argc@entry=1, argv=argv@entry=0x80068870) at nsh_session.c:246
    at nsh_consolemain.c:75
    at nsh_main.c:74
...

libc/arm64: add cfi for optimized func

(gdb) bt
    #0  arch_strlen () at machine/arm64/gnu/arch_strlen.S:119
    #1  0x000000004043a2c0 in strchr (s=s@entry=0x408e5e40 "HELLO WORLD", c=c@entry=87) at machine/arch_libc.c:252
    #2  0x0000000040504c6c in strchr (c=87, s=0x408e5e40 "HELLO WORLD") at /home/mi/ssd/dev-system/nuttx/include/string.h:306
    #3  test_strchr () at hello_main.c:79
    #4  hello_main (argc=argc@entry=1, argv=argv@entry=0x40b5c090) at hello_main.c:132
    #5  0x000000004043d958 in nxtask_startup (entrypt=0x40504ba0 <hello_main>, argc=argc@entry=1, argv=argv@entry=0x40b5c090) at sched/task_startup.c:72
    #6  0x00000000403f1ab4 in nxtask_start () at task/task_start.c:104
    #7  0x0000000000000000 in ?? ()

armv7a:add cfi instrcutions to debug

(gdb) bt
    #0  memset () at machine/arm/armv7-a/gnu/arch_memset.S:45
    #1  0x0407222e in memset (n=4, c=65, s=0x40269d94) at /home/mi/ssd/dev-system/nuttx/include/string.h:203
    #2  test_memset () at hello_main.c:57
    #3  hello_main (argc=<optimized out>, argv=<optimized out>) at hello_main.c:66
    #4  0x0403f1de in nxtask_startup (entrypt=0x40721b1 <hello_main>, argc=1, argv=0x40269628) at sched/task_startup.c:72
    #5  0x0400c66a in nxtask_start () at task/task_start.c:104
    #6  0x00000000 in ?? ()

memset patch: memset: add none NEON version support for armv7-a/r: test with ARM_NEON disable: boards/arm/qemu/qemu-armv7a/configs/nsh/

arch:use ARCH_64BIT to mark arch is support 64bit no C code modify, only Kconfig modification. Only need compile pass and CT pass.

memcpy: fix link failed when open kasan: no C code modify, only Kconfig modification. Only need compile pass and CT pass.

GUIDINGLI avatar Dec 16 '25 13:12 GUIDINGLI