Visitar URL original
libs/libc: Generate the system symbol tables in the CMake build by casaroli · Pull Request #20489 · apache/nuttx · GitHub
Skip to content

libs/libc: Generate the system symbol tables in the CMake build - #20489

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:libc-cmake-system-symtab
Oct 8, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:libc-cmake-system-symtab

Conversation

@casaroli

@casaroli casaroli commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

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 (libs/libc/Makefile). 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/binfmt_execsymtab.c:127: undefined reference to `g_symtab'
binfmt/binfmt_execsymtab.c:127: undefined reference to `g_nsymbols'

This PR does the same in libs/libc/CMakeLists.txt: it builds mksymtab as a host tool with nuttx_build_host_target(), sorts the three lists by name, generates the table with the configured array and count names, and adds 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.

This came up in review of #20132, which documents that a CMake configuration needs the table from elsewhere. That note goes once this merges.

Impact

CMake builds with CONFIG_EXECFUNCS_SYSTEM_SYMTAB or CONFIG_LIBC_ELF_SYSTEM_SYMTAB. No change to the make build or to CMake builds without these options.

Testing

Host: macOS arm64, Arm GNU Toolchain 13.2.rel1, CMake with Ninja. mps2-an500:xipfs with CONFIG_ELF, CONFIG_LIBC_EXECFUNCS, CONFIG_EXECFUNCS_HAVE_SYMTAB and CONFIG_EXECFUNCS_SYSTEM_SYMTAB:

build result
CMake, master link fails, undefined reference to g_symtab
CMake, this PR links; exec_symtab.c is byte-identical to the one the make build generates (699 symbols)

mps2-an500:xipfs with CONFIG_LIBC_ELF_HAVE_SYMTAB, CONFIG_LIBC_ELF_SYSTEM_SYMTAB and the names g_elf_symtab/g_elf_nsymbols: links, and nm shows both symbols. The CMake image boots to NSH under QEMU. tools/checkpatch.sh -c -u -m -g passes.

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 <marco.casaroli@gmail.com>
@github-actions github-actions Bot added Area: OS Components OS Components issues Size: S The size of the change in this PR is small labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis
acassis merged commit 8ed7f00 into apache:master Oct 8, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants