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

acassis 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 8ed7f004500 libs/libc: Generate the system symbol tables in the CMake 
build.
8ed7f004500 is described below

commit 8ed7f004500ea979efece8b6e14cb4f20b14850b
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Oct 7 16:37:07 2026 +0200

    libs/libc: Generate the system symbol tables in the CMake build.
    
    With CONFIG_EXECFUNCS_SYSTEM_SYMTAB, the make build generates
    exec_symtab.c from libc.csv, libm.csv and syscall.csv with the host
    tool mksymtab.  CONFIG_LIBC_ELF_SYSTEM_SYMTAB does the same for
    elf_sys_symtab.c.  The CMake build did neither, so a CMake configuration
    with one of these options did not link:
    
      binfmt_execsymtab.c: undefined reference to `g_symtab'
    
    Do the same in libs/libc/CMakeLists.txt: build mksymtab as a host tool,
    sort the three lists by name, generate the table with the configured
    array and count names, and add it to the C library.  mksymtab runs in
    the build directory with relative names, so the output is the same as
    from the make build.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 libs/libc/CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/libs/libc/CMakeLists.txt b/libs/libc/CMakeLists.txt
index 55971ac8d53..cbfc2734481 100644
--- a/libs/libc/CMakeLists.txt
+++ b/libs/libc/CMakeLists.txt
@@ -24,3 +24,42 @@ nuttx_add_kernel_library(c SPLIT)
 nuttx_add_subdirectory()
 
 target_include_directories(c PRIVATE ${CMAKE_CURRENT_LIST_DIR})
+
+# Generate the system symbol tables from the C library, math library and system
+# call lists, as libs/libc/Makefile does.  The lists are sorted by name.
+
+if(CONFIG_EXECFUNCS_SYSTEM_SYMTAB OR CONFIG_LIBC_ELF_SYSTEM_SYMTAB)
+  nuttx_build_host_target(mksymtab ${NUTTX_DIR}/tools/mksymtab.c)
+
+  set(SYMTAB_CSVS
+      ${CMAKE_CURRENT_LIST_DIR}/libc.csv ${NUTTX_DIR}/libs/libm/libm.csv
+      ${NUTTX_DIR}/syscall/syscall.csv)
+  set(SYMTAB_CSV ${CMAKE_CURRENT_BINARY_DIR}/system_symtab.csv)
+
+  add_custom_command(
+    OUTPUT ${SYMTAB_CSV}
+    COMMAND cat ${SYMTAB_CSVS} | LC_ALL=C sort > ${SYMTAB_CSV}
+    DEPENDS ${SYMTAB_CSVS})
+
+  if(CONFIG_EXECFUNCS_SYSTEM_SYMTAB)
+    add_custom_command(
+      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/exec_symtab.c
+      COMMAND
+        ${NUTTX_BINARY_DIR}/bin_host/mksymtab system_symtab.csv exec_symtab.c
+        ${CONFIG_EXECFUNCS_SYMTAB_ARRAY} ${CONFIG_EXECFUNCS_NSYMBOLS_VAR}
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+      DEPENDS mksymtab ${SYMTAB_CSV})
+    target_sources(c PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/exec_symtab.c)
+  endif()
+
+  if(CONFIG_LIBC_ELF_SYSTEM_SYMTAB)
+    add_custom_command(
+      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/elf_sys_symtab.c
+      COMMAND
+        ${NUTTX_BINARY_DIR}/bin_host/mksymtab system_symtab.csv 
elf_sys_symtab.c
+        ${CONFIG_LIBC_ELF_SYMTAB_ARRAY} ${CONFIG_LIBC_ELF_NSYMBOLS_VAR}
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+      DEPENDS mksymtab ${SYMTAB_CSV})
+    target_sources(c PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/elf_sys_symtab.c)
+  endif()
+endif()

Reply via email to